Model.prototype.remove()
Parameters
[options] «Object»
[options.session=null] «Session» the session associated with this operation. If not specified, defaults to the document’s associated session.
[fn] «function(err|product)» optional callback
Returns:
- «Promise» Promise
Removes this document from the db.
Example:
product.remove(function (err, product) {
if (err) return handleError(err);
Product.findById(product._id, function (err, product) {
console.log(product) // null
})
})
As an extra measure of flow control, remove will return a Promise (bound to fn
if passed) so it could be chained, or hooked to recieve errors
Example:
product.remove().then(function (product) {
...
}).catch(function (err) {
assert.ok(err)
})
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .