abstract AbstractPowerSyncDatabase
Extends
Extended by
Constructors
new AbstractPowerSyncDatabase()
new AbstractPowerSyncDatabase(options): AbstractPowerSyncDatabase
Parameters
| Parameter | Type |
|---|---|
options | PowerSyncDatabaseOptionsWithDBAdapter |
Returns
Overrides
new AbstractPowerSyncDatabase()
new AbstractPowerSyncDatabase(options): AbstractPowerSyncDatabase
Parameters
| Parameter | Type |
|---|---|
options | PowerSyncDatabaseOptionsWithOpenFactory |
Returns
Overrides
BaseObserver<PowerSyncDBListener>.constructor
new AbstractPowerSyncDatabase()
new AbstractPowerSyncDatabase(options): AbstractPowerSyncDatabase
Parameters
| Parameter | Type |
|---|---|
options | PowerSyncDatabaseOptionsWithSettings |
Returns
Overrides
BaseObserver<PowerSyncDBListener>.constructor
new AbstractPowerSyncDatabase()
new AbstractPowerSyncDatabase(options): AbstractPowerSyncDatabase
Parameters
| Parameter | Type |
|---|---|
options | PowerSyncDatabaseOptions |
Returns
Overrides
BaseObserver<PowerSyncDBListener>.constructor
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
closed | public | boolean | Returns true if the connection is closed. |
currentStatus | public | SyncStatus | Current connection status. |
logger | public | ILogger | - |
ready | public | boolean | - |
sdkVersion | public | string | - |
triggers | readonly | TriggerManager | Experimental Allows creating SQLite triggers which can be used to track various operations on SQLite tables. |
Accessors
connected
Get Signature
get connected(): boolean
Whether a connection to the PowerSync service is currently open.
Returns
boolean
connecting
Get Signature
get connecting(): boolean
Returns
boolean
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.
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.
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
schema
Get Signature
get schema(): Schema<{}>
Schema used for the local database.
Returns
Schema<{}>
syncStreamImplementation
Get Signature
get syncStreamImplementation():
| null
| StreamingSyncImplementation
Returns
| null
| StreamingSyncImplementation
Methods
_initialize()
abstract _initialize(): Promise<void>
Allows for extended implementations to execute custom initialization logic as part of the total init process
Returns
Promise<void>
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 |
Returns
Promise<void>
connect()
connect(connector, options?): Promise<void>
Connects to stream of events from the PowerSync instance.
Parameters
| Parameter | Type |
|---|---|
connector | PowerSyncBackendConnector |
options? | PowerSyncConnectionOptions |
Returns
Promise<void>
customQuery()
customQuery<RowType>(query): Query<RowType>
Allows building a WatchedQuery using an existing WatchCompatibleQuery. The watched query will use the provided WatchCompatibleQuery.execute method to query results.
Type Parameters
| Type Parameter |
|---|
RowType |
Parameters
| Parameter | Type |
|---|---|
query | WatchCompatibleQuery<RowType[]> |
Returns
Query<RowType>
Example
// Potentially a query from an ORM like Drizzle
const query = db.select().from(lists);
const watchedTodos = powersync.customQuery(query)
.watch()
// OR use .differentialWatch() for fine-grained watches.
disconnect()
disconnect(): Promise<void>
Close the sync connection.
Use connect to connect again.
Returns
Promise<void>
disconnectAndClear()
disconnectAndClear(options?): Promise<void>
Disconnect and clear the database. Use this when logging out. The database can still be queried after this is called, but the tables would be empty.
To preserve data in local-only tables, set clearLocal to false.
Parameters
| Parameter | Type |
|---|---|
options? | DisconnectAndClearOptions |