Created
December 15, 2013 16:45
-
-
Save mickhansen/7975176 to your computer and use it in GitHub Desktop.
Test-case for @dstanoev
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
var Sequelize = require('sequelize'), | |
sequelize = new Sequelize(); | |
var User = sequelize.define('User', {}), | |
Post = sequelize.define('Post', {}); | |
Post.belongsTo(User, {as: 'Creator', foreignKey: 'creator_id', foreignKeyConstraint: true}); | |
User.hasMany(Post, {foreignKey: 'creator_id'}); | |
User.hasMany(Post, {as: 'SharedPosts', joinTableName: 'SharedPosts', foreignKey: 'user_id', foreignKeyConstraint: true}); | |
Post.hasMany(User, {as: 'SharedWithUsers', joinTableName: 'SharedPosts', foreignKey: 'post_id', foreignKeyConstraint: true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment