-
Notifications
You must be signed in to change notification settings - Fork 3
/
02.InsertData.js
60 lines (55 loc) · 1.03 KB
/
02.InsertData.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
//Insert Document
db.getCollection("employee").insert({
name: "Mohammad Sujon",
designation: "web developer",
salary: 20000,
});
/*
executed result
for single document => WriteResult({ "nInserted" : 1 })
for multiple document => {
"writeErrors" : [],
"writeConcernErrors" : [],
"nInserted" : 3.0,
"nUpserted" : 0.0,
"nMatched" : 0.0,
"nModified" : 0.0,
"nRemoved" : 0.0,
"upserted" : []
}*/
//Insert single Document
db.getCollection("employee").insertOne({
name: "Mohammad Sujon",
designation: "web developer",
salary: 20000,
});
/*
executed result
{
"acknowledged" : true,
"insertedId" : ObjectId("6474d6d880389505350476aa")
}
}*/
//Inset Multiple Document
db.getCollection("employee").insertMany([
{
name: "Hamim",
designation: "Marketing",
salary: 80000,
},
{
name: "Poros",
designation: "Email Sender",
salary: 10000,
},
]);
/*
executed result
{
"acknowledged" : true,
"insertedIds" : [
ObjectId("6474d74380389505350476ab"),
ObjectId("6474d74380389505350476ac")
]
}
}*/