-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongo_DB_creation.js
106 lines (87 loc) · 2.72 KB
/
mongo_DB_creation.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const mongodb = require('mongodb');
const dbName = 'test'
var url = `mongodb://localhost:27017/${dbName}`;
console.info('Attampting to create Dummy DB')
mongodb.MongoClient.connect(url, function (err, db) {
if (err) {
console.log('Cannot connect to DB', err)
}
else {
console.log("Connected to DB");
insertData();
}
});
function insertData() {
const collection = mongodb.MongoClient.collection(dbName);
collection.insertMany([
{ a: 1 }, { a: 2 }, { a: 3 },
])
console.log('inserted')
};
// var doc1 = {'hello':'doc1'};
// var doc2 = {'hello':'doc2'};
// var lotsOfDocs = [{ 'hello': 'doc3' }, { 'hello': 'doc4' }];
// db.runCommand(
// {
// insert: "meal",
// foods: [],
// time: "timestamp",
// userId: "userId"[
// { user: "ijk123", status: "A" },
// { user: "xyz123", status: "P" },
// { user: "mop123", status: "P" }
// ],
// ordered: false,
// writeConcern: { w: "majority", wtimeout: 5000 }
// },
// {
// insert: "meal",
// foods: [
// { user: "ijk123", status: "A" },
// { user: "xyz123", status: "P" },
// { user: "mop123", status: "P" }
// ],
// ordered: false,
// writeConcern: { w: "majority", wtimeout: 5000 }
// },
// {
// insert: "meal",
// foods: [
// { user: "ijk123", status: "A" },
// { user: "xyz123", status: "P" },
// { user: "mop123", status: "P" }
// ],
// ordered: false,
// writeConcern: { w: "majority", wtimeout: 5000 }
// },
// )
// db.runCommend({
// "insert": "meal",
// "user": [
// { "username": "aa", "password": "aA" },
// { "_id": 2, "username": "bb", "password": "bB" },
// { "_id": 3, "username": "cc", "password": "cC" },
// { "_id": 4, "username": "jaja", "password": "jajA" }
// ],
// "ordered": false,
// },
// {
// "insert": "meal",
// "user": [
// { "_id": 1, "username": "aa", "password": "aA" },
// { "_id": 2, "username": "bb", "password": "bB" },
// { "_id": 3, "username": "cc", "password": "cC" },
// { "_id": 4, "username": "jaja", "password": "jajA" }
// ],
// "ordered": false,
// },
// {
// "insert": "felling",
// "user": [
// { "_id": 1, "username": "aa", "password": "aA" },
// { "_id": 2, "username": "bb", "password": "bB" },
// { "_id": 3, "username": "cc", "password": "cC" },
// { "_id": 4, "username": "jaja", "password": "jajA" }
// ],
// "ordered": false,
// })