Skip to content

Instantly share code, notes, and snippets.

@RyanKor
Last active October 24, 2020 18:30
Show Gist options
  • Save RyanKor/c63208647100f03e93f77e8829558d92 to your computer and use it in GitHub Desktop.
Save RyanKor/c63208647100f03e93f77e8829558d92 to your computer and use it in GitHub Desktop.
Hash setting - models/index.js
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