src/utils/resolveFields.js
function fieldsFromMongo(projection = {}, includeIdDefault = false) {
  const fields = _.reduce(projection, (memo, value, key) => {
    if (key !== '_id' && value !== undefined && !value) {
      throw new TypeError('projection includes exclusion, but we do not support that');
    }
    if (value || (key === '_id' && value === undefined && includeIdDefault)) {
      memo.push(key);
    }

    return memo;
  }, []);

  return ProjectionFieldSet.fromDotted(fields);
}
function fieldsFromMongo(projection = {}, includeIdDefault = false) {
  const fields = _.reduce(projection, (memo, value, key) => {
    if (key !== '_id' && value !== undefined && !value) {
      throw new TypeError('projection includes exclusion, but we do not support that');
    }
    if (value || (key === '_id' && value === undefined && includeIdDefault)) {
      memo.push(key);
    }

    return memo;
  }, []);

  return ProjectionFieldSet.fromDotted(fields);
}
function fieldsFromMongo ( projection = { } , includeIdDefault = false ) { const fields = _ . reduce ( projection , ( memo , value , key ) => { if ( key !== '_id' && value !== undefined && ! value ) { throw new TypeError ( 'projection includes exclusion, but we do not support that' ) ; } if ( value || ( key === '_id' && value === undefined && includeIdDefault ) ) { memo . push ( key ) ; } return memo ; } , [ ] ) ; return ProjectionFieldSet . fromDotted ( fields ) ; }
Produce a ProjectionFieldSet from the given mongo projection, after validating it to ensure it
doesn't have exclusion rules.

@param {Object<String, *>} projection The projected fields.
@param {Boolean=} includeIdDefault Whether to include _id by default (mongo's default behavior).
@returns {ProjectionFieldSet} The synthesized field set.
Produce a ProjectionFieldSet from the given mongo projection after validating it to ensure it doesn t have exclusion rules .