-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.js
More file actions
27 lines (25 loc) · 710 Bytes
/
seed.js
File metadata and controls
27 lines (25 loc) · 710 Bytes
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
const { green, red } = require("chalk");
const { db } = require("./db");
const seed = async () => {
try {
await db.sync({ force: true });
} catch (err) {
console.log(red(err));
}
};
module.exports = seed;
// If this module is being required from another module, then we just export the
// function, to be used as necessary. But it will run right away if the module
// is executed directly (e.g. `node seed.js` or `npm run seed`)
if (require.main === module) {
seed()
.then(() => {
console.log(green("Seeding success!"));
db.close();
})
.catch((err) => {
console.error(red("Oh noes! Something went wrong!"));
console.error(err);
db.close();
});
}