Meteor-Community-Packages / Meteor-Community-Packages/denormalize
Many-to-One unique relationship
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
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 `commentId`s, and I want each comment to denormalize the author, without it being an array.
```js
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name a file or test entry point. Start by locating the relationship denormalization and cache-handling logic, then reproduce the Authors/Comments example. Done means the unique many-to-one relationship stores one author object rather than an array, with coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100