createCustomMsSqlPersister
The createCustomMsSqlPersister function creates a Persister object that you can configure to persist the Store to a SQL Server database.
createCustomMsSqlPersister<Persist>(
store: PersistedStore<Persist>,
configOrStoreTableName: string | DatabasePersisterConfig | undefined,
executeCommand: DatabaseExecuteCommand,
onSqlCommand: ((sql: string, params?: any[]) => void) | undefined,
onIgnoredError: ((error: any) => void) | undefined,
destroy: () => void,
persist: Persist,
thing: any,
getThing?: string,
): Persister<Persist>| Type | Description | |
|---|---|---|
store | PersistedStore<Persist> | The |
configOrStoreTableName | string | DatabasePersisterConfig | undefined | A |
executeCommand | DatabaseExecuteCommand | A function that will execute a command against the database. |
onSqlCommand | ((sql: string, params?: any[]) => void) | undefined | A function that will be called for each SQL command executed against the database. |
onIgnoredError | ((error: any) => void) | undefined | An optional handler for the errors that the |
destroy | () => void | A function that will be called to perform any extra clean up on the |
persist | Persist | An integer from the |
thing | any | A reference to the database or connection that can be returned with a method, by default called |
getThing? | string | An optional string that will be used to get the reference to the database or connection from the |
| returns | Persister<Persist> | A reference to the new |
This is only used when developing custom database-oriented Persisters, and most TinyBase users will not need to be particularly aware of it.
Unlike the PostgreSQL equivalent, this takes no change listener functions. SQL Server has no notification mechanism that is available on every one of its hosted flavors, so automatic loading polls a rowversion column that the Persister maintains instead.
The createMsSqlPersister function uses this function under the covers, and so you may wish to look at that implementation for ideas on how to build your own Persister type, and as a functional example.
Since
10.0.0