DEV Community

Joy Dey
Joy Dey

Posted on

CRUD

CRUD is a short form of Create, Read, Update and Delete. These are the basic operations to perform with the database system. To interact with a database, we used crud operations. CRUD is used for anything related to databases and database systems. Software, Web Development can not be imagined without these operations nowadays. The CRUD also appears in the discussion of REST APIs. In HTTP, the GET, PUT and DELETE methods are crud operations as they can manipulate the states of target resources. For Database, we are showing this operation with MongoDB, which is a NoSQL database system.

Create Operation

Create or insert operations add new documents to a collection. If the collection does not exist, insert operations will create a new collection in the database.
MongoDB provides some methods to insert data in the database

db.collection.insertOne() New in version 3.2
db.collection.insertMany() New in version 3.2
Enter fullscreen mode Exit fullscreen mode

Read Operation

Read operations retrieve data from the collection of databases. The query is a collection of documents.
There are some methods that we can use to read or find the data from the database

db.collection.find()
Enter fullscreen mode Exit fullscreen mode

Update Operation

Update operations updates or modify existing data from the data collections. We use some update methods to update or modify data the content in the database.

db.collection.updateOne() New in version 3.2
db.collection.updateMany() New in version 3.2
db.collection.replaceOne() New in version 3.2
Enter fullscreen mode Exit fullscreen mode

Delete Operation

Delete operations remove or delete data from the data collections. The methods of delete operation in nosql are -

db.collection.deleteOne() New in version 3.2
db.collection.deleteMany() New in version 3.2
Enter fullscreen mode Exit fullscreen mode

Top comments (0)