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

Many to Many Relationships - Are They Supported? #15

Closed
bsill opened this issue Oct 6, 2015 · 1 comment
Closed

Many to Many Relationships - Are They Supported? #15

bsill opened this issue Oct 6, 2015 · 1 comment
Labels

Comments

@bsill
Copy link

bsill commented Oct 6, 2015

I am having trouble saving models which have a many-to-many relationship. Is this supported? I have a many-to-many relationship between users and roles. I have created the join table that sails requires, 'role_users__user_roles' in dynamodb. When I run my migration script to seed the database with an admin user and his corresponding roles, I get the following error:

Waterline Error:  { originalError: 
{ [Error: the value of id is not allowed to be undefined]
 details: [ [Object] ],
 _object: 
  { role_users: '9c7d4258-fdd1-4cd4-a0b7-073a14c70529',
    user_roles: 'f098d269-7815-4c92-bea4-ed3cca63c4f9' },
 message: 'the value of id is not allowed to be undefined' } }

It appears that the dynamodb adapter is not auto-generating the required id field value. I was able to get around this for basic models by generating the uuids in sails based upon the suggestion in another issue thread, however am unsure how to do this for join table entries.

@devinivy
Copy link
Collaborator

I think you'll need to use through associations for this. See https://github.com/balderdashy/waterline/issues/705#issuecomment-60945411

For general support of populations, refer to #16 for the feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants