forked from Automattic/mongoose
/
seed.js
39 lines (31 loc) · 903 Bytes
/
seed.js
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
'use strict';
const { Product } = require('./models');
const config = require('./.config');
const mongoose = require('mongoose');
async function createProducts() {
await mongoose.connect(config.mongodbUri);
await mongoose.connection.dropDatabase();
await Product.create({
name: 'iPhone 12',
price: 500,
image: 'https://images.unsplash.com/photo-1611472173362-3f53dbd65d80'
});
await Product.create({
name: 'iPhone SE',
price: 600,
image: 'https://images.unsplash.com/photo-1529618160092-2f8ccc8e087b'
});
await Product.create({
name: 'iPhone 12 Pro',
price: 700,
image: 'https://images.unsplash.com/photo-1603921326210-6edd2d60ca68'
});
await Product.create({
name: 'iPhone 11',
price: 800,
image: 'https://images.unsplash.com/photo-1574755393849-623942496936'
});
console.log('done');
process.exit(0);
}
createProducts();