-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8curd.txt
47 lines (30 loc) · 924 Bytes
/
8curd.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
use myblogdb;
db.createCollection("articles");
db.articles.insertOne({
title: "Introduction to MongoDB",
content: "MongoDB is a NoSQL database...",
author: "John Doe",
author_age: 30,
category: "Database",
comments: [
{ name: "Alice", remarks: "Great article!" },
{ name: "Bob", remarks: "I learned a lot." }
]
});
db.articles.insertOne({
title: "Getting Started with Node.js",
content: "Node.js is a JavaScript runtime...",
author: "Jane Smith",
author_age: 25,
category: "Web Development",
comments: [
{ name: "Charlie", remarks: "Very informative." }
]
});
db.articles.find();
db.articles.find({ category: "Database" });
db.articles.updateOne(
{ title: "Introduction to MongoDB" },
{ $set: { content: "MongoDB is a powerful NoSQL database..." } }
);
db.articles.deleteOne({ title: "Getting Started with Node.js" });