routier-collection / core/src / ReplicationDbPlugin
Class: ReplicationDbPlugin
Defined in: core/src/plugins/replication/ReplicationDbPlugin.ts:7
Interface for a database plugin, which provides query, destroy, and bulk operations.
Implements
Properties
plugins
plugins:
ReplicationPluginOptions
Defined in: core/src/plugins/replication/ReplicationDbPlugin.ts:9
Constructors
constructor()
new ReplicationDbPlugin(
plugins):ReplicationDbPlugin
Defined in: core/src/plugins/replication/ReplicationDbPlugin.ts:20
Creates a new ReplicationDbPlugin that coordinates operations between a source database and its replicas.
Parameters
plugins
Configuration object containing the source, read (optional), and replica database plugins
plugins.source- The primary database plugin that will receive all operations firstplugins.read- Optional read-optimized plugin (typically a memory plugin) used for fast queriesplugins.replicas- Additional database plugins that will replicate operations from the source
Returns
ReplicationDbPlugin
A new ReplicationDbPlugin instance that manages the source-replica relationship
Methods
query()
query<
TEntity,TShape>(event,done):void
Defined in: core/src/plugins/replication/ReplicationDbPlugin.ts:29
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
destroy()
destroy(
event,done):void
Defined in: core/src/plugins/replication/ReplicationDbPlugin.ts:40
Destroys or cleans up the plugin, closing connections or freeing resources.
Parameters
event
done
PluginEventCallbackResult<never>
Callback with an optional error.
Returns
void
Implementation of
bulkPersist()
bulkPersist(
event,done):void
Defined in: core/src/plugins/replication/ReplicationDbPlugin.ts:66
Executes bulk operations (add, update, remove) on the database.
Parameters
event
The bulk operations event containing schema, parent, and changes.
done
PluginEventCallbackPartialResult<BulkPersistResult>
Callback with the result or error.
Returns
void