more
This commit is contained in:
parent
152b6261a5
commit
20a085da93
26
playground/mongodb-delete.js
Normal file
26
playground/mongodb-delete.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// const MongoClient = require('mongodb').MongoClient;
|
||||||
|
const {MongoClient, ObjectID} = require('mongodb');
|
||||||
|
|
||||||
|
|
||||||
|
var mongoUrl = 'mongodb://127.0.0.1:27017/TodoApp';
|
||||||
|
|
||||||
|
MongoClient.connect(mongoUrl, (err, db) => {
|
||||||
|
if (err) {
|
||||||
|
return console.log('Unable to connect to MongoDB Server', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
//deleteMany
|
||||||
|
// db.collection("Todos").deleteMany({text: "Walk the dog"}).then((result) => {
|
||||||
|
// console.log(result);
|
||||||
|
// })
|
||||||
|
//deleteOne
|
||||||
|
// db.collection("Todos").deleteOne({text: "Something to do"}).then((result) => {
|
||||||
|
// console.log(result);
|
||||||
|
// })
|
||||||
|
//findOneAndDelete
|
||||||
|
var todo = db.collection("Todos").findOneAndDelete({text: "Something to do"}).then((result) => {
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
// db.close();
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user