-
Notifications
You must be signed in to change notification settings - Fork 0
/
03-03.mongodb.js
84 lines (66 loc) · 1.57 KB
/
03-03.mongodb.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
db.employees.insertOne({
name: "lake",
age: 21,
dept: "Database",
joinDate: new ISODate("2024-07-23"),
salary: 400000,
bonus: null
})
db.employees.insertMany([{
name: "고윤정",
age: 21,
dept: "Network",
joinDate: new ISODate("2020-07-23"),
salary: 100000,
resignationDate: new ISODate("2024-07-23"),
bonus: null
},
{
name: "카라나",
age: 21,
dept: "Database",
isNegotiating: true
},
])
db.employees.updateOne({ name: "카라나" }, {
$set: {
name: "카리나",
salary: 350000,
dept: "Software",
joinDate: new ISODate("2024-07-23")
},
$unset: {
isNegotiating: ""
}
})
db.employees.updateMany({ resignationDate: { $exists: false }, joinDate: { $exists: true } }, { $mul: { salary: Decimal128("1.1") } })
db.employees.deleteOne({ name: "lake" })
// 전체 삭제
db.employees.deleteMany({})
// show collections 후에 실행
db.employees.drop()
// sample_guides
db.planets.findOne({ name: "Mars" })
db.planets.find({ hasRings: true, orderFromSun: { $lte: 6 } })
db.planets.find({
$and: [
{ hasRings: true }, { orderFromSun: { $lte: 6 } }
]
})
db.planets.find({
$or: [
{ hasRings: { $ne: false } }, { orderFromSun: { $gt: 6 } }
]
})
db.planets.find({
mainAtmosphere: { $in: ['O2'] }
})
// 속도 확인
for (i = 0; i < 300; i++) {
db.insertTest2.insertOne({ a: i })
}
var docs = [];
for (i = 0; i < 300; i++) {
docs.push({ a: i })
}
db.insertTest2.insertMany(docs);