Please enable JavaScript.
Coggle requires JavaScript to display documents.
MongoDB CRUD Operations: Replace and Delete Documents - Coggle Diagram
MongoDB CRUD Operations: Replace and Delete Documents
Update Documents
updateMany()
Update beberapa dokumen dalam satu collection
Accepts 3 arguments: filter, update, options
updateOne()
Accepts 3 arguments: filter, update, options
Update using operator
$set
Update nilai sebuah field dari nilai yang ditentukan
$push
Menambahkan nilai ke array
Jika tidak ada, menambahkan field array dengan nilai sebagai elemennya
Pembaruan hanya terjadi jika sebuah dokumen cocok dengan query filter
Update single document
upsert
Berasal dari kata update or insert
Insert dokumen dengan informasi yang disediakan jika dokumen yang cocok tidak ada
Menggunakan value boolean (true
Argument options
findAndModify()
Untuk mencari dan mengganti single document
Return document yang baru saja di-update
Accepts 3 arguments: dokumen filter, dokumen pengganti, dan objek opsi opsional.
Replace Documents
replaceOne()
Replace single document
Accepts 3 arguments
Filter: a query that matches the document to replace.
Replacement: the new document to replace the old one with.
Options: An object that specifies options for the update.
db.collection.replaceOne(filter, replacement, options)
Return dokumen yang berisi acknowledgement of the operation, a matched count, modified count, and an upserted ID (if applicable)
Delete Documents
deleteOne()
Menghapus satu document
deleteMany()
Menghapus banyak document