MCPcopy Create free account
hub / github.com/Automattic/mongoose / handleSuccessfulWrite

Function handleSuccessfulWrite

lib/model.js:3686–3699  ·  view source on GitHub ↗
(document, options)

Source from the content-addressed store, hash-verified

3684}
3685
3686async function handleSuccessfulWrite(document, options) {
3687 const wasNew = document.$isNew;
3688 if (wasNew) {
3689 _setIsNew(document, false);
3690 }
3691
3692 document.$__reset();
3693 // version key gets initialized to 0 when inserting a new document so avoid incrementing version key here
3694 if (!wasNew) {
3695 document._applyVersionIncrement();
3696 }
3697 const postFilter = buildMiddlewareFilter(options, 'post');
3698 return document.schema.s.hooks.execPost('save', document, [document], { filter: postFilter });
3699}
3700
3701/**
3702 * Apply defaults to the given document or POJO.

Callers 1

model.jsFile · 0.85

Calls 2

_setIsNewFunction · 0.85
buildMiddlewareFilterFunction · 0.85

Tested by

no test coverage detected