-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsequelize.js
37 lines (32 loc) · 996 Bytes
/
sequelize.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
const Sequelize = require("sequelize");
const EntityModel = require("./models/albion/entity");
const StaticModel = require("./models/albion/static");
const ServerTrackModel = require("./models/albion/servertrack");
const ServerModel = require("./models/server");
const sequelize = new Sequelize("database", "user", "password", {
host: "localhost",
dialect: "sqlite",
logging: false,
// SQLite only
storage: "database.sqlite",
});
const Entity = EntityModel(sequelize, Sequelize);
const Server = ServerModel(sequelize, Sequelize);
const ServerTrack = ServerTrackModel(sequelize, Sequelize);
const Static = StaticModel(sequelize, Sequelize);
Entity.hasMany(ServerTrack);
ServerTrack.belongsTo(Entity);
sequelize.sync({force: false})
.then(() => {
console.log("Database & tables created!");
});
module.exports = {
Database: {
Server,
Albion: {
Entity,
ServerTrack,
Static
}
}
};