lib/manage/commands/find.js
function(doc, fields) {
	return Object.keys(fields).reduce((prev, key) => {
		let val

		if (fields[key].hasOwnProperty('referenceCollection')) {
			const displayField = fields[key].referenceCollection.defaultField

			if (Array.isArray(doc[key])) {
				val = doc[key].map(data => {
					return data[displayField]
				})
			} else {
				val = doc[key][displayField]
			}
		} else {
			val = doc[key]
		}
		return Object.assign({}, prev, {
			[key]: val
		})
	}, { _id: doc._id })
}
function(doc, fields) {
	return Object.keys(fields).reduce((prev, key) => {
		let val

		if (fields[key].hasOwnProperty('referenceCollection')) {
			const displayField = fields[key].referenceCollection.defaultField

			if (Array.isArray(doc[key])) {
				val = doc[key].map(data => {
					return data[displayField]
				})
			} else {
				val = doc[key][displayField]
			}
		} else {
			val = doc[key]
		}
		return Object.assign({}, prev, {
			[key]: val
		})
	}, { _id: doc._id })
}
function ( doc , fields ) { return Object . keys ( fields ) . reduce ( ( prev , key ) => { let val if ( fields [ key ] . hasOwnProperty ( 'referenceCollection' ) ) { const displayField = fields [ key ] . referenceCollection . defaultField if ( Array . isArray ( doc [ key ] ) ) { val = doc [ key ] . map ( data => { return data [ displayField ] } ) } else { val = doc [ key ] [ displayField ] } } else { val = doc [ key ] } return Object . assign ( { } , prev , { [ key ] : val } ) } , { _id : doc . _id } ) }
Replace populated fields with only the default field value
@param  {Object} doc
@param  {Object} fields
@return {Object}
Replace populated fields with only the default field value