-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual_queries.txt
80 lines (71 loc) · 1.94 KB
/
manual_queries.txt
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
Insert a New Record
--------------------
'''
> b = { "fields" :
... {
... "reporter": {
... "displayName": "Risto"
... },
... "summary": "New totally broken issue",
... "project": {
... "name": "Core Server"
... }
... }
... }
{
"fields" : {
"reporter" : {
"displayName" : "Risto"
},
"summary" : "New totally broken issue",
"project" : {
"name" : "Core Server"
}
}
}
> db.issues.insert(b);
WriteResult({ "nInserted" : 1 })
'''
Update a Record
---------------
'''
> db.issues.findOne({"fields.reporter.displayName": "Risto"})
{
"_id" : ObjectId("56ef5e301fc57209a9dec3d8"),
"fields" : {
"reporter" : {
"displayName" : "Risto"
},
"summary" : "New totally broken issue",
"project" : {
"name" : "Core Server"
}
}
}
> db.issues.findOne({"fields.reporter.displayName": "risto"})
null
> db.issues.update({"fields.reporter.displayName": "Risto"}, {"fields": {
"reporter": { "displayName": "risto"}}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.issues.findOne({"fields.reporter.displayName": "risto"})
{
"_id" : ObjectId("56ef5e301fc57209a9dec3d8"),
"fields" : {
"reporter" : {
"displayName" : "risto"
}
}
}
'''
^ this is not what was suppose to happen!
Here we go again:
'''
> db.issues.update({"fields.reporter.displayName": "Risto"}, { $set: {"fields.reporter.displayName": "risto"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.issues.find({"fields.reporter.displayName": "Risto"})
> db.issues.find({"fields.reporter.displayName": "risto"})
{ "_id" : ObjectId("56ef61d41fc57209a9dec3d9"), "fields" : { "reporter" : {
"displayName" : "risto" }, "summary" : "New totally broken issue",
"project" : { "name" : "Core Server" } } }
'''
^ this is more like it!