-
Notifications
You must be signed in to change notification settings - Fork 4
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
How do we specify denormalization? #12
Comments
I tried the following, but it didn't work:
|
The if (args.to) {
config = Object.assign({}, args);
config.inversedBy = args.to;
delete config.to;
} thisCollection.addLinks({
[field.name]: {
collection: referencedCollection,
...config,
},
}); If I use direct addLinks API, it works: Colors.addLinks({
"messages": {
collection: ColorMessages,
inversedBy: "color",
autoremove: true,
denormalize: {
field: "messagesCache",
body: {
senderId: 1,
date: 1,
recipientIds: 1
}
}
}
}); |
Well, this explains it :-) directiveDefinitions.js:
Any chances of adding support for denormalize? |
Aargh! I just saw this at the bottom of the README: This is a very quick way to setup your schema, however if you need to use denormalisation abilities, and you don't want to give up the sugary directives above: import { db } from 'meteor/cultofcoders:grapher';
Meteor.startup(() => {
const userCommentLinker = db.users.getLinker('comments');
Object.assign(userCommentLinker.linkConfig, {
denormalize: {},
});
userCommentLinker._initDenormalization();
}); Duh, I will try this... |
Hmm, when I try this: Meteor.startup(() => {
// initialize Apollo server
initialize({}, {
gui: Meteor.isDevelopment
});
// set up denormalization stuff
const colorMessagesLinker = db.colors.getLinker("messages");
Object.assign(colorMessagesLinker.linkConfig, {
denormalize: {
field: "messagesCache",
body: {
senderId: 1,
date: 1,
recipientIds: 1
}
}
});
colorMessagesLinker._initDenormalization();
}); I get this startup error:
|
OK, this worked: Meteor.startup(() => {
// initialize Apollo server
initialize({}, {
gui: Meteor.isDevelopment
});
// set up denormalization stuff
const colorMessagesLinker = db.colorMessages.getLinker("color");
const colorsInverseLinker = db.colors.getLinker("messages");
colorsInverseLinker._setupVirtualConfig(colorMessagesLinker);
Object.assign(colorsInverseLinker.linkConfig, {
denormalize: {
field: "messagesCache",
body: {
senderId: 1,
date: 1,
recipientIds: 1
}
}
});
colorsInverseLinker._initDenormalization();
}); Had to read through colorsInverseLinker._setupVirtualConfig(colorMessagesLinker); |
Hi,
How do we specify denormalization structure with this package?
Thanks
The text was updated successfully, but these errors were encountered: