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-One unique relationship #17

Open
Floriferous opened this issue Jul 25, 2019 · 3 comments
Open

Many-to-One unique relationship #17

Floriferous opened this issue Jul 25, 2019 · 3 comments

Comments

@Floriferous
Copy link
Contributor

I'm trying to get a cache working where the relationship is "many-to-one unique", but I think this package doesn't handle it. Here's an example:

I have a collection of Authors, and a collection of Comments. The authors store an array of commentIds, and I want each comment to denormalize the author, without it being an array.

Authors // { commentIds: ['commentId1', 'commentId2'] }

// What I want
Comments: // { authorCache: { _id: 'authorId', name: 'John' } }

// What I get
Comments: // { authorCache: [{ _id: 'authorId', name: 'John' }] }

Usually many-to-one means there can be many authors linking to the same comment, but that's not the case here, so the cache is not correct.

@doronrk
Copy link

doronrk commented Oct 4, 2019

Yeah I agree that it would be nice to be able to express "unique" here. I'm running into this as well using grapher with denormalize.

@doronrk
Copy link

doronrk commented Oct 4, 2019

@Herteby is this something you would accept a PR for?

@Herteby
Copy link
Collaborator

Herteby commented Feb 3, 2020

Not 100% if @-mentioning people in other threads means they get notified, so posting a link here too:
#21

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

3 participants