SqliteClient.ts
SqliteClient.ts overview
Section titled “SqliteClient.ts overview”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
Exports Grouped by Category
Section titled “Exports Grouped by Category”constructors
Section titled “constructors”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>Since v4.0.0
fiber refs
Section titled “fiber refs”AsyncQuery
Section titled “AsyncQuery”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>Since v4.0.0
withAsyncQuery
Section titled “withAsyncQuery”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>>Since v4.0.0
layers
Section titled “layers”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>Since v4.0.0
layerConfig
Section titled “layerConfig”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>Since v4.0.0
models
Section titled “models”SqliteClient (interface)
Section titled “SqliteClient (interface)”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}Since v4.0.0
SqliteClientConfig (interface)
Section titled “SqliteClientConfig (interface)”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}Since v4.0.0
services
Section titled “services”SqliteClient
Section titled “SqliteClient”Service tag for the React Native SQLite client.
Signature
declare const SqliteClient: Context.Service<SqliteClient, SqliteClient>Since v4.0.0
type IDs
Section titled “type IDs”TypeId
Section titled “TypeId”Runtime identifier attached to SQLite React Native client values.
Signature
declare const TypeId: "~@effect/sql-sqlite-react-native/SqliteClient"Since v4.0.0
TypeId (type alias)
Section titled “TypeId (type alias)”Type-level identifier for SQLite React Native client values.
Signature
type TypeId = "~@effect/sql-sqlite-react-native/SqliteClient"Since v4.0.0