Skip to main content

CapacitorSQLiteAdapter

Experimental Alpha

An implementation of DBAdapter using the Capacitor Community SQLite plugin.

This is currently experimental and may change without a major version bump.

Extends

  • DBAdapter

Constructors

Constructor

new CapacitorSQLiteAdapter(options): CapacitorSQLiteAdapter;

Alpha Experimental

Parameters

ParameterType
optionsCapacitorSQLiteOpenFactoryOptions

Returns

CapacitorSQLiteAdapter

Overrides

DBAdapter.constructor

Accessors

name

Get Signature

get name(): string;

Alpha Experimental

Returns

string

Overrides

DBAdapter.name

Methods

close()

close(): Promise<void>;

Alpha Experimental

Returns

Promise<void>

Overrides

DBAdapter.close

dispose()

dispose(): void;

Alpha Experimental

Returns

void

Inherited from

DBAdapter.dispose

execute()

execute<T>(query, params?): Promise<QueryResult<T>>;

Alpha

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

ParameterType
querystring
params?any[]

Returns

Promise<QueryResult<T>>

The query result as an object with structured key-value pairs

Inherited from

DBAdapter.execute

executeBatch()

executeBatch(query, params?): Promise<QueryResult<never>>;

Alpha

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

ParameterType
querystring
params?any[][]

Returns

Promise<QueryResult<never>>

The query result

Inherited from

DBAdapter.executeBatch

executeRaw()

executeRaw(query, params?): Promise<RawQueryResult>;

Alpha

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

ParameterType
querystring
params?any[]

Returns

Promise<RawQueryResult>

The RawQueryResult representing each row as an array.

Inherited from

DBAdapter.executeRaw

get()

get<T>(sql, parameters?): Promise<T>;

Alpha

Execute a read-only query and return the first result, error if the ResultSet is empty.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
sqlstringThe 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

Inherited from

DBAdapter.get

getAll()

getAll<T>(sql, parameters?): Promise<T[]>;

Alpha

Execute a read-only query and return results.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
sqlstringThe SQL query to execute
parameters?any[]Optional array of parameters to bind to the query

Returns

Promise<T[]>

An array of results

Inherited from

DBAdapter.getAll

getOptional()

getOptional<T>(sql, parameters?): Promise<T | null>;

Alpha

Execute a read-only query and return the first result, or null if the ResultSet is empty.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
sqlstringThe SQL query to execute
parameters?any[]Optional array of parameters to bind to the query

Returns

Promise<T | null>

The first result if found, or null if no results are returned

Inherited from

DBAdapter.getOptional

iterateAsyncListeners()

iterateAsyncListeners(cb): Promise<void>;

Alpha Experimental

Parameters

ParameterType
cb(listener) => Promise<any>

Returns

Promise<void>

Inherited from

DBAdapter.iterateAsyncListeners

iterateListeners()

iterateListeners(cb): void;

Alpha Experimental

Parameters

ParameterType
cb(listener) => any

Returns

void

Inherited from

DBAdapter.iterateListeners

readLock()

readLock<T>(fn, options?): Promise<T>;

Alpha Experimental

Type Parameters

Type Parameter
T

Parameters

ParameterType
fn(tx) => Promise<T>
options?DBLockOptions

Returns

Promise<T>

Overrides

DBAdapter.readLock

readTransaction()

readTransaction<T>(fn, options?): Promise<T>;

Alpha Experimental

Type Parameters

Type Parameter
T

Parameters

ParameterType
fn(tx) => Promise<T>
options?DBLockOptions

Returns

Promise<T>

Inherited from

DBAdapter.readTransaction

refreshSchema()

refreshSchema(): Promise<void>;

Alpha

This method refreshes the schema information across all connections. This is for advanced use cases, and should generally not be needed.

Returns

Promise<void>

Overrides

DBAdapter.refreshSchema

registerListener()

registerListener(listener): () => void;

Alpha

Register a listener for updates to the PowerSync client.

Parameters

ParameterType
listenerPartial<T>

Returns

() => void

Inherited from

DBAdapter.registerListener

writeLock()

writeLock<T>(fn, options?): Promise<T>;

Alpha Experimental

Type Parameters

Type Parameter
T

Parameters

ParameterType
fn(tx) => Promise<T>
options?DBLockOptions

Returns

Promise<T>

Overrides

DBAdapter.writeLock

writeTransaction()

writeTransaction<T>(fn, options?): Promise<T>;

Alpha Experimental

Type Parameters

Type Parameter
T

Parameters

ParameterType
fn(tx) => Promise<T>
options?DBLockOptions

Returns

Promise<T>

Inherited from

DBAdapter.writeTransaction