Query.prototype.set()
Parameters
path «String|Object» path or object of key/value pairs to set
[val] «Any» the value to set
Returns:
- «Query» this
Adds a $set
to this query’s update without changing the operation. This is useful for query middleware so you can add an update regardless of whether you use updateOne()
, updateMany()
, findOneAndUpdate()
, etc.
Example:
// Updates `{ $set: { updatedAt: new Date() } }`
new Query().updateOne({}, {}).set('updatedAt', new Date());
new Query().updateMany({}, {}).set({ updatedAt: new Date() });
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .