回答編集履歴

1

```

2018/03/25 08:34

投稿

HayatoKamono
HayatoKamono

スコア2415

test CHANGED
@@ -1,5 +1,141 @@
1
+ ```
2
+
3
+ db.teratail.find();
4
+
5
+ ```
6
+
7
+ ```
8
+
9
+ /* 1 */
10
+
11
+ {
12
+
13
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0a"),
14
+
15
+ "name" : "AAA",
16
+
17
+ "contents" : [
18
+
19
+ {
20
+
21
+ "contentsId" : "111",
22
+
23
+ "contentsName" : "aaa"
24
+
25
+ },
26
+
27
+ {
28
+
29
+ "contentsId" : "222",
30
+
31
+ "contentsName" : "bbb"
32
+
33
+ }
34
+
35
+ ]
36
+
37
+ }
38
+
39
+
40
+
41
+ /* 2 */
42
+
43
+ {
44
+
45
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0b"),
46
+
47
+ "name" : "BBB",
48
+
49
+ "contents" : [
50
+
51
+ {
52
+
53
+ "contentsId" : "333",
54
+
55
+ "contentsName" : "ccc"
56
+
57
+ },
58
+
59
+ {
60
+
61
+ "contentsId" : "444",
62
+
63
+ "contentsName" : "ddd"
64
+
65
+ }
66
+
67
+ ]
68
+
69
+ }
70
+
71
+ ```
72
+
1
73
  ```
2
74
 
3
75
  db.teratail.update({}, { $pull: { contents: { contentsName: 'bbb' } } })
4
76
 
77
+
78
+
79
+ db.teratail.find();
80
+
5
81
  ```
82
+
83
+
84
+
85
+ ```
86
+
87
+ /* 1 */
88
+
89
+ {
90
+
91
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0a"),
92
+
93
+ "name" : "AAA",
94
+
95
+ "contents" : [
96
+
97
+ {
98
+
99
+ "contentsId" : "111",
100
+
101
+ "contentsName" : "aaa"
102
+
103
+ }
104
+
105
+ ]
106
+
107
+ }
108
+
109
+
110
+
111
+ /* 2 */
112
+
113
+ {
114
+
115
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0b"),
116
+
117
+ "name" : "BBB",
118
+
119
+ "contents" : [
120
+
121
+ {
122
+
123
+ "contentsId" : "333",
124
+
125
+ "contentsName" : "ccc"
126
+
127
+ },
128
+
129
+ {
130
+
131
+ "contentsId" : "444",
132
+
133
+ "contentsName" : "ddd"
134
+
135
+ }
136
+
137
+ ]
138
+
139
+ }
140
+
141
+ ```