kysely-dialect-expo
v0.1.0
Published
A Kysely dialect for Expo SQLite, allowing you to use the powerful Kysely query builder with SQLite databases in React Native/Expo applications.
Maintainers
Readme
kysely-dialect-expo
A Kysely dialect for Expo SQLite, allowing you to use the powerful Kysely query builder with SQLite databases in React Native/Expo applications.
Install
npm install kysely-dialect-expo kysely expo-sqlite
# or
pnpm add kysely-dialect-expo kysely expo-sqlite
# or
yarn add kysely-dialect-expo kysely expo-sqliteUsage
import * as SQLite from 'expo-sqlite'
import { Kysely } from 'kysely'
import { ExpoSqliteDialect } from 'kysely-dialect-expo'
interface Database {
users: {
id: number
name: string
email: string
}
}
const db = new Kysely<Database>({
dialect: new ExpoSqliteDialect({
database: () => SQLite.openDatabaseAsync('myapp.db'),
}),
})
// Query
const users = await db.selectFrom('users').selectAll().execute()
// Insert
await db.insertInto('users').values({ name: 'John', email: '[email protected]' }).execute()With Options
const db = new Kysely<Database>({
dialect: new ExpoSqliteDialect({
database: async () => {
const db = await SQLite.openDatabaseAsync('myapp.db')
await db.execAsync('PRAGMA foreign_keys = ON')
return db
},
debug: __DEV__,
}),
})Options
| Option | Type | Description |
|--------|------|-------------|
| database | () => Promise<SQLiteDatabase> | Function that returns an opened database |
| debug | boolean | Enable debug logging |
Platforms
- ✅ iOS
- ✅ Android
- ✅ macOS (Expo SDK 46+)
- ✅ Windows (Expo SDK 51+)
- ⚠️ Web (Experimental)
Requirements
- Expo SDK 48+
- Kysely 0.24.0+
License
MIT
