You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use local collections as a cache around an ordered query (the idea is that while query is read only, cache is not). But I would like that native order of the local collections matches that of ordered query.
It seems there is no way to move documents in the local collection. Any internal functions which might do the trick would be great. The important part is that somebody using observeChanges and addedBefore/movedBefore on the local collection should get notified as documents move around as well.
documents.find({},{sort: <sort>, limit: <limit>}).observeChanges({addedBefore: function(id,fields,before){if(before===null){localCollection.insert(_.extend({_id: id},fields}));}else{// What to do here?}},changed: function(id,fields){varmodifier={$set: {},$unset: {}};varkey,value;for(keyinfields){value=fields[key];if(_.isUndefined(value)){modifier.$unset[key]='';}else{modifier.$set[key]=value;}}localCollection.update(id,modifier);},movedBefore: function(id,before){// What to do here?}removed: function(id){localCollection.remove(id);}})
This would allow one to create a query against a read-only database, but allow local modifications (like reordering of the data which is displayed to the user, of adding flags, like "read" or "seen"). It is useful to have this so that one can then render things directly.
The text was updated successfully, but these errors were encountered:
Sent also to the meteor-core.
I am trying to use local collections as a cache around an ordered query (the idea is that while query is read only, cache is not). But I would like that native order of the local collections matches that of ordered query.
It seems there is no way to move documents in the local collection. Any internal functions which might do the trick would be great. The important part is that somebody using
observeChanges
andaddedBefore
/movedBefore
on the local collection should get notified as documents move around as well.This would allow one to create a query against a read-only database, but allow local modifications (like reordering of the data which is displayed to the user, of adding flags, like "read" or "seen"). It is useful to have this so that one can then render things directly.
The text was updated successfully, but these errors were encountered: