-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseedData.js
41 lines (38 loc) · 1.11 KB
/
seedData.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
40
41
const Item = require('./models/Item');
const User = require('./models/User');
const Reaction = require('./reactions-config').model;
module.exports = () => {
let items = [
{name: "item 1"},
{name: "item 2"},
{name: "item 3"}
];
let users = [
{name: "John Doe 1"},
{name: "John Doe 2"},
{name: "John Doe 3"}
];
Promise.all([
Item.deleteMany({}).exec().then(() => {
console.log("items cleared");
}),
User.deleteMany({}).exec().then(() => {
console.log("users cleared");
}),
Reaction.deleteMany({}).exec().then(() => {
console.log("reactions cleared");
})
])
.then(data => {
console.log("Database cleared.");
Promise.all([
Item.collection.insertMany(items),
User.collection.insertMany(users),
])
.then(data => {
console.log("Data seeding complete.");
})
.catch(e => console.log(e));
})
.catch(e => console.log(e));
};