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:

  1. // path, value
  2. doc.set(path, value)
  3. // object
  4. doc.set({
  5. path : value
  6. , path2 : {
  7. path : value
  8. }
  9. })
  10. // on-the-fly cast to number
  11. doc.set(path, value, Number)
  12. // on-the-fly cast to string
  13. doc.set(path, value, String)
  14. // changing strict mode behavior
  15. doc.set(path, value, { strict: false });