From 20a085da931009c1e42ff821073b44658663ea5d Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Wed, 29 Nov 2017 00:46:57 -0500 Subject: [PATCH] more --- playground/mongodb-delete.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 playground/mongodb-delete.js diff --git a/playground/mongodb-delete.js b/playground/mongodb-delete.js new file mode 100644 index 0000000..4cee234 --- /dev/null +++ b/playground/mongodb-delete.js @@ -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(); +})