routier-collection


routier-collection / core/src / OptimisticReplicationDbPlugin

Class: OptimisticReplicationDbPlugin

Defined in: core/src/plugins/replication/OptimisticReplicationDbPlugin.ts:30

Interface for a database plugin, which provides query, destroy, and bulk operations.

Implements

Methods

create()

static create(plugins): OptimisticReplicationDbPlugin

Defined in: core/src/plugins/replication/OptimisticReplicationDbPlugin.ts:45

Creates a new OptimisticDbPluginReplicator that coordinates operations between a source database and its replicas.

Parameters

plugins

OptimisticReplicationPluginOptions

Returns

OptimisticReplicationDbPlugin

A new DbPluginReplicator instance that manages the source-replica relationship


query()

query<TEntity, TShape>(event, done): void

Defined in: core/src/plugins/replication/OptimisticReplicationDbPlugin.ts:52

Will query the read plugin if there is one, otherwise the source plugin will be queried

Type Parameters

TEntity

TEntity extends object

TShape

TShape extends unknown = TEntity

Parameters

event

DbPluginQueryEvent<TEntity, TShape>

done

PluginEventCallbackResult<ITranslatedValue<TShape>>

Callback with the result or error. The result must be wrapped in an ITranslatedValue to allow the datastore to iterate over results (for grouped queries) and determine if change tracking should be enabled.

Returns

void

Implementation of

IDbPlugin.query


destroy()

destroy(event, done): void

Defined in: core/src/plugins/replication/OptimisticReplicationDbPlugin.ts:151

Destroys or cleans up the plugin, closing connections or freeing resources.

Parameters

event

DbPluginEvent

done

PluginEventCallbackResult<never>

Callback with an optional error.

Returns

void

Implementation of

IDbPlugin.destroy


bulkPersist()

bulkPersist(event, done): void

Defined in: core/src/plugins/replication/OptimisticReplicationDbPlugin.ts:176

Executes bulk operations (add, update, remove) on the database.

Parameters

event

DbPluginBulkPersistEvent

The bulk operations event containing schema, parent, and changes.

done

PluginEventCallbackPartialResult<BulkPersistResult>

Callback with the result or error.

Returns

void

Implementation of

IDbPlugin.bulkPersist