lib/predefine.js
function pluck(data) {
    //
    // Either map as array or return object through single map.
    //
    if (Array.isArray(data)) return data.map(map);
    return map(data);

    /**
     * Recursive mapping function.
     *
     * @param {Object} d Collection, Model or plain object.
     * @returns {Object} plucked object
     * @api private
     */
    function map(d) {
      if (isModel(d)) return pluck(d.attributes);

      for (var key in d) {
        if (isCollection(d[key])) {
          d[key] = pluck(d[key].models);
        }

        if (isModel(d[key])) {
          //
          // Delete MongoDB ObjectIDs. The stored state of the model is ambigious
          // as the referenced model could have different values in its own
          // collection. Hence doing recursive storage should be limited as much
          // as possible, since duplicate data will be stored.
          //
          d[key] = pluck(d[key].attributes);
          delete d[key]._id;
        }
      }

      return d;
    }
  }
function pluck(data) {
    //
    // Either map as array or return object through single map.
    //
    if (Array.isArray(data)) return data.map(map);
    return map(data);

    /**
     * Recursive mapping function.
     *
     * @param {Object} d Collection, Model or plain object.
     * @returns {Object} plucked object
     * @api private
     */
    function map(d) {
      if (isModel(d)) return pluck(d.attributes);

      for (var key in d) {
        if (isCollection(d[key])) {
          d[key] = pluck(d[key].models);
        }

        if (isModel(d[key])) {
          //
          // Delete MongoDB ObjectIDs. The stored state of the model is ambigious
          // as the referenced model could have different values in its own
          // collection. Hence doing recursive storage should be limited as much
          // as possible, since duplicate data will be stored.
          //
          d[key] = pluck(d[key].attributes);
          delete d[key]._id;
        }
      }

      return d;
    }
  }
function pluck ( data ) { // // Either map as array or return object through single map. // if ( Array . isArray ( data ) ) return data . map ( map ) ; return map ( data ) ; /**
     * Recursive mapping function.
     *
     * @param {Object} d Collection, Model or plain object.
     * @returns {Object} plucked object
     * @api private
     */ function map ( d ) { if ( isModel ( d ) ) return pluck ( d . attributes ) ; for ( var key in d ) { if ( isCollection ( d [ key ] ) ) { d [ key ] = pluck ( d [ key ] . models ) ; } if ( isModel ( d [ key ] ) ) { // // Delete MongoDB ObjectIDs. The stored state of the model is ambigious // as the referenced model could have different values in its own // collection. Hence doing recursive storage should be limited as much // as possible, since duplicate data will be stored. // d [ key ] = pluck ( d [ key ] . attributes ) ; delete d [ key ] . _id ; } } return d ; } }
Recursively pluck attributes from either a Model or Collection.

@param {Array|Object} data Array of Models or single Model
@returns {Mixed} Object or Array of objects
@api private
Recursively pluck attributes from either a Model or Collection .