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

Does this work for associations? #1

Open
georgeedwards opened this issue Jan 17, 2017 · 1 comment
Open

Does this work for associations? #1

georgeedwards opened this issue Jan 17, 2017 · 1 comment

Comments

@georgeedwards
Copy link

Say your example was Users and Todos (seems to be a demo favourite!), where a user hasMany Todos and a Todo hasOne User. Presumably you can't know the id of the User before it is created, in which case associating a Todo with a user is tricky?

Does this package support this, in which case a note in the docs would be great, otherwise, is that possible/ in scope?

@jimthedev
Copy link
Owner

Hey I just saw this. For some reason I got swamped with notifications and missed it.

This project assumes that if you will manually provide the ids involved in relationships. We should probably make a note in the readme to indicate how you can do this, but essentially it comes down to providing either an array of ids on the 'many' side, or a single id on the 'one' side.

We don't force you to put ids on individual items being added to tables since generally they are auto generated. So, items in a table will be created in the order that they fall in the array that you provide. So if you have three users then the item 0 in the array would be auto assigned id 1 by your database. A user at index 1 in the provided array would have an id of 2, etc. So we can actually know the ids that will be created given the order of the item in an array. I think it probably reasonable to ask for an example of this so I'll put it in my personal backlog to add and will keep this open until it is complete.

Thanks!

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

2 participants