typeORMDriver
TypeScriptSource files: TypeScript
const typeORMDriver: object = legacyDriver
SQLite callback adapter for TypeORM's react-native DataSource type.
Pass this object as the DataSource's driver option. openDatabase accepts
a database name, optional relative location, and optional SEE
encryptionKey. It calls ok and returns the connection on success, or
calls fail and returns null when opening fails.
This package shares the core adapter implementation, so legacy core imports and this entry point use the same connection lifecycle and callbacks. TypeORM and react-native-nitro-sqlite must be installed as peer dependencies.
Type Declaration
openDatabase
openDatabase: (options, ok, fail) => TypeOrmConnection | null
Open a database for TypeORM.
Parameters
options
Database name, optional relative directory, and optional SEE key.
encryptionKey?
string
Key for a licensed SQLite SEE build. Without SEE, a supplied key fails
with EncryptionNotEnabled. An existing plaintext file is rejected.
location?
string
Directory relative to the platform database directory.
name
string
Database file name.
ok
(db) => void
Receives the adapter connection on success.
fail
(msg) => void
Receives the caught opening error on failure. The legacy string signature does not convert Error objects to strings.
Returns
TypeOrmConnection | null
The callback connection after ok runs, or null after fail runs.
A supplied encryption key requires a licensed SEE build; without SEE the
failure callback receives EncryptionNotEnabled.