Skip to content

Commit 35ebdc2

Browse files
committed
Add python solution to INSERT DELETE challenge
1 parent 575cd7c commit 35ebdc2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/40-CRUD/4-INSERT-DELETE.mdx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,39 @@ DELETE FROM reviews WHERE bookId = '0786222727';
136136
```
137137
</div>
138138
</TabItem>
139+
<TabItem value="python" label="Python">
140+
<div>
141+
```python
142+
reviews = db.collection("reviews")
143+
reviews.insert_many([
144+
{
145+
"text": "Thrilling end.",
146+
"rating": 4,
147+
"name": "Mark",
148+
"bookId": "0786222727",
149+
},
150+
{
151+
"text": "Must read!",
152+
"rating": 5,
153+
"name": "Raj",
154+
"bookId": "0786222727",
155+
},
156+
{
157+
"text": "Very expensive",
158+
"rating": 3,
159+
"name": "Yun",
160+
"bookId": "0786222727",
161+
},
162+
{
163+
"text": "Extremely satisfied with the storyline!",
164+
"rating": 5,
165+
"name": "Lisa",
166+
"bookId": "0786222727",
167+
}
168+
])
169+
```
170+
</div>
171+
</TabItem>
139172
</Tabs>
140173
</details>
141174

@@ -159,5 +192,13 @@ DELETE FROM reviews WHERE bookId = '0786222727';
159192
```
160193
</div>
161194
</TabItem>
195+
<TabItem value="python" label="Python">
196+
<div>
197+
```python
198+
reviews = db.collection("reviews")
199+
reviews.delete_many({"bookId": "0786222727"})
200+
```
201+
</div>
202+
</TabItem>
162203
</Tabs>
163204
</details>

0 commit comments

Comments
 (0)