Query.prototype.projection()
Parameters
- arg «Object|null»
Returns:
- «Object» the current projection
Get/set the current projection (AKA fields). Pass null
to remove the current projection.
Unlike projection()
, the select()
function modifies the current projection in place. This function overwrites the existing projection.
Example:
const q = Model.find();
q.projection(); // null
q.select('a b');
q.projection(); // { a: 1, b: 1 }
q.projection({ c: 1 });
q.projection(); // { c: 1 }
q.projection(null);
q.projection(); // null
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .