Last active
October 24, 2020 18:30
-
-
Save RyanKor/c63208647100f03e93f77e8829558d92 to your computer and use it in GitHub Desktop.
Hash setting - models/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Sequelize = require("sequelize"); | |
const env = process.env.NODE_ENV || "development"; | |
const config = require("../config/config.json")[env]; | |
const db = {}; | |
const sequelize = new Sequelize( | |
config.database, | |
config.username, | |
config.password, | |
config | |
); | |
db.sequelize = sequelize; | |
db.Sequelize = Sequelize; | |
db.Post = require("./post")(sequelize, Sequelize); | |
db.Hashtag = require("./hashtag")(sequelize, Sequelize); | |
db.Post.belongsToMany(db.Hashtag, { through: "PostHashTag" }); | |
db.Hashtag.belongsToMany(db.Post, { through: "PostHashTag" }); | |
module.exports = db; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment