MongoDBCRUD Operation


Syntax

  • insert(document or array of documents)
  • insertOne( 'document', { writeConcern: 'document' } )
  • insertMany( { [ document 1 , document 2, ... ] }, { writeConcern: document, ordered: boolean } )
  • find(query, projection)
  • findOne(query, projection)
  • update(query, update)
  • updateOne( query, update, { upsert: boolean, writeConcern: document } )
  • updateMany( query, update, { upsert: boolean, writeConcern: document } )
  • replaceOne( query, replacement, { upsert: boolean, writeConcern: document } )
  • remove(query, justOne)
  • findAndModify(query, sort, update, options[optional])

Remarks

Updating and Deleting a document should be done carefully. Since operation may affect for multiple documents.