Skip to content

Commit f58ed87

Browse files
committed
Add : insert document
1 parent d2858a8 commit f58ed87

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

scripts/insert.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Insert document customers
2+
db.customers.insertOne({
3+
_id: "khannedy",
4+
name: "Eko Kurniawan Khannedy"
5+
});
6+
7+
// Insert document products
8+
db.products.insertMany([
9+
{
10+
_id: 1,
11+
name: "Indomie Ayam Bawang",
12+
price: new NumberLong(2000)
13+
},
14+
{
15+
_id: 2,
16+
name: "Mie Sedap",
17+
price: new NumberLong(2000)
18+
}
19+
]);
20+
21+
// Insert document orders
22+
db.orders.insertOne({
23+
_id: new ObjectId(),
24+
total: new NumberLong(8000),
25+
items: [
26+
{
27+
product_id: 1,
28+
price: new NumberLong(2000),
29+
quantity: new NumberInt(2)
30+
},
31+
{
32+
product_id: 2,
33+
price: new NumberLong(2000),
34+
quantity: new NumberInt(2)
35+
}
36+
]
37+
})

0 commit comments

Comments
 (0)