abstract DBAdapter
Extends
Extended by
Implements
Constructors
new DBAdapter()
new DBAdapter(): DBAdapter
Returns
Inherited from
Accessors
name
Get Signature
get abstract name(): string
Returns
string
Methods
close()
abstract close(): void | Promise<void>
Returns
void | Promise<void>
dispose()
dispose(): void
Returns
void
Inherited from
execute()
execute<T>(query, params?): Promise<QueryResult<T>>
Execute a SQL write (INSERT/UPDATE/DELETE) query and optionally return results.
When using the default client-side JSON-based view system,
the returned result's rowsAffected may be 0 for successful UPDATE and DELETE statements.
Use a RETURNING clause and inspect result.rows when you need to confirm which rows changed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
query | string |
params? | any[] |
Returns
Promise<QueryResult<T>>
The query result as an object with structured key-value pairs
Implementation of
executeBatch()
executeBatch(query, params?): Promise<QueryResult<never>>
Execute a write query (INSERT/UPDATE/DELETE) multiple times with each parameter set and optionally return results. This is faster than executing separately with each parameter set.
Parameters
| Parameter | Type |
|---|---|
query | string |
params? | any[][] |
Returns
Promise<QueryResult<never>>
The query result
Implementation of
executeRaw()
executeRaw(query, params?): Promise<RawQueryResult>
Execute a SQL write (INSERT/UPDATE/DELETE) query directly on the database without any PowerSync processing. This bypasses certain PowerSync abstractions and is useful for accessing the raw database results.
Parameters
| Parameter | Type |
|---|---|
query | string |
params? | any[] |
Returns
Promise<RawQueryResult>
The RawQueryResult representing each row as an array.
Implementation of
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 | Description |
|---|---|---|
sql | string | The SQL query to execute |
parameters? | any[] | Optional array of parameters to bind to the query |
Returns
Promise<T>
The first result matching the query
Throws
Error if no rows are returned
Implementation of
getAll()
getAll<T>(sql, parameters?): Promise<T[]>
Execute a read-only query and return results.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
sql | string | The SQL query to execute |
parameters? | any[] | Optional array of parameters to bind to the query |
Returns
Promise<T[]>
An array of results
Implementation of
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 | Description |
|---|---|---|
sql | string | The SQL query to execute |
parameters? | any[] | Optional array of parameters to bind to the query |
Returns
Promise<null | T>
The first result if found, or null if no results are returned
Implementation of
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
readLock()
abstract readLock<T>(fn, options?): Promise<T>
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
fn | (tx) => Promise<T> |
options? | DBLockOptions |
Returns
Promise<T>
readTransaction()
readTransaction<T>(fn, options?): Promise<T>
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
fn | (tx) => Promise<T> |
options? | DBLockOptions |
Returns
Promise<T>
refreshSchema()
abstract refreshSchema(): Promise<void>
This method refreshes the schema information across all connections. This is for advanced use cases, and should generally not be needed.
Returns
Promise<void>
registerListener()
registerListener(listener): () => void
Register a listener for updates to the PowerSync client.
Parameters
| Parameter | Type |
|---|---|
listener | Partial<DBAdapterListener> |
Returns
Function
Returns
void
Inherited from
writeLock()
abstract writeLock<T>(fn, options?): Promise<T>
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
fn | (tx) => Promise<T> |
options? | DBLockOptions |
Returns
Promise<T>
writeTransaction()
writeTransaction<T>(fn, options?): Promise<T>
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
fn | (tx) => Promise<T> |
options? | DBLockOptions |
Returns
Promise<T>