Parameters
  • [options.safe] «Object» (DEPRECATED) overrides schema’s safe option. Use the option instead.

  • [options.validateBeforeSave] «Boolean» set to false to save without validating.

  • [options.w] «Number|String» set the . Overrides the schema-level writeConcern option

  • [options.j] «Boolean» set to true for MongoDB to wait until this save() has been . Overrides the schema-level option

  • [options.timestamps=true] «Boolean» if false and are enabled, skip timestamps for this save().

  • [fn] «Function» optional callback

Returns:
  • «Promise,undefined» Returns undefined if used with callback or a Promise otherwise.

Saves this document by inserting a new document into the database if is , or sends an updateOne operation with just the modified paths if isNew is false.

Example:

Example:

  1. const newProduct = await product.save();