1//CRUD
2
3const mongodb = require('mongodb');
4const MongoClient = mongodb.MongoClient;
5
6const connectionURl = 'mongodb://127.0.0.1:27017';
7const databaseName = 'task-manager';
8
9MongoClient.connect(
10 connectionURl,
11 { useNewUrlParser: true },
12 (error, client) => {
13 if (error) {
14 return console.log('unable to connect to database');
15 }
16
17 const db = client.db(databaseName);
18
19 db.collection('users').insertOne({
20 name: 'user',
21 age: 24,
22 });
23 }
24);
25