Deep Cache
See original GitHub issueUse https://github.com/Herteby/denormalize Depend on this package with {weak: true} Check for package existence when specifying cache, and give instructions on how to install it.
API
Invoice.addLinks({
user: {
collection: Users,
cache: {
field: 'userCache',
body: { firstName: 1, lastName: 1 }
}
}
});
When query-ing for invoices, if a link is cached, fetch from cache IF and only IF ALL the specified fields exist in cache.
{ invoices: { user: { firstname: 1, lastname: 1} }
This will actually fetch ‘userCache.firstname’, ‘userCache.lastname’
However, if there is an extra field, then caching is bypassed.
If user contains a nested field like: profile: { firstname, lastname }
We need to be careful when we have:
Invoice.addLinks({
user: {
collection: Users,
cache: {
field: 'userCache',
body: {
profile: { firstName: 1, lastName: 1},
lastLogin: 1
}
}
}
});
If we query:
invoices: { user: { profile: { firstName: 1 }, lastLogin: 1 } }
It will still only hit the cache.
The logic is that the requested body needs to be a sub-body from profile.
Same logic applies for reactive queries as well, transforming the CollectionNode
into a Cache node.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top GitHub Comments
You could use my bypassSchema option, which doesn’t depend on SimpleSchema, but maybe that could lead to problems elsewhere…
Aah now I understand what you meant by disabling denormalization - just if you have $filters on a link. Yeah that’s fine, I thought you meant on the root query, that puzzled me a bit 😛
@Herteby bypassSchema option is allowed in the cache: {}, now named denormalize: {} configuration.