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 denormalization does not work as expected #369

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

Many-to-One unique denormalization does not work as expected #369

Floriferous opened this issue Jul 25, 2019 · 0 comments

Comments

@Floriferous
Copy link
Contributor

Floriferous commented Jul 25, 2019

When you link 2 collections together in a many-to-one/unique way, it is not possible to get denormalization to work properly. This is because of Meteor-Community-Packages/denormalize#17, so for now, nothing can be done to fix this.

const A = new Meteor.Collection('a');
const B = new Meteor.Collection('b');

A.addLinks({
  b: {
    field: 'bLinks',
    type: 'many',
    collection: B,
    unique: true,
  },
});

B.addLinks({
  a: {
    inversedBy: 'b',
    collection: A,
    denormalize: {
      field: 'aCache',
      body: { _id: 1 },
    },
  },
});

const bId = B.insert({});
A.insert({ bLinks: [{ _id: bId }] });

B.findOne({ _id: bId })
// Returns { aCache: [{ _id: 'xxx' }] }
// Expected { aCache: { _id: 'xxx' } }
@Floriferous Floriferous changed the title Many-to-One denormalization is always of type many-inverse Many-to-One unique denormalization does not work as expected Jul 25, 2019
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