userCache
userCache copied to clipboard
The one simple trick that can save you millions of database requests
Hey, @msavin. Thank you for the fine package! I updated the meteor to 1.8.1 and received this error. ``` Exception while invoking method 'MY_SERVER_METHOD_WHICH_USES_METEOR_USER' TypeError: Cannot read property 'collectionViews' of...
The return value of `_getField()` is usually defined by: ``` if (!doc[field[i]]) { return; // === undefined } ``` and then the existance of the field is determined by: ```...
If quickly doing a `findOne(field)` after an `update()` then stale data is received. Contrived example: ```js const name = Meteor.user('profile').profile.name; console.log('before', name); // -> "bob" Meteor.users.update(Meteor.userId(), {$set: {"profile.name": name+name.length}}); console.log('after...
If `Meteor.user([fields])` doesn't hit the cache then the result is `_original()` which is reactive. However, if it hits the cache then the result is static (not reactive). This is fine...
Here's my PR to fix the minor issues I found since I started using this excellent package! I've tested this in production with Meteor 1.8.
I've had instances where the returned user doc doesn't include the `_id` field. This can cause a bug in code like this: ```js // toggle the 'flag' of user given...
Today I had an error `TypeError: Cannot read property 'documents' of undefined at _getCache...` from this code: ```js var collectionViews = isMeteor1_8 ? connectionData.collectionViews.get('users').documents.get(instance.userId) : connectionData.collectionViews.users.documents[instance.userId]; ``` Using Meteor 1.8...
the `_getField()` function misses the cache when the field required is an array, e.g: ```js // user = {emails: [{address: '[email protected]', verified: true}, {address: '[email protected]', verified: false}]} // this will...
When the required fields are not available in the cache, `userCache` simply calls `_original()` which causes the entire user object to be fetched from the db, even though `userCache` knows...
I do not see it anywhere in the code. You are assuming there is an observe happening? Isn't merge box populated only when you do observe and not just a...