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
Methods
registerListener()
registerListener(listener): () => void
Parameters
Parameter | Type |
---|
listener | Partial <T > |
Returns
Function
Returns
void
BasePowerSyncDatabaseOptions
Extended by
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 | Schema used for the local database. |
BatchedUpdateNotification
Properties
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
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()
Returns
string
hasCompletedSync()
hasCompletedSync(): Promise<boolean>
Returns
Promise
<boolean
>
hasCrud()
hasCrud(): Promise<boolean>
Returns
Promise
<boolean
>
init()
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
BaseObserver
.iterateListeners
nextCrudItem()
nextCrudItem(): Promise<undefined | CrudEntry>
Returns
Promise
<undefined
| CrudEntry
>
registerListener()
registerListener(listener): () => void
Register a listener for updates to the PowerSync client.
Parameters
Returns
Function
Returns
void
Inherited from
BaseObserver
.registerListener
removeBuckets()
removeBuckets(buckets): Promise<void>
Parameters
Parameter | Type |
---|
buckets | string [] |
Returns
Promise
<void
>
saveSyncData()
saveSyncData(batch): Promise<void>
Parameters
Returns
Promise
<void
>
setTargetCheckpoint()
setTargetCheckpoint(checkpoint): Promise<void>
Parameters
Returns
Promise
<void
>
startSession()
Returns
void
syncLocalDatabase()
syncLocalDatabase(checkpoint): Promise<{
checkpointValid: boolean;
failures: any[];
ready: boolean;
}>
Parameters
Returns
Promise
<{
checkpointValid
: boolean
;
failures
: any
[];
ready
: boolean
;
}>
updateLocalTarget()
updateLocalTarget(cb): Promise<boolean>
Parameters
Parameter | Type |
---|
cb | () => Promise <string > |
Returns
Promise
<boolean
>
BucketStorageListener
Extends
Indexable
[key: string]: undefined | (...event) => any
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
CompilableQuery<T>
Type Parameters
Methods
compile()
Returns
CompiledQuery
execute()
Returns
Promise
<T
[]>
CompilableQueryWatchHandler<T>
Type Parameters
Properties
Property | Type |
---|
onError? | (error : Error ) => void |
onResult | (results : T []) => void |
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
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. |
DataStreamListener<Data>
Extends
Type Parameters
Type Parameter | Default type |
---|
Data extends any | any |
Indexable
[key: string]: undefined | (...event) => any
Properties
Property | Type |
---|
closed | () => void |
data | (data : Data ) => Promise <void > |
error | (error : Error ) => void |
highWater | () => Promise <void > |
lowWater | () => Promise <void > |
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
Parameters
Parameter | Type |
---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
>
Inherited from
DBGetUtils
.get
getAll()
getAll<T>(sql, parameters?): Promise<T[]>
Execute a read-only query and return results.
Type Parameters
Parameters
Parameter | Type |
---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
[]>
Inherited from
DBGetUtils
.getAll
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
Parameters
Parameter | Type |
---|
sql | string |
parameters ? | any [] |
Returns
Promise
<null
| T
>
Inherited from
DBGetUtils
.getOptional
registerListener()
registerListener(listener): () => void
Parameters
Returns
Function
Returns
void
Inherited from
BaseObserverInterface
.registerListener
DBAdapterListener
Extends
Indexable
[key: string]: undefined | (...event) => any
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
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
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
Parameters
Parameter | Type |
---|
sql | string |
parameters ? | any [] |
Returns
Promise
<null
| T
>
DBLockOptions
Properties
Property | Type |
---|
timeoutMs? | number |
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
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
Parameters
Parameter | Type |
---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
>
Inherited from
DBGetUtils
.get
getAll()
getAll<T>(sql, parameters?): Promise<T[]>
Execute a read-only query and return results.
Type Parameters
Parameters
Parameter | Type |
---|
sql | string |
parameters ? | any [] |
Returns
Promise
<T
[]>
Inherited from
DBGetUtils
.getAll
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
Parameters
Parameter | Type |
---|
sql | string |
parameters ? | any [] |
Returns
Promise
<null
| T
>
Inherited from
DBGetUtils
.getOptional
LockOptions<T>
Abstract Lock to be implemented by various JS environments
Type Parameters
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 |
PowerSyncDatabaseOptions
Extends
Properties
PowerSyncDatabaseOptionsWithDBAdapter
Extends
Properties
PowerSyncDatabaseOptionsWithOpenFactory
Extends
Properties
PowerSyncDatabaseOptionsWithSettings
Extends
Properties
PowerSyncDBListener
Extends
Indexable
[key: string]: undefined | (...event) => any
Properties
PowerSyncOpenFactoryOptions
Extends
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 |
database? | | SQLOpenOptions | DBAdapter | SQLOpenFactory | Source for a SQLite database connection. This can be either: - A DBAdapter if providing an instantiated SQLite connection - A SQLOpenFactory which will be used to open a SQLite connection - SQLOpenOptions for opening a SQLite connection with a default SQLOpenFactory | - | Partial.database |
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 |
logger? | ILogger | - | - | Partial.logger |
retryDelay? | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | - | Partial.retryDelay |
schema | Schema | Schema used for the local database. | Partial.schema | - |
ResolvedWebSQLOpenOptions