Skip to content

SqliteClient.ts

Connects Effect SQL to SQLite in React Native using @op-engineering/op-sqlite.

This module opens an on-device SQLite database and exposes it as both SqliteClient and the generic Effect SQL client. It serializes access, supports normal and value-based queries, and uses the driver’s synchronous query API by default. AsyncQuery and withAsyncQuery switch a scoped effect to the driver’s asynchronous query API. Streaming queries and updateValues are not supported by this driver.

Since v4.0.0



Creates a scoped React Native SQLite client from the supplied configuration, using a single serialized connection and honoring AsyncQuery for query execution.

Signature

declare const make: (
options: SqliteClientConfig
) => Effect.Effect<SqliteClient, never, Scope.Scope | Reactivity.Reactivity>

Source

Since v4.0.0

Fiber reference that makes the React Native SQLite client run queries through the asynchronous execute API instead of executeSync.

When to use

Use to switch React Native SQLite query execution to the asynchronous driver API for a scoped effect.

Signature

declare const AsyncQuery: Context.Reference<boolean>

Source

Since v4.0.0

Runs an effect with AsyncQuery enabled, causing React Native SQLite queries in that effect to use the asynchronous driver API.

Signature

declare const withAsyncQuery: <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, never>>

Source

Since v4.0.0

Builds a layer from a React Native SQLite client configuration, providing both SqliteClient and the generic SqlClient service.

Signature

declare const layer: (config: SqliteClientConfig) => Layer.Layer<SqliteClient | Client.SqlClient>

Source

Since v4.0.0

Builds a layer from an Effect Config value, providing both the React Native SqliteClient service and the generic SqlClient service.

Signature

declare const layerConfig: (
config: Config.Wrap<SqliteClientConfig>
) => Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError>

Source

Since v4.0.0

React Native SQLite client service interface, extending SqlClient with its configuration and marking updateValues as unsupported for SQLite.

Signature

export interface SqliteClient extends Client.SqlClient {
readonly [TypeId]: TypeId
readonly config: SqliteClientConfig
/** Not supported in sqlite */
readonly updateValues: never
}

Source

Since v4.0.0

Configuration for a React Native SQLite client, including the database filename, optional location and encryption key, span attributes, and query/result name transforms.

Signature

export interface SqliteClientConfig {
readonly filename: string
readonly location?: string | undefined
readonly encryptionKey?: string | undefined
readonly spanAttributes?: Record<string, unknown> | undefined
readonly transformResultNames?: ((str: string) => string) | undefined
readonly transformQueryNames?: ((str: string) => string) | undefined
}

Source

Since v4.0.0

Service tag for the React Native SQLite client.

Signature

declare const SqliteClient: Context.Service<SqliteClient, SqliteClient>

Source

Since v4.0.0

Runtime identifier attached to SQLite React Native client values.

Signature

declare const TypeId: "~@effect/sql-sqlite-react-native/SqliteClient"

Source

Since v4.0.0

Type-level identifier for SQLite React Native client values.

Signature

type TypeId = "~@effect/sql-sqlite-react-native/SqliteClient"

Source

Since v4.0.0