teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

```

2018/03/25 08:34

投稿

HayatoKamono
HayatoKamono

スコア2415

answer CHANGED
@@ -1,3 +1,71 @@
1
1
  ```
2
+ db.teratail.find();
3
+ ```
4
+ ```
5
+ /* 1 */
6
+ {
7
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0a"),
8
+ "name" : "AAA",
9
+ "contents" : [
10
+ {
11
+ "contentsId" : "111",
12
+ "contentsName" : "aaa"
13
+ },
14
+ {
15
+ "contentsId" : "222",
16
+ "contentsName" : "bbb"
17
+ }
18
+ ]
19
+ }
20
+
21
+ /* 2 */
22
+ {
23
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0b"),
24
+ "name" : "BBB",
25
+ "contents" : [
26
+ {
27
+ "contentsId" : "333",
28
+ "contentsName" : "ccc"
29
+ },
30
+ {
31
+ "contentsId" : "444",
32
+ "contentsName" : "ddd"
33
+ }
34
+ ]
35
+ }
36
+ ```
37
+ ```
2
38
  db.teratail.update({}, { $pull: { contents: { contentsName: 'bbb' } } })
39
+
40
+ db.teratail.find();
41
+ ```
42
+
43
+ ```
44
+ /* 1 */
45
+ {
46
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0a"),
47
+ "name" : "AAA",
48
+ "contents" : [
49
+ {
50
+ "contentsId" : "111",
51
+ "contentsName" : "aaa"
52
+ }
53
+ ]
54
+ }
55
+
56
+ /* 2 */
57
+ {
58
+ "_id" : ObjectId("5ab75ebd2fbe474420a8fa0b"),
59
+ "name" : "BBB",
60
+ "contents" : [
61
+ {
62
+ "contentsId" : "333",
63
+ "contentsName" : "ccc"
64
+ },
65
+ {
66
+ "contentsId" : "444",
67
+ "contentsName" : "ddd"
68
+ }
69
+ ]
70
+ }
3
71
  ```