PowerSyncDatabase
A PowerSync database which provides SQLite functionality which is automatically synced.
Example
export const db = new PowerSyncDatabase({
schema: AppSchema,
database: {
dbFilename: 'example.db'
}
});
Extends
Constructors
new PowerSyncDatabase()
new PowerSyncDatabase(options): PowerSyncDatabase
Parameters
| Parameter | Type |
|---|---|
options | NodePowerSyncDatabaseOptions |
Returns
Overrides
AbstractPowerSyncDatabase.constructor
Properties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
closed | public | boolean | Returns true if the connection is closed. | AbstractPowerSyncDatabase.closed |
currentStatus | public | SyncStatus | Current connection status. | AbstractPowerSyncDatabase.currentStatus |
logger | public | ILogger | - | AbstractPowerSyncDatabase.logger |
ready | public | boolean | - | AbstractPowerSyncDatabase.ready |
sdkVersion | public | string | - | AbstractPowerSyncDatabase.sdkVersion |
triggers | readonly | TriggerManager | Experimental Allows creating SQLite triggers which can be used to track various operations on SQLite tables. | AbstractPowerSyncDatabase.triggers |
Accessors
connected
Get Signature
get connected(): boolean
Whether a connection to the PowerSync service is currently open.
Returns
boolean
Inherited from
AbstractPowerSyncDatabase.connected
connecting
Get Signature
get connecting(): boolean
Returns
boolean
Inherited from
AbstractPowerSyncDatabase.connecting
connectionOptions
Get Signature
get connectionOptions():
| null
| InternalConnectionOptions
The resolved connection options used to connect to the PowerSync service.
Returns
| null
| InternalConnectionOptions
The resolved connection options used to connect to the PowerSync service or null if connect() has not been called.
Inherited from
AbstractPowerSyncDatabase.connectionOptions
connector
Get Signature
get connector():
| null
| PowerSyncBackendConnector
The connector used to connect to the PowerSync service.
Returns
| null
| PowerSyncBackendConnector
The connector used to connect to the PowerSync service or null if connect() has not been called.
Inherited from
AbstractPowerSyncDatabase.connector
database
Get Signature
get database(): DBAdapter
The underlying database.
For the most part, behavior is the same whether querying on the underlying database, or on AbstractPowerSyncDatabase.
Returns
Inherited from
AbstractPowerSyncDatabase.database
schema
Get Signature
get schema(): Schema<{}>
Schema used for the local database.
Returns
Schema<{}>
Inherited from
AbstractPowerSyncDatabase.schema
syncStreamImplementation
Get Signature
get syncStreamImplementation():
| null
| StreamingSyncImplementation
Returns
| null
| StreamingSyncImplementation
Inherited from
AbstractPowerSyncDatabase.syncStreamImplementation
Methods
_initialize()
_initialize(): Promise<void>
Allows for extended implementations to execute custom initialization logic as part of the total init process
Returns
Promise<void>
Overrides
AbstractPowerSyncDatabase._initialize
close()
close(options?): Promise<void>
Close the database, releasing resources.
Also disconnects any active connection.
Once close is called, this connection cannot be used again - a new one must be constructed.
Parameters
| Parameter | Type |
|---|---|
options? | PowerSyncCloseOptions |