routes/crud.js
function addToFooter(schema, path, unwind) {
    Object.keys(schema).forEach(function(name) {
      if (name.slice(0,2) == '__')
        return true;
      if (!path && (name == 'id' || name == '_id'))
        return;
      if (model.schema.nested[path+name]) {
        addToFooter(schema[name], path+name+'.', '')
      } else if (schema[name] && schema[name].tree) {
        addToFooter(schema[name].tree, path+name+'.');
        if (typeof schema[name].options.strict === 'boolean' && !schema[name].options.strict) {
          footer.push({name:name, path: path+name+'.*'});
        }
      } else if (name === unwind) {
        addToFooter(schema[name][0].tree, path+name+'.0.')
        if (typeof schema[name][0].options.strict === 'boolean' && !schema[name][0].options.strict) {
          footer.push({name:name, path: path+name+'.0.*'});
        }
      } else {
        if (skipField(path+name)) {
          return;
        }
        footer.push({name:name, path: path+name})
      }
    });
  }
function addToFooter(schema, path, unwind) {
    Object.keys(schema).forEach(function(name) {
      if (name.slice(0,2) == '__')
        return true;
      if (!path && (name == 'id' || name == '_id'))
        return;
      if (model.schema.nested[path+name]) {
        addToFooter(schema[name], path+name+'.', '')
      } else if (schema[name] && schema[name].tree) {
        addToFooter(schema[name].tree, path+name+'.');
        if (typeof schema[name].options.strict === 'boolean' && !schema[name].options.strict) {
          footer.push({name:name, path: path+name+'.*'});
        }
      } else if (name === unwind) {
        addToFooter(schema[name][0].tree, path+name+'.0.')
        if (typeof schema[name][0].options.strict === 'boolean' && !schema[name][0].options.strict) {
          footer.push({name:name, path: path+name+'.0.*'});
        }
      } else {
        if (skipField(path+name)) {
          return;
        }
        footer.push({name:name, path: path+name})
      }
    });
  }
function addToFooter ( schema , path , unwind ) { Object . keys ( schema ) . forEach ( function ( name ) { if ( name . slice ( 0 , 2 ) == '__' ) return true ; if ( ! path && ( name == 'id' || name == '_id' ) ) return ; if ( model . schema . nested [ path + name ] ) { addToFooter ( schema [ name ] , path + name + '.' , '' ) } else if ( schema [ name ] && schema [ name ] . tree ) { addToFooter ( schema [ name ] . tree , path + name + '.' ) ; if ( typeof schema [ name ] . options . strict === 'boolean' && ! schema [ name ] . options . strict ) { footer . push ( { name : name , path : path + name + '.*' } ) ; } } else if ( name === unwind ) { addToFooter ( schema [ name ] [ 0 ] . tree , path + name + '.0.' ) if ( typeof schema [ name ] [ 0 ] . options . strict === 'boolean' && ! schema [ name ] [ 0 ] . options . strict ) { footer . push ( { name : name , path : path + name + '.0.*' } ) ; } } else { if ( skipField ( path + name ) ) { return ; } footer . push ( { name : name , path : path + name } ) } } ) ; }
only include leaves
only include leaves