-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestingMongoDB.js
31 lines (24 loc) · 1.04 KB
/
testingMongoDB.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
var mongoClient = require("mongodb").MongoClient;
var assert = require("assert");
var dboper = require("./operations")
var url = "mongodb://localhost:27017/conFusion";
mongoClient.connect(url, function(err, db) {
assert.equal(err, null);
console.log("Connect correctly to server");
dboper.insertDocument(db, {name : "Fatta", description : "An egyptian meal"}, "dishes", function(result) {
console.log(result.ops);
dboper.findDocument(db, "dishes", function(docs) {
console.log(docs);
dboper.updateDocument(db, {name : "Fatta"}, {description : "The best meal ever"}, "dishes", function(result) {
console.log(result.result);
dboper.findDocument(db, "dishes", function(docs) {
console.log(docs);
db.dropCollection("dishes", function(result) {
console.log("drop collection result : " + result);
db.close();
});
});
});
});
});
});