forked from mahmoudsultan/expressjs-api-startup-files-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeds.js
55 lines (44 loc) · 1.61 KB
/
seeds.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const categoriesSeeder = require('./seeders/categories');
const sessionsSeeder = require('./seeders/sessions');
const speakersSeeder = require('./seeders/speakers');
var seed = function () {
const config = require('./config');
/* Database and models setup */
const connection = require('./models/main')('connection');
const User = require('./models/main')('user');
const Post = require('./models/main')('post');
const Hashtag = require('./models/main')('hashtag');
// force: true here is only in the development env change in config.js
connection.sync({
force: config.force
}).then(function () {
console.log('Database created succesfully...');
// For Testing
// User.create({
// alias: "test",
// password: "123456789",
// name: "test",
// email: "test@test.com"
// }).then(function (user) {
// console.log("User created successfully");
// Post.create({
// content: "initial topic",
// }).then(function (post) {
// Hashtag.create({
// title: "test",
// }).then((hashtag) => {
// hashtag.setPosts([post]);
// return user.setPosts([post]);
// });
// })
// }).catch(console.log);
// // seed categories
// categoriesSeeder();
// // seed sessions
// sessionsSeeder();
// // seed speakers
// speakersSeeder();
// // seed sponsors
}).catch(console.log);
};
module.exports = seed;