@powersync/web
Enumerations
Enumeration | Description |
---|---|
ColumnType | - |
LockType | - |
OpTypeEnum | - |
PSInternalTable | - |
RowUpdateType | Update table operation numbers from SQLite |
SyncStreamConnectionMethod | - |
UpdateType | Type of local change. |
Classes
Class | Description |
---|---|
AbortOperation | Calls to Abortcontroller.abort(reason: any) will result in the reason being thrown. This is not necessarily an error, but extends error for better logging purposes. |
AbstractPowerSyncDatabase | - |
AbstractPowerSyncDatabaseOpenFactory | - |
AbstractRemote | - |
AbstractStreamingSyncImplementation | - |
AbstractWebPowerSyncDatabaseOpenFactory | Intermediate PowerSync Database Open factory for Web which uses a mock SSR DB Adapter if running on server side. Most SQLite DB implementations only run on client side, this will safely return empty query results in SSR which will allow for generating server partial views. |
AbstractWebSQLOpenFactory | - |
BaseObserver | - |
Column | - |
CrudBatch | A batch of client-side changes. |
CrudEntry | A single client-side change. |
CrudTransaction | A batch of client-side changes. |
DataStream | A very basic implementation of a data stream with backpressure support which does not use native JS streams or async iterators. This is handy for environments such as React Native which need polyfills for the above. |
FetchImplementationProvider | Class wrapper for providing a fetch implementation. The class wrapper is used to distinguish the fetchImplementation option in [AbstractRemoteOptions] from the general fetch method which is typeof "function" |
Index | - |
IndexedColumn | - |
OpType | Used internally for sync buckets. |
OplogEntry | - |
PowerSyncDatabase | A PowerSync database which provides SQLite functionality which is automatically synced. |
Schema | A schema is a collection of tables. It is used to define the structure of a database. |
SharedWebStreamingSyncImplementation | - |
SqliteBucketStorage | - |
SyncDataBatch | - |
SyncDataBucket | - |
SyncStatus | - |
Table | - |
TableV2 | Generate a new table from the columns and indexes |
UploadQueueStats | - |
WASQLiteDBAdapter | Adapter for WA-SQLite SQLite connections. |
WASQLiteOpenFactory | Opens a SQLite connection using WA-SQLite. |
WASQLitePowerSyncDatabaseOpenFactory | - |
WebRemote | - |
WebStreamingSyncImplementation | - |
Functions
Function | Description |
---|---|
extractTableUpdates | - |
isBatchedUpdateNotification | - |
isContinueCheckpointRequest | - |
isDBAdapter | Tests if input is a DBAdapter |
isPowerSyncDatabaseOptionsWithSettings | Tests if the input is a PowerSyncDatabaseOptionsWithSettings |
isSQLOpenFactory | Tests if input is a SQLOpenFactory |
isSQLOpenOptions | Tests if the input is a SQLOpenOptions |
isServerSide | - |
isStreamingKeepalive | - |
isStreamingSyncCheckpoint | - |
isStreamingSyncCheckpointComplete | - |
isStreamingSyncCheckpointDiff | - |
isStreamingSyncData | - |
isSyncNewCheckpointRequest | - |
parseQuery | - |
resolveWebPowerSyncFlags | - |
resolveWebSQLFlags | - |
runOnSchemaChange | - |
Interfaces
AbstractStreamingSyncImplementationOptions
Extended by
Properties
Property | Type | Description |
---|---|---|
adapter | BucketStorageAdapter | - |
crudUploadThrottleMs? | number | - |
identifier? | string | An identifier for which PowerSync DB this sync implementation is linked to. Most commonly DB name, but not restricted to DB name. |
logger? | ILogger | - |
remote | AbstractRemote | - |
retryDelayMs? | number | - |
uploadCrud | () => Promise <void > | - |
BaseObserverInterface<T>
Extended by
Type parameters
Type parameter |
---|
T extends BaseListener |
Methods
registerListener()
registerListener(listener): () => void
Parameters
Parameter | Type |
---|---|
listener | Partial <T > |
Returns
Function
Returns
void
BasePowerSyncDatabaseOptions
Extended by
PowerSyncDatabaseOptions
PowerSyncDatabaseOptionsWithDBAdapter
PowerSyncDatabaseOptionsWithOpenFactory
PowerSyncDatabaseOptionsWithSettings
Properties
Property | Type | Description |
---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. |
logger? | ILogger | - |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. |
schema | Schema <SchemaType > | Schema used for the local database. |
BatchedUpdateNotification
Properties
Property | Type |
---|---|
groupedUpdates | Record <string , TableUpdateOperation []> |
rawUpdates | UpdateNotification [] |
tables | string [] |
BucketChecksum
Properties
Property | Type | Description |
---|---|---|
bucket | string | - |
checksum | number | 32-bit unsigned hash. |
count? | number | Count of operations - informational only. |
BucketRequest
Properties
Property | Type | Description |
---|---|---|
after | string | Base-10 number. Sync all data from this bucket with op_id > after. |
name | string | - |
BucketState
Properties
Property | Type |
---|---|
bucket | string |
op_id | string |
BucketStorageAdapter
Extends
Properties
Property | Type | Inherited from |
---|---|---|
dispose | () => Promise <void > | Disposable .dispose |
Methods
autoCompact()
autoCompact(): Promise<void>
Exposed for tests only.
Returns
Promise
<void
>
forceCompact()
forceCompact(): Promise<void>
Exposed for tests only.
Returns
Promise
<void
>
getBucketStates()
getBucketStates(): Promise<BucketState[]>
Returns
Promise
<BucketState
[]>
getClientId()
getClientId(): Promise<string>
Get an unique client id.
Returns
Promise
<string
>
getCrudBatch()
getCrudBatch(limit?): Promise<null | CrudBatch>
Parameters
Parameter | Type |
---|---|
limit ? | number |
Returns
Promise
<null
| CrudBatch
>
getMaxOpId()
getMaxOpId(): string
Returns
string
hasCompletedSync()
hasCompletedSync(): Promise<boolean>
Returns
Promise
<boolean
>
hasCrud()
hasCrud(): Promise<boolean>
Returns
Promise
<boolean
>
init()
init(): Promise<void>
Returns
Promise
<void
>
iterateAsyncListeners()
iterateAsyncListeners(cb): Promise<void>
Parameters
Parameter | Type |
---|---|
cb | (listener ) => Promise <any > |
Returns
Promise
<void
>
Inherited from
BaseObserver
.iterateAsyncListeners
iterateListeners()
iterateListeners(cb): void
Parameters
Parameter | Type |
---|---|
cb | (listener ) => any |
Returns
void
Inherited from
nextCrudItem()
nextCrudItem(): Promise<undefined | CrudEntry>
Returns
Promise
<undefined
| CrudEntry
>
registerListener()
registerListener(listener): () => void
Register a listener for updates to the PowerSync client.
Parameters
Parameter | Type |
---|---|
listener | Partial <BucketStorageListener > |
Returns
Function
Returns
void
Inherited from
removeBuckets()
removeBuckets(buckets): Promise<void>
Parameters
Parameter | Type |
---|---|
buckets | string [] |
Returns
Promise
<void
>
saveSyncData()
saveSyncData(batch): Promise<void>
Parameters
Parameter | Type |
---|---|
batch | SyncDataBatch |
Returns
Promise
<void
>
setTargetCheckpoint()
setTargetCheckpoint(checkpoint): Promise<void>
Parameters
Parameter | Type |
---|---|
checkpoint | Checkpoint |
Returns
Promise
<void
>
startSession()
startSession(): void
Returns
void
syncLocalDatabase()
syncLocalDatabase(checkpoint): Promise<{
checkpointValid: boolean;
failures: any[];
ready: boolean;
}>
Parameters
Parameter | Type |
---|---|
checkpoint | Checkpoint |
Returns
Promise
<{
checkpointValid
: boolean
;
failures
: any
[];
ready
: boolean
;
}>
Member | Type |
---|---|
checkpointValid | boolean |
failures | any [] |
ready | boolean |
updateLocalTarget()
updateLocalTarget(cb): Promise<boolean>
Parameters
Parameter | Type |
---|---|
cb | () => Promise <string > |
Returns
Promise
<boolean
>
BucketStorageListener
Extends
Properties
Property | Type |
---|---|
crudUpdate | () => void |
Checkpoint
Properties
Property | Type |
---|---|
buckets | BucketChecksum [] |
last_op_id | string |
write_checkpoint? | string |
ChecksumCache
Properties
Property | Type |
---|---|
checksums | Map <string , { checksum : BucketChecksum ; last_op_id : string ; }> |
lastOpId | string |
ColumnOptions
Properties
Property | Type |
---|---|
name | string |
type? | ColumnType |
CompilableQuery<T>
Type parameters
Type parameter |
---|
T |
Methods
compile()
compile(): CompiledQuery
Returns
execute()
execute(): Promise<T[]>
Returns
Promise
<T
[]>
CompiledQuery
Properties
Property | Modifier | Type |
---|---|---|
parameters | readonly | readonly unknown [] |
sql | readonly | string |
ContinueCheckpointRequest
For sync2.json
Properties
Property | Type | Description |
---|---|---|
buckets | BucketRequest [] | Existing bucket states. Only these buckets are synchronized. |
checkpoint_token | string | - |
limit? | number | - |
CrudRequest
For crud.json
Properties
Property | Type |
---|---|
data | CrudEntry [] |
CrudResponse
Properties
Property | Type | Description |
---|---|---|
checkpoint? | string | A sync response with a checkpoint >= this checkpoint would contain all the changes in this request. Any earlier checkpoint may or may not contain these changes. May be empty when the request contains no ops. |
DBAdapter
Extends
Properties
Property | Type | Description |
---|---|---|
close | () => void | - |
execute | (query : string , params ?: any []) => Promise <QueryResult > | - |
executeBatch | (query : string , params ?: any [][]) => Promise <QueryResult > | - |
name | string | - |
readLock | <T >(fn : (tx ) => Promise <T >, options ?: DBLockOptions ) => Promise <T > | - |
readTransaction | <T >(fn : (tx ) => Promise <T >, options ?: DBLockOptions ) => Promise <T > | - |
refreshSchema | () => Promise <void > | This method refreshes the schema information across all connections. This is for advanced use cases, and should generally not be needed. |
writeLock | <T >(fn : (tx ) => Promise <T >, options ?: DBLockOptions ) => Promise <T > | - |
writeTransaction | <T >(fn : (tx ) => Promise <T >, options ?: DBLockOptions ) => Promise <T > | - |
Methods
get()
get<T>(sql, parameters?): Promise<T>
Execute a read-only query and return the first result, error if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
>
Inherited from
getAll()
getAll<T>(sql, parameters?): Promise<T[]>
Execute a read-only query and return results.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
[]>
Inherited from
getOptional()
getOptional<T>(sql, parameters?): Promise<null | T>
Execute a read-only query and return the first result, or null if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<null
| T
>
Inherited from
registerListener()
registerListener(listener): () => void
Parameters
Parameter | Type |
---|---|
listener | Partial <DBAdapterListener > |
Returns
Function
Returns
void
Inherited from
BaseObserverInterface
.registerListener
DBAdapterListener
Extends
Properties
Property | Type | Description |
---|---|---|
tablesUpdated | (updateNotification : BatchedUpdateNotification | UpdateNotification ) => void | Listener for table updates. Allows for single table updates in order to maintain API compatibility without the need for a major version bump The DB adapter can also batch update notifications if supported. |
DBGetUtils
Extended by
Methods
get()
get<T>(sql, parameters?): Promise<T>
Execute a read-only query and return the first result, error if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
>
getAll()
getAll<T>(sql, parameters?): Promise<T[]>
Execute a read-only query and return results.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
[]>
getOptional()
getOptional<T>(sql, parameters?): Promise<null | T>
Execute a read-only query and return the first result, or null if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<null
| T
>
DBLockOptions
Properties
Property | Type |
---|---|
timeoutMs? | number |
DataStreamListener<Data>
Extends
Type parameters
Type parameter | Value |
---|---|
Data extends any | any |
Properties
Property | Type |
---|---|
closed | () => void |
data | (data : Data ) => Promise <void > |
error | (error : Error ) => void |
highWater | () => Promise <void > |
lowWater | () => Promise <void > |
DisconnectAndClearOptions
Properties
Property | Type | Description |
---|---|---|
clearLocal? | boolean | When set to false, data in local-only tables is preserved. |
Disposable
Extended by
Properties
Property | Type |
---|---|
dispose | () => Promise <void > |
IndexColumnOptions
Properties
Property | Type |
---|---|
ascending? | boolean |
name | string |
IndexOptions
Properties
Property | Type |
---|---|
columns? | IndexedColumn [] |
name | string |
LockContext
Extends
Extended by
Properties
Property | Type | Description |
---|---|---|
execute | (query : string , params ?: any []) => Promise <QueryResult > | Execute a single write statement. |
Methods
get()
get<T>(sql, parameters?): Promise<T>
Execute a read-only query and return the first result, error if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
>
Inherited from
getAll()
getAll<T>(sql, parameters?): Promise<T[]>
Execute a read-only query and return results.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
[]>
Inherited from
getOptional()
getOptional<T>(sql, parameters?): Promise<null | T>
Execute a read-only query and return the first result, or null if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<null
| T
>
Inherited from
LockOptions<T>
Abstract Lock to be implemented by various JS environments
Type parameters
Type parameter |
---|
T |
Properties
Property | Type |
---|---|
callback | () => Promise <T > |
signal? | AbortSignal |
type | LockType |
OplogEntryJSON
Properties
Property | Type |
---|---|
checksum | number |
data? | string |
object_id? | string |
object_type? | string |
op | string |
op_id | string |
subkey? | string | object |
ParsedQuery
Properties
Property | Type |
---|---|
parameters | any [] |
sqlStatement | string |
PowerSyncBackendConnector
Properties
Property | Type | Description |
---|---|---|
fetchCredentials | () => Promise <null | PowerSyncCredentials > | Allows the PowerSync client to retrieve an authentication token from your backend which is used to authenticate against the PowerSync service. This should always fetch a fresh set of credentials - don't use cached values. Return null if the user is not signed in. Throw an error if credentials cannot be fetched due to a network error or other temporary error. This token is kept for the duration of a sync connection. |
uploadData | (database : AbstractPowerSyncDatabase ) => Promise <void > | Upload local changes to the app backend. Use AbstractPowerSyncDatabase.getCrudBatch to get a batch of changes to upload. Any thrown errors will result in a retry after the configured wait period (default: 5 seconds). |
PowerSyncCloseOptions
Properties
Property | Type | Description |
---|---|---|
disconnect? | boolean | Disconnect the sync stream client if connected. This is usually true, but can be false for Web when using multiple tabs and a shared sync provider. |
PowerSyncConnectionOptions
Configurable options to be used when connecting to the PowerSync backend instance.
Properties
Property | Type | Description |
---|---|---|
connectionMethod? | SyncStreamConnectionMethod | The connection method to use when streaming updates from the PowerSync backend instance. Defaults to a HTTP streaming connection. |
params? | Record <string , JSONValue > | These parameters are passed to the sync rules, and will be available under theuser_parameters object. |
PowerSyncCredentials
Properties
Property | Type |
---|---|
endpoint | string |
expiresAt? | Date |
token | string |
PowerSyncDBListener
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
initialized | () => void | - | - |
schemaChanged | (schema : Schema <SchemaType >) => void | - | - |
statusChanged? | (status : SyncStatus ) => void | Triggers whenever the status' members have changed in value | StreamingSyncImplementationListener .statusChanged |
statusUpdated? | (statusUpdate : SyncStatusOptions ) => void | Triggered whenever a status update has been attempted to be made or refreshed. | StreamingSyncImplementationListener .statusUpdated |
PowerSyncDatabaseOptions
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | BasePowerSyncDatabaseOptions .crudUploadThrottleMs |
database | SQLOpenOptions | DBAdapter | SQLOpenFactory | Source for a SQLite database connection. This can be either:
| - |
logger? | ILogger | - | BasePowerSyncDatabaseOptions .logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | BasePowerSyncDatabaseOptions .retryDelay |
schema | Schema <SchemaType > | Schema used for the local database. | BasePowerSyncDatabaseOptions .schema |
PowerSyncDatabaseOptionsWithDBAdapter
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | BasePowerSyncDatabaseOptions .crudUploadThrottleMs |
database | DBAdapter | - | - |
logger? | ILogger | - | BasePowerSyncDatabaseOptions .logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | BasePowerSyncDatabaseOptions .retryDelay |
schema | Schema <SchemaType > | Schema used for the local database. | BasePowerSyncDatabaseOptions .schema |
PowerSyncDatabaseOptionsWithOpenFactory
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | BasePowerSyncDatabaseOptions .crudUploadThrottleMs |
database | SQLOpenFactory | - | - |
logger? | ILogger | - | BasePowerSyncDatabaseOptions .logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | BasePowerSyncDatabaseOptions .retryDelay |
schema | Schema <SchemaType > | Schema used for the local database. | BasePowerSyncDatabaseOptions .schema |
PowerSyncDatabaseOptionsWithSettings
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | BasePowerSyncDatabaseOptions .crudUploadThrottleMs |
database | SQLOpenOptions | - | - |
logger? | ILogger | - | BasePowerSyncDatabaseOptions .logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | BasePowerSyncDatabaseOptions .retryDelay |
schema | Schema <SchemaType > | Schema used for the local database. | BasePowerSyncDatabaseOptions .schema |
PowerSyncOpenFactoryOptions
Extends
Partial
<PowerSyncDatabaseOptions
>.SQLOpenOptions
Extended by
Properties
Property | Type | Description | Overrides | Inherited from |
---|---|---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | Partial.crudUploadThrottleMs | Partial.crudUploadThrottleMs |
database? | SQLOpenOptions | DBAdapter | SQLOpenFactory | Source for a SQLite database connection. This can be either:
| Partial.database | Partial.database |
dbFilename | string | Filename for the database. | SQLOpenOptions .dbFilename | SQLOpenOptions .dbFilename |
dbLocation? | string | Directory where the database file is located. | SQLOpenOptions .dbLocation | SQLOpenOptions .dbLocation |
debugMode? | boolean | Enable debugMode to log queries to the performance timeline. Defaults to false. To enable in development builds, use: debugMode: process.env.NODE_ENV !== 'production' | SQLOpenOptions .debugMode | SQLOpenOptions .debugMode |
logger? | ILogger | - | Partial.logger | Partial.logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | Partial.retryDelay | Partial.retryDelay |
schema | Schema <SchemaType > | Schema used for the local database. | Partial.schema | Partial.schema |
ResolvedWebSQLOpenOptions
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
dbFilename | string | Filename for the database. | SQLOpenOptions .dbFilename |
dbLocation? | string | Directory where the database file is located. | SQLOpenOptions .dbLocation |
debugMode? | boolean | Enable debugMode to log queries to the performance timeline. Defaults to false. To enable in development builds, use: debugMode: process.env.NODE_ENV !== 'production' | SQLOpenOptions .debugMode |
flags | Required <WebSQLFlags > | - | - |
SQLOpenFactory
Methods
openDB()
openDB(): DBAdapter
Opens a connection adapter to a SQLite DB
Returns
SQLOpenOptions
Extended by
Properties
Property | Type | Description |
---|---|---|
dbFilename | string | Filename for the database. |
dbLocation? | string | Directory where the database file is located. |
debugMode? | boolean | Enable debugMode to log queries to the performance timeline. Defaults to false. To enable in development builds, use: debugMode: process.env.NODE_ENV !== 'production' |
SQLWatchOptions
Properties
Property | Type | Description |
---|---|---|
rawTableNames? | boolean | Deprecated All tables specified in tables will be watched, including PowerSync tables with prefixes. Allows for watching any SQL table by not removing PowerSync table name prefixes |
signal? | AbortSignal | - |
tables? | string [] | - |
throttleMs? | number | The minimum interval between queries. |
StreamingSyncCheckpoint
Properties
Property | Type |
---|---|
checkpoint | Checkpoint |
StreamingSyncCheckpointComplete
Properties
Property | Type |
---|---|
checkpoint_complete | { last_op_id : string ; } |
checkpoint_complete.last_op_id | string |
StreamingSyncCheckpointDiff
Properties
Property | Type |
---|---|
checkpoint_diff | { last_op_id : string ; removed_buckets : string []; updated_buckets : BucketChecksum []; write_checkpoint : string ; } |
checkpoint_diff.last_op_id | string |
checkpoint_diff.removed_buckets | string [] |
checkpoint_diff.updated_buckets | BucketChecksum [] |
checkpoint_diff.write_checkpoint | string |
StreamingSyncDataJSON
Properties
Property | Type |
---|---|
data | SyncDataBucketJSON |
StreamingSyncImplementation
Extends
Properties
Property | Type | Inherited from |
---|---|---|
dispose | () => Promise <void > | Disposable .dispose |
getWriteCheckpoint | () => Promise <string > | - |
hasCompletedSync | () => Promise <boolean > | - |
isConnected | boolean | - |
lastSyncedAt? | Date | - |
syncStatus | SyncStatus | - |
triggerCrudUpload | () => void | - |
Methods
connect()
connect(options?): Promise<void>
Connects to the sync service
Parameters
Parameter | Type |
---|---|
options ? | PowerSyncConnectionOptions |
Returns
Promise
<void
>
disconnect()
disconnect(): Promise<void>
Disconnects from the sync services.
Returns
Promise
<void
>
Throws
if not connected or if abort is not controlled internally
iterateAsyncListeners()
iterateAsyncListeners(cb): Promise<void>
Parameters
Parameter | Type |
---|---|
cb | (listener ) => Promise <any > |
Returns
Promise
<void
>
Inherited from
BaseObserver
.iterateAsyncListeners
iterateListeners()
iterateListeners(cb): void
Parameters
Parameter | Type |
---|---|
cb | (listener ) => any |
Returns
void
Inherited from
registerListener()
registerListener(listener): () => void
Register a listener for updates to the PowerSync client.
Parameters
Parameter | Type |
---|---|
listener | Partial <StreamingSyncImplementationListener > |
Returns
Function
Returns
void
Inherited from
waitForReady()
waitForReady(): Promise<void>
Returns
Promise
<void
>
waitForStatus()
waitForStatus(status): Promise<void>
Parameters
Parameter | Type |
---|---|
status | SyncStatusOptions |
Returns
Promise
<void
>
StreamingSyncImplementationListener
Extends
Extended by
Properties
Property | Type | Description |
---|---|---|
statusChanged? | (status : SyncStatus ) => void | Triggers whenever the status' members have changed in value |
statusUpdated? | (statusUpdate : SyncStatusOptions ) => void | Triggered whenever a status update has been attempted to be made or refreshed. |
StreamingSyncKeepalive
Properties
Property | Type | Description |
---|---|---|
token_expires_in | number | If specified, token expires in this many seconds. |
StreamingSyncRequest
Properties
Property | Type | Description |
---|---|---|
buckets? | BucketRequest [] | Existing bucket states. |
client_id? | string | - |
include_checksum | boolean | Whether or not to compute a checksum for each checkpoint |
only? | string [] | If specified, limit the response to only include these buckets. |
parameters? | Record <string , JSONValue > | Client parameters to be passed to the sync rules. |
raw_data | boolean | Changes the response to stringified data in each OplogEntry |
SyncLocalDatabaseResult
Properties
Property | Type |
---|---|
checkpointFailures? | string [] |
checkpointValid | boolean |
ready | boolean |
SyncNewCheckpointRequest
Properties
Property | Type | Description |
---|---|---|
buckets? | BucketRequest [] | Existing bucket states. Used if include_data is specified. |
limit? | number | - |
request_checkpoint | { include_checksum : boolean ; include_data : boolean ; } | - |
request_checkpoint.include_checksum | boolean | Whether or not to compute a checksum. |
request_checkpoint.include_data | boolean | Whether or not to include an initial data request. |
SyncResponse
Properties
Property | Type | Description |
---|---|---|
checkpoint? | Checkpoint | - |
checkpoint_token? | string | - |
data? | SyncDataBucketJSON [] | Data for the buckets returned. May not have an an entry for each bucket in the request. |
has_more | boolean | True if the response limit has been reached, and another request must be made. |
TableOptions
Properties
Property | Type | Description |
---|---|---|
columns | Column [] | - |
indexes? | Index [] | - |
insertOnly? | boolean | - |
localOnly? | boolean | - |
name | string | The synced table name, matching sync rules |
viewName? | string | - |
TableUpdateOperation
Extended by
Properties
Property | Type |
---|---|
opType | RowUpdateType |
rowId | number |
TableV2Options
Properties
Property | Type |
---|---|
indexes? | IndexShorthand |
insertOnly? | boolean |
localOnly? | boolean |
viewName? | string |
Transaction
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
commit | () => Promise <QueryResult > | Commit multiple changes to the local DB using the Transaction context. | - |
execute | (query : string , params ?: any []) => Promise <QueryResult > | Execute a single write statement. | LockContext .execute |
rollback | () => Promise <QueryResult > | Roll back multiple attempted changes using the Transaction context. | - |
Methods
get()
get<T>(sql, parameters?): Promise<T>
Execute a read-only query and return the first result, error if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
>
Inherited from
getAll()
getAll<T>(sql, parameters?): Promise<T[]>
Execute a read-only query and return results.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
[]>
Inherited from
getOptional()
getOptional<T>(sql, parameters?): Promise<null | T>
Execute a read-only query and return the first result, or null if the ResultSet is empty.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
sql | string |
parameters ? | any [] |
Returns
Promise
<null
| T
>
Inherited from
UpdateNotification
Notification of an update to one or more tables, for the purpose of realtime change notifications.
Extends
Properties
Property | Type | Inherited from |
---|---|---|
opType | RowUpdateType | TableUpdateOperation .opType |
rowId | number | TableUpdateOperation .rowId |
table | string | - |
WASQLiteDBAdapterOptions
Extends
Omit
<PowerSyncOpenFactoryOptions
,"schema"
>
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | Omit.crudUploadThrottleMs |
database? | SQLOpenOptions | DBAdapter | SQLOpenFactory | Source for a SQLite database connection. This can be either:
| Omit.database |
dbFilename | string | Filename for the database. | Omit.dbFilename |
dbLocation? | string | Directory where the database file is located. | Omit.dbLocation |
debugMode? | boolean | Enable debugMode to log queries to the performance timeline. Defaults to false. To enable in development builds, use: debugMode: process.env.NODE_ENV !== 'production' | Omit.debugMode |
flags? | WebSQLFlags | - | - |
logger? | ILogger | - | Omit.logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | Omit.retryDelay |
worker? | string | URL | (options ) => SharedWorker | Worker | - | - |
workerPort? | MessagePort | Use an existing port to an initialized worker. A worker will be initialized if none is provided | - |
WatchHandler
Properties
Property | Type |
---|---|
onError? | (error : Error ) => void |
onResult | (results : QueryResult ) => void |
WatchOnChangeEvent
Properties
Property | Type |
---|---|
changedTables | string [] |
WatchOnChangeHandler
Properties
Property | Type |
---|---|
onChange | (event : WatchOnChangeEvent ) => void | Promise <void > |
onError? | (error : Error ) => void |
WebPowerSyncFlags
Common settings used when creating SQL connections on web.
Extends
Extended by
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
broadcastLogs? | boolean | Broadcast logs from shared workers, such as the shared sync worker, to individual tabs. This defaults to true. | WebSQLFlags .broadcastLogs |
disableSSRWarning? | boolean | SQLite operations are currently not supported in SSR mode. A warning will be logged if attempting to use SQLite in SSR. Setting this to true will disabled the warning above. | WebSQLFlags .disableSSRWarning |
enableMultiTabs? | boolean | Enables multi tab support | WebSQLFlags .enableMultiTabs |
externallyUnload? | boolean | Externally unload open PowerSync database instances when the window closes. Setting this to true requires calling close on all open PowerSyncDatabase instances before the window unloads | - |
ssrMode? | boolean | Open in SSR placeholder mode. DB operations and Sync operations will be a No-op | WebSQLFlags .ssrMode |
useWebWorker? | boolean | The SQLite connection is often executed through a web worker in order to offload computation. This can be used to manually disable the use of web workers in environments where web workers might be unstable. | WebSQLFlags .useWebWorker |
WebPowerSyncOpenFactoryOptions
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
crudUploadThrottleMs? | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | PowerSyncOpenFactoryOptions .crudUploadThrottleMs |
database? | SQLOpenOptions | DBAdapter | SQLOpenFactory | Source for a SQLite database connection. This can be either:
| PowerSyncOpenFactoryOptions .database |
dbFilename | string | Filename for the database. | PowerSyncOpenFactoryOptions .dbFilename |
dbLocation? | string | Directory where the database file is located. | PowerSyncOpenFactoryOptions .dbLocation |
debugMode? | boolean | Enable debugMode to log queries to the performance timeline. Defaults to false. To enable in development builds, use: debugMode: process.env.NODE_ENV !== 'production' | PowerSyncOpenFactoryOptions .debugMode |
flags? | WebPowerSyncOpenFlags | - | - |
logger? | ILogger | - | PowerSyncOpenFactoryOptions .logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | PowerSyncOpenFactoryOptions .retryDelay |
schema | Schema <SchemaType > | Schema used for the local database. | PowerSyncOpenFactoryOptions .schema |
WebPowerSyncOpenFlags
WebPowerSyncFlags Maintaining export for consistency with API from previous versions
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
broadcastLogs? | boolean | Broadcast logs from shared workers, such as the shared sync worker, to individual tabs. This defaults to true. | WebPowerSyncFlags .broadcastLogs |
disableSSRWarning? | boolean | SQLite operations are currently not supported in SSR mode. A warning will be logged if attempting to use SQLite in SSR. Setting this to true will disabled the warning above. | WebPowerSyncFlags .disableSSRWarning |
enableMultiTabs? | boolean | Enables multi tab support | WebPowerSyncFlags .enableMultiTabs |
externallyUnload? | boolean | Externally unload open PowerSync database instances when the window closes. Setting this to true requires calling close on all open PowerSyncDatabase instances before the window unloads | WebPowerSyncFlags .externallyUnload |
ssrMode? | boolean | Open in SSR placeholder mode. DB operations and Sync operations will be a No-op | WebPowerSyncFlags .ssrMode |
useWebWorker? | boolean | The SQLite connection is often executed through a web worker in order to offload computation. This can be used to manually disable the use of web workers in environments where web workers might be unstable. | WebPowerSyncFlags .useWebWorker |
WebSQLFlags
Common settings used when creating SQL connections on web.
Extended by
Properties
Property | Type | Description |
---|---|---|
broadcastLogs? | boolean | Broadcast logs from shared workers, such as the shared sync worker, to individual tabs. This defaults to true. |
disableSSRWarning? | boolean | SQLite operations are currently not supported in SSR mode. A warning will be logged if attempting to use SQLite in SSR. Setting this to true will disabled the warning above. |
enableMultiTabs? | boolean | Enables multi tab support |
ssrMode? | boolean | Open in SSR placeholder mode. DB operations and Sync operations will be a No-op |
useWebWorker? | boolean | The SQLite connection is often executed through a web worker in order to offload computation. This can be used to manually disable the use of web workers in environments where web workers might be unstable. |
WebSQLOpenFactoryOptions
Options for opening a Web SQL connection
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
dbFilename | string | Filename for the database. | SQLOpenOptions .dbFilename |
dbLocation? | string | Directory where the database file is located. | SQLOpenOptions .dbLocation |
debugMode? | boolean | Enable debugMode to log queries to the performance timeline. Defaults to false. To enable in development builds, use: debugMode: process.env.NODE_ENV !== 'production' | SQLOpenOptions .debugMode |
flags? | WebSQLFlags | - | - |
worker? | string | URL | (options ) => SharedWorker | Worker | Allows you to override the default wasqlite db worker. You can either provide a path to the worker script or a factory method that returns a worker. | - |
WebStreamingSyncImplementationOptions
Extends
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
adapter | BucketStorageAdapter | - | AbstractStreamingSyncImplementationOptions .adapter |
crudUploadThrottleMs? | number | - | AbstractStreamingSyncImplementationOptions .crudUploadThrottleMs |
database? | { options : { worker : string | URL | (options ) => SharedWorker | Worker ; }; } | - | - |
database.options | { worker : string | URL | (options ) => SharedWorker | Worker ; } | - | - |
database.options.worker? | string | URL | (options ) => SharedWorker | Worker | - | - |
flags? | WebSQLFlags | - | - |
identifier? | string | An identifier for which PowerSync DB this sync implementation is linked to. Most commonly DB name, but not restricted to DB name. | AbstractStreamingSyncImplementationOptions .identifier |
logger? | ILogger | - | AbstractStreamingSyncImplementationOptions .logger |
remote | AbstractRemote | - | AbstractStreamingSyncImplementationOptions .remote |
retryDelayMs? | number | - | AbstractStreamingSyncImplementationOptions .retryDelayMs |
sync? | { worker : string | URL | (options ) => SharedWorker ; } | - | - |
sync.worker? | string | URL | (options ) => SharedWorker | - | - |
uploadCrud | () => Promise <void > | - | AbstractStreamingSyncImplementationOptions .uploadCrud |
WebSyncOptions
Properties
Property | Type | Description |
---|---|---|
worker? | string | URL | (options ) => SharedWorker | Allows you to override the default sync worker. You can either provide a path to the worker script or a factory method that returns a worker. |