mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Basic handling for fields in oplog
Just run through projection before calling callbacks or keeping fields in published IdMap, or diffing.
This commit is contained in:
@@ -1562,11 +1562,6 @@ var cursorSupportedByOplogTailing = function (cursorDescription) {
|
||||
// First, check the options.
|
||||
var options = cursorDescription.options;
|
||||
|
||||
// We don't yet implement field filtering for oplog tailing (just because it's
|
||||
// not implemented, not because there's a deep problem with implementing it).
|
||||
// XXX Implementing field filtering should be a priority.
|
||||
if (options.fields) return false;
|
||||
|
||||
// This option (which are mostly used for sorted cursors) require us to figure
|
||||
// out where a given document fits in an order to know if it's included or
|
||||
// not, and we don't track that information when doing oplog tailing.
|
||||
|
||||
@@ -31,13 +31,16 @@ MongoConnection.prototype._observeChangesWithOplog = function (
|
||||
|
||||
var published = new IdMap;
|
||||
var selector = LocalCollection._compileSelector(cursorDescription.selector);
|
||||
var projection = cursorDescription.options.fields ?
|
||||
LocalCollection._compileProjection(cursorDescription.options.fields) :
|
||||
EJSON.clone;
|
||||
|
||||
var needToFetch = new IdMap;
|
||||
var currentlyFetching = new IdMap;
|
||||
|
||||
var add = function (doc) {
|
||||
var id = doc._id;
|
||||
var fields = EJSON.clone(doc);
|
||||
var fields = projection(doc);
|
||||
delete fields._id;
|
||||
if (published.has(id))
|
||||
throw Error("tried to add something already published " + id);
|
||||
@@ -52,8 +55,10 @@ MongoConnection.prototype._observeChangesWithOplog = function (
|
||||
callbacks.removed && callbacks.removed(id);
|
||||
};
|
||||
|
||||
// XXX mutates newDoc, that's weird
|
||||
// XXX it doesn't mutate newDoc anymore since we apply projection function but
|
||||
// be careful refactoring and moving out projection.
|
||||
var handleDoc = function (id, newDoc) {
|
||||
newDoc = projection(newDoc);
|
||||
var matchesNow = newDoc && selector(newDoc);
|
||||
var matchedBefore = published.has(id);
|
||||
if (matchesNow && !matchedBefore) {
|
||||
|
||||
Reference in New Issue
Block a user