Created
October 15, 2017 09:12
-
-
Save esarafianou/d53db9908b13872ff6bd87b5a6508aa5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import { Sequelize } from 'sequelize' | |
| const sequelize = new Sequelize( | |
| 'postgres', | |
| 'postgres', | |
| 'postgres', | |
| { | |
| dialect: 'postgres', | |
| host: 'localhost' | |
| } | |
| ) | |
| const User = sequelize.define('user', {}) | |
| const Project = sequelize.define('project', {}) | |
| const UserProjects = sequelize.define('userProjects', { | |
| status: Sequelize.STRING | |
| }) | |
| User.belongsToMany(Project, { through: UserProjects }) | |
| Project.belongsToMany(User, { through: UserProjects }) | |
| sequelize.sync({ force: true }).then(() => { | |
| return User.create({ | |
| }) | |
| .then((user) => { | |
| return Project.create({ | |
| }) | |
| .then((project) => { | |
| return user.addProject(project, { through: { status: 'started' }}) | |
| }) | |
| }) | |
| }) | |
| export default sequelize |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
docker commands:
docker rm -f harmoniseit
docker run --name harmoniseit -e POSTGRES_PASSWORD=postgres -p 127.0.0.1:5432:5432 -d postgres