build.gradle.kts
file:
cocoapods
config in your build.gradle.kts
:linkOnly = true
attribute and isStatic = true
framework setting ensure that the powersync-sqlite-core
binaries are statically linked.PowerSyncDatabase
constructor via the schema
parameter. This schema represents a “view” of the downloaded data. No migrations are required — the schema is applied directly when the PowerSync database is constructed.
The types available are text
, integer
and real
. These should map directly to the values produced by the Sync Rules. If a value doesn’t match, it is cast automatically.
Example:
id
column, as PowerSync will automatically create this.DatabaseDriverFactory
to be used by the PowerSyncBuilder
to create the SQLite database driver.
PowerSyncDatabase
instance using the PowerSyncBuilder
and the DatabaseDriverFactory
. The schema you created in a previous step is provided as a parameter:
PowerSyncDatabase
to the backend connector:
com.powersync:powersync-compose
provides a simpler API:
PowerSyncBackendConnector.fetchCredentials
- This is called every couple of minutes and is used to obtain credentials for your app backend API. -> See Authentication Setup for instructions on how the credentials should be generated.PowerSyncBackendConnector.uploadData
- Use this to upload client-side changes to your app backend.
-> See Writing Client Changes for considerations on the app backend implementation.get
method executes a read-only (SELECT) query and returns a single result. It throws an exception if no result is found. Use getOptional
to return a single optional result (returns null
if no result is found).
getAll
method executes a read-only (SELECT) query and returns a set of rows.
watch
method executes a read query whenever a change to a dependent table is made.
execute
method executes a write query (INSERT, UPDATE, DELETE) and returns the results (if any).
Warnings
in release and Verbose
in debug as follows:
SyncOptions(newClientImplementation = true)
as a second parameter when
connecting.
PowerSyncDatabase.connect()
method uses HTTP streams.
You can optionally specify the connectionMethod
to override this: