Skip to content

OpType Plugin Types

The OpType plugin type is used to specify the type of the plugin when registering it. It is defined as follows:

go
type OpType string

The OpType plugin type defines the following constants:

TypeDescription
operation.OpTypeBeforeInsertExecutes before inserting a document
operation.OpTypeAfterInsertExecutes after inserting a document
operation.OpTypeBeforeUpdateExecutes before updating a document
operation.OpTypeAfterUpdateExecutes after updating a document
operation.OpTypeBeforeDeleteExecutes before deleting a document
operation.OpTypeAfterDeleteExecutes after deleting a document
operation.OpTypeBeforeUpsertExecutes before saving a document
operation.OpTypeAfterUpsertExecutes after saving a document
operation.OpTypeBeforeFindExecutes before querying a document
operation.OpTypeAfterFindExecutes after querying a document
operation.OpTypeBeforeAnyExecutes before any operation
operation.OpTypeAfterAnyExecutes after any operation

Each of these operation types corresponds to a specific phase in the lifecycle of database operations, allowing you to hook into different stages for custom logic processing.