technical skills grow

Responsive Ads Here

Tuesday, December 12, 2023

MongoDB CRUD Operations

 CRUD Operations 

CRUD == Create, Read, Update, Delete

 Create Operations  

   •Create and Add new documents to the collections

 Read Operations

    Retrieve data from the collections 

Update Operations  

Modify existing documents in the collection 

Delete Operations  

Delete or remove documents from the collections

Database and Collection Creation

List databases

 List collections 

Create new database “myNewDB 

Create new collections “myNewCollections2” and “myNewCollections3 

Switch between the databases 

Capped Collections 

Create Capped Collection 

Create capped collection with size 100000 bytes 

Specify maximum number of documents 

Check if collection is capped 

Create (Insert) Operation 

Add new documents to the collection

It creates the collection 

Targets single collection 

Automic write operations on the single document level 

Unique _id field, which acts as primary key 

Auto-creates _id field if not present 


Read (Query) Operation

Query a collection for documents 

You can specify query filters 

You can specify the list of fields to

Can use indexes

Can perform sort and limit operations

 Update Operation

Modifies existing documents in a collection

 Targets a single collection 

Atomic write operations on the single document level 

You can specify criteria, or filters 

You cannot update the value of the _id field

Delete (Remove) Operation

Removes documents from a collection 

Targets a single collection 

Atomic write operations on the single document level 

You can specify criteria, or filters 

Delete operations do not drop indexes

 


 

No comments:

Post a Comment

Powered by Blogger.

Labels

Contact Form

Name

Email *

Message *

Search This Blog

Blog Archive

Ad Code

Responsive Advertisement

Recent Posts