meteor/minimongo/projection.js
function (doc, ruleTree) {
    // Special case for "sets"
    if (_.isArray(doc))
      return _.map(doc, function (subdoc) { return transform(subdoc, ruleTree); });

    var res = details.including ? {} : EJSON.clone(doc);
    _.each(ruleTree, function (rule, key) {
      if (!_.has(doc, key))
        return;
      if (_.isObject(rule)) {
        // For sub-objects/subsets we branch
        if (_.isObject(doc[key]))
          res[key] = transform(doc[key], rule);
        // Otherwise we don't even touch this subfield
      } else if (details.including)
        res[key] = EJSON.clone(doc[key]);
      else
        delete res[key];
    });

    return res;
  }
function (doc, ruleTree) {
    // Special case for "sets"
    if (_.isArray(doc))
      return _.map(doc, function (subdoc) { return transform(subdoc, ruleTree); });

    var res = details.including ? {} : EJSON.clone(doc);
    _.each(ruleTree, function (rule, key) {
      if (!_.has(doc, key))
        return;
      if (_.isObject(rule)) {
        // For sub-objects/subsets we branch
        if (_.isObject(doc[key]))
          res[key] = transform(doc[key], rule);
        // Otherwise we don't even touch this subfield
      } else if (details.including)
        res[key] = EJSON.clone(doc[key]);
      else
        delete res[key];
    });

    return res;
  }
function ( doc , ruleTree ) { // Special case for "sets" if ( _ . isArray ( doc ) ) return _ . map ( doc , function ( subdoc ) { return transform ( subdoc , ruleTree ) ; } ) ; var res = details . including ? { } : EJSON . clone ( doc ) ; _ . each ( ruleTree , function ( rule , key ) { if ( ! _ . has ( doc , key ) ) return ; if ( _ . isObject ( rule ) ) { // For sub-objects/subsets we branch if ( _ . isObject ( doc [ key ] ) ) res [ key ] = transform ( doc [ key ] , rule ) ; // Otherwise we don't even touch this subfield } else if ( details . including ) res [ key ] = EJSON . clone ( doc [ key ] ) ; else delete res [ key ] ; } ) ; return res ; }
returns transformed doc according to ruleTree
returns transformed doc according to ruleTree