Skip to main content

setOperationSubject

@webda/core


Function: setOperationSubject()

setOperationSubject(subject): void

Defined in: packages/core/src/core/operations.ts:163

Declare the object the current operation acts on, when the framework cannot derive it: a service operation such as Publisher.PublishPost(postId). Listeners such as the audit log record it like a derived subject, and it takes precedence over one. Call it from the operation (or anything it calls); outside an operation it does nothing.

Parameters​

subject​

Model | { key: unknown; model: any; }

a model instance, or { model, key } with a model class or identifier and its primary key (scalar, object of key fields, or canonical string)

Returns​

void

Throws​

Error if the model is unknown or the key does not match its primary key