Skip to main content

MongoDB CRUD Operations Introduction

Create

insertOne(data, options)

To insert one record.

insertMany(data, options)

To insert multiple records at once.

Read

find(filter, options)

returns all data available after applying filter

findOne(filter, options)

returns the first occurrence after applying filter

Update

updateOne(filter, data, options)

To find and update first record of the filter

updateMany(filter, data, options)

To find and update all records in the filter

replaceOne(filter, data, options)

very similar to updateOne

Delete

deleteOne(filter, options)

delete the first record in the filter

deleteMany(filter, options)

deletes all records in the filter

Comments