MongoDb Practice 

   
   

Output:

{"t":{"$date":"2023-02-06T18:56:34.861Z"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"-","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":13},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":13},"outgoing":{"minWireVersion":0,"maxWireVersion":13},"isInternalClient":false}}}
switched to db inventory
{
	"acknowledged" : true,
	"insertedIds" : [
		ObjectId("63e14d623b7cb3750aa9b484"),
		ObjectId("63e14d623b7cb3750aa9b485"),
		ObjectId("63e14d623b7cb3750aa9b486"),
		ObjectId("63e14d623b7cb3750aa9b487"),
		ObjectId("63e14d623b7cb3750aa9b488")
	]
}
{ "_id" : ObjectId("63e14d623b7cb3750aa9b484"), "item" : "journal", "instock" : [ { "warehouse" : "A", "qty" : 5 }, { "warehouse" : "C", "qty" : 15 } ] }
{ "_id" : ObjectId("63e14d623b7cb3750aa9b486"), "item" : "paper", "instock" : [ { "warehouse" : "A", "qty" : 60 }, { "warehouse" : "B", "qty" : 15 } ] }
{ "_id" : ObjectId("63e14d623b7cb3750aa9b487"), "item" : "planner", "instock" : [ { "warehouse" : "A", "qty" : 40 }, { "warehouse" : "B", "qty" : 5 } ] }
{ "_id" : ObjectId("63e14d623b7cb3750aa9b488"), "item" : "postcard", "instock" : [ { "warehouse" : "B", "qty" : 15 }, { "warehouse" : "C", "qty" : 35 } ] }

MongoDB online editor

Write, Run & Share MongoDB queries online using OneCompiler's MongoDB online editor and compiler for free. It's one of the robust, feature-rich online editor and compiler for MongoDB. Getting started with the OneCompiler's MongoDB editor is really simple and pretty fast. The editor shows sample boilerplate code when you choose language as 'MongoDB' and start writing queries to learn and test online without worrying about tedious process of installation.

About MongoDB

MongoDB is a cross platform document oriented NoSQL database.

Key Features:

  • Designed to overcome the the limitations of relational databases approach and other NoSQL solutions
  • Horizontal scaling
  • Load balancing capabilities
  • Better data availability and stability

Syntax help

Commands

Inserting documents

  1. db.collection.insert(): Using insert you can either insert one document or array of documents

  1. db.collection.insertOne(): Inserts one document

  1. db.collection.insertMany: Inserts multiple documents

Updating documents

  1. db.collection.update() : Updates one or more than one document(s) in collection based on matching document and based on multi option

  1. db.collection.updateOne() : Updates a single document in collection based on matching document

  1. db.collection.updateMany() : Updates multiple documents in collection based on the condition.

Deleting documents

  1. db.collection.deleteOne(<filter>, <options>): Deletes a Single document from collection

  1. db.collection.deleteMany(<filter>, <options>): Deletes all documents with matching filter


© Copyright 2025 One Compiler Pvt. Ltd. | Privacy Policy | Terms & Conditions