-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseeds.js
More file actions
63 lines (59 loc) · 1.13 KB
/
seeds.js
File metadata and controls
63 lines (59 loc) · 1.13 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const mongoose = require('mongoose');
const { Product } = require('./models/product');
mongoose.connect('mongodb://127.0.0.1/codepolitanshop_db')
.then(() => {
console.log('connected to MongoDB');
})
.catch((err) => {
console.log(err.message);
});
// data sample pertama yang ingin dimasukkan
const seedProducts = [
{
name: 'Kemeja Flanel',
brand: 'Hollister',
price: 750000,
color: 'biru muda',
category: 'Baju',
},
{
name: 'Celana Chino',
brand: "Levi's",
price: 900000,
color: 'krem',
category: 'Celana',
},
{
name: 'Sweater',
brand: 'Gap',
price: 650000,
color: 'merah muda',
category: 'Baju',
},
{
name: 'Baju Renang',
brand: 'Speedo',
price: 500000,
color: 'biru tua',
category: 'Baju',
},
{
name: 'Rompi',
brand: 'Zara',
price: 850000,
color: 'abu-abu',
category: 'Baju',
},
{
name: 'Jas',
brand: 'Hugo Boss',
price: 4500000,
color: 'hitam',
category: 'Baju',
},
];
Product.insertMany(seedProducts).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
});