CRUD Operations
CRUD Operations
CRUD Operations
Create
Read
Update
Delete
Explore Databases and Collections
๏ Show active Database
db
returns "insertedId" of
๏ Insert One Document the inserted document
db.<collection name>.insertOne(<Object>)
{
"acknowledged" : true,
"insertedId" : ObjectId("5ad06d63be9df1be43808588")
}
insertMany()
{
"acknowledged" : true,
"insertedIds" : [
ObjectId("5ad06d71be9df1be43808589"),
ObjectId("5ad06d71be9df1be4380858a"),
ObjectId("5ad06d71be9df1be4380858b")
]
}
Insert Document Example
Read Documents
Returns Cursor
๏ Find Documents Cursor must be iterated
db.<collection name>.find(<query>, <fields>) to get documents in
Extended JSON format
cursor
MongoDB MongoDB
Client Server
next Batch
SORT
SKIP
LIMIT
findOne()