MongoDB

Posted by rightpeter on July 24, 2015

Update()

Reference to mongoDB

Example:

db.products.update(
    { _id: 100 },
    {
        {
            quantity: 500,
            details: { model: "14Q3", make: "xyz" },
            tags: [ "coats", "outerwear", "clothing" ]
        }
    }
)

Find schema of a collection in MongoDB

Reference to Optimal.io

Open a mongo shell and run the following commands:

MongoDB shell versio: x.x.x
> show dbs
local 0.078GB
todo 0.xxGB
> use todo
switched to db todo
> show collections
system.indexes
tasks
> var scematodo = db.tasks.findOne():
> for (var key in schematodo) { print (key) ; }
_id
label
content