Document.prototype.set()
Parameters
path «String|Object» path or object of key/vals to set
val «Any» the value to set
[type] «Schema|String|Number|Buffer|*» optionally specify a type for “on-the-fly” attributes
[options] «Object» optionally specify options that modify the behavior of the set
Sets the value of a path, or many paths.
Example:
// path, value
doc.set(path, value)
// object
doc.set({
path : value
, path2 : {
path : value
}
})
// on-the-fly cast to number
doc.set(path, value, Number)
// on-the-fly cast to string
doc.set(path, value, String)
// changing strict mode behavior
doc.set(path, value, { strict: false });
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .