createCustomSqlitePersister
The createCustomSqlitePersister
function creates a Persister
object that you can configure to persist the Store
to a SQLite database.
createCustomSqlitePersister<ListenerHandle, Persist>(
store: PersistedStore<Persist>,
configOrStoreTableName: undefined | string | DatabasePersisterConfig,
executeCommand: DatabaseExecuteCommand,
addChangeListener: (listener: DatabaseChangeListener) => ListenerHandle,
delChangeListener: (listenerHandle: ListenerHandle) => void,
onSqlCommand: undefined | (sql: string, params?: any[]) => void,
onIgnoredError: undefined | (error: any) => void,
destroy: () => void,
persist: Persist,
thing: any,
getThing?: string,
): Persister<Persist>
Type | Description | |
---|---|---|
store | PersistedStore<Persist> | The |
configOrStoreTableName | undefined | string | DatabasePersisterConfig | A |
executeCommand | DatabaseExecuteCommand | A function that will execute a command against the database. |
addChangeListener | (listener: DatabaseChangeListener) => ListenerHandle | A function that will register a listener for changes to the database. |
delChangeListener | (listenerHandle: ListenerHandle) => void | A function that will unregister the listener for changes to the database. |
onSqlCommand | undefined | (sql: string, params?: any[]) => void | A function that will be called for each SQL command executed against the database. |
onIgnoredError | undefined | (error: any) => void | A function that will be called for errors that are ignored by 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 SQLite-oriented |
This is only used when developing custom database-oriented Persisters, and most TinyBase users will not need to be particularly aware of it.
All of the TinyBase SQLite-oriented Persister
functions use this function under the covers, and so you may wish to look at those implementations for ideas on how to build your own Persister
type, and as functional examples. Examine the implementation of the createSqlite3Persister
function as a good starting point, for example.
Since
v5.2.0