-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (31 loc) · 1.33 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var MongoClient = require('mongodb').MongoClient,
assert = require('assert');
var dboper = require('./operations');
// Connection URL
var url = 'mongodb://localhost:27017/conFusion';
// Use connect method to connect to the Server
MongoClient.connect(url, function (err, db) {
assert.equal(null, err);
console.log("Connected correctly to server");
dboper.insertDocument(db, { name: "Vadonut", description: "Test" },
"dishes", function (result) {
console.log(result.ops);
dboper.findDocuments(db, "dishes", function (docs) {
console.log(docs);
dboper.updateDocument(db, { name: "Vadonut" },
{ description: "Updated Test" },
"dishes", function (result) {
console.log(result.result);
dboper.findDocuments(db, "dishes", function (docs) {
console.log(docs);
//db.dropCollection("dishes", function (result) {
// console.log(result);
//db.close();
db.collection("dishes").remove();
db.close();
//});
});
});
});
});
});