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

Function handleSuccessfulWrite

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

Source from the content-addressed store, hash-verified

3751}
3752
3753async function handleSuccessfulWrite(document, options) {
3754 const wasNew = document.$isNew;
3755 if (wasNew) {
3756 _setIsNew(document, false);
3757 }
3758
3759 document.$__reset();
3760 // version key gets initialized to 0 when inserting a new document so avoid incrementing version key here
3761 if (!wasNew) {
3762 document._applyVersionIncrement();
3763 }
3764 const postFilter = buildMiddlewareFilter(options, 'post');
3765 return document.schema.s.hooks.execPost('save', document, [document], { filter: postFilter });
3766}
3767
3768/**
3769 * 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