forked from irene-hakes/plantr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.js
32 lines (29 loc) · 886 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
const {db} = require('./models')
const {Gardener} = require('./models')
const {Plot} = require('./models')
const {Vegetable} = require('./models')
db.sync({force: true})
.then(() => {
console.log('Database synced!');
return Promise.all([Vegetable.create({name: 'carrot', color: 'orange', planted_on: new Date()}), Vegetable.create({name: 'broccoli', color: 'green', planted_on: new Date()})])
})
.then(()=> {
return Gardener.create({favoriteVegetableId: Vegetable.id})
})
.then(()=> {
return Plot.create({gardenerId: Gardener.id })
})
.catch(err => {
console.log('Disaster! Something went wrong! ');
console.log(err)
})
.finally(() => {
db.close();
})
// Vegetable.create({name: 'carrot', color: 'orange', planted_on: new Date()})
// .then(() => {
// db.sync();
// });
// Vegetable.create()
// .then((vegetable) => {
// })