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

 


 

2 comments:

  1. The article gives a clear introduction to MongoDB CRUD operations by separating Create, Read, Update, and Delete tasks and then moving into database and collection management. The explanation of automatic _id generation, single-document atomic writes, query filters, indexes, sorting, and limiting makes the fundamentals easier to connect with practical database work.

    The section on creating databases and collections is particularly useful for understanding how MongoDB organizes data before performing CRUD operations. For someone building applications, learning these fundamentals through a structured Mongodb Course can provide a useful foundation for working with NoSQL databases.

    ReplyDelete
  2. The database and collection creation section is useful because it introduces practical tasks such as listing databases, switching between databases, and creating collections. These concepts are especially relevant when learning MongoDB as part of a MEAN Stack Course, where MongoDB forms an important part of the application stack.

    ReplyDelete

Powered by Blogger.

Labels

Contact Form

Name

Email *

Message *

Search This Blog

Blog Archive

Ad Code

Responsive Advertisement

Recent Posts