27 lines
730 B
JavaScript
27 lines
730 B
JavaScript
// 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);
|
|
}
|
|
// db.collection('Todos').find().toArray().then((docs) => {
|
|
// console.log("Todos");
|
|
// console.log(JSON.stringify(docs, null, 2));
|
|
//
|
|
// }, (err) => {
|
|
// console.log("Unable to fetch todos", err);
|
|
// })
|
|
|
|
db.collection('Users').find({name: 'Tyrel'}).toArray().then((docs) => {
|
|
console.log(JSON.stringify(docs, null, 2));
|
|
}, (err) => {
|
|
console.log("Unable to fetch todos", err);
|
|
})
|
|
|
|
// db.close();
|
|
})
|