36 lines
932 B
JavaScript
36 lines
932 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').insertOne({
|
|
// text: 'Something to do',
|
|
// completed: false
|
|
// }, (err, result) => {
|
|
// if (err) {
|
|
// return console.log('Unable to insert todo', err);
|
|
// }
|
|
// console.log(JSON.stringify(result.ops, undefined, 2));
|
|
// })
|
|
|
|
// db.collection('Users').insertOne({
|
|
// name: "Tyrel",
|
|
// age: 29,
|
|
// location: "Boston"
|
|
// }, (err, result) => {
|
|
// if (err) {
|
|
// return console.log('Unable to insert user', err);
|
|
// }
|
|
// console.log(JSON.stringify(result.ops, undefined, 2));
|
|
// console.log(result.ops[0]._id.getTimestamp());
|
|
// })
|
|
|
|
|
|
db.close();
|
|
})
|