Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to define unique constraint for multiple columns on Associations? #816

Open
reumia opened this issue Oct 17, 2017 · 0 comments
Open

Comments

@reumia
Copy link

reumia commented Oct 17, 2017

I already know the way to defining when define models like this.

db.define('likes_user', {
  userId: {type: 'integer', unique: 'userId_targetId'},
  targetId: {type: 'integer', unique: 'userId_targetId'}
})

but i define those keys automatically when make associations.
so i want to know is there any ways for defining unique keys when make associations :(

here is my codes for associations. need helps!

LikesUser.hasOne('target', Users, {reverse: 'likes', field: 'targetId', mapsTo: 'target_id', required: true})
LikesUser.hasOne('user', Users, {reverse: 'likeUsers', field: 'userId', mapsTo: 'user_id', required: true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant