Navigation

What is MongoDB?

Homepage hero image

Work with your data in MongoDB

➜ mongosh --port 27017
Current Mongosh Log ID:  123a4bc5d67891011ef1213g
Connecting to:    mongodb://127.0.0.1:27017/

For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/

test> db.messages.insertMany([
         {
            message: "Hello World!",
            author: "MongoDB",
            comments: [],
            _id: 1
         }
      ])
{ acknowledged: true, insertedIds: { '0': 1 } }

test> db.messages.findOne({ _id: 1 })
{ _id: 1, message: 'Hello World!', author: 'MongoDB', comments: [] }
test> db.orders.insertMany([
   { "item" : "almonds", "price" : 12, "quantity" : 2 },
   { "item" : "pecans", "price" : 20, "quantity" : 1 },
])

test> db.inventory.insertMany([
   { "sku" : "almonds", "description": "product 1", "instock" : 120 },
   { "sku" : "cashews", "description": "product 3", "instock" : 60 },
   { "sku" : "pecans", "description": "product 4", "instock" : 70 }
])

test> db.orders.aggregate([
   { $match: { price: { $lt: 15 } } },
   { $lookup: {
         from: "inventory",
         localField: "item",
         foreignField: "sku",
         as: "inventory_docs"
   } },
   { $sort: { price: 1 } },
])
MongoDB Security
MongoDB Deploy and Scale