Skip to main content
Version: 57.2.0

executeUpdate

executeUpdate<T>(__namedParameters): Promise<ExecutorResult<T>>

Update a document through the same pipeline as PATCH /:id: method-level and object-level permissions, doc loading (404), transformer.transform, _updatedAt stripping, preUpdate, the optional concurrency check, doc.set + doc.save (Mongoose validation), population, and postUpdate. Throws APIErrors with the same statuses/titles as the REST handler; concurrency conflicts throw ExecutorConflictError (409) carrying the server doc.

Type Parameters

T

T

Parameters

__namedParameters

body

unknown

concurrencyCheck?

ExecutorConcurrencyCheck

existingDoc?

ExecutorDoc<T>

Pre-loaded document, used by the REST handler where permissionMiddleware already loaded and authorized it (avoids a second fetch). Permission checks still run either way.

id

string

model

Model<T>

options

ModelRouterOptions<T>

req?

Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

The real Express request when called over HTTP; hooks receive a {user} stub otherwise.

skipPostHooks?

boolean

C5 (FIX 6): see executeCreate's skipPostHooks doc comment.

user?

User

Returns

Promise<ExecutorResult<T>>