Registry / database / react-native-ts-sqlite-orm

react-native-ts-sqlite-orm

JSON →
library0.2.0jsnpmunverified

A fully typed TypeScript ORM for SQLite in React Native and Expo environments (v0.2.0). It provides a LINQ-like query builder for SELECT, INSERT, UPDATE, DELETE operations and supports multiple SQLite backends like react-native-sqlite-storage, expo-sqlite, and even custom API contexts. The library focuses on type safety, bulk save operations, optional encryption, and a custom useQuery hook. Unlike other ORMs, it abstracts away the specific database driver, allowing flexible switching without code changes.

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Entity is a named export, not default.

import { Entity } from 'react-native-ts-sqlite-orm'

Case-sensitive: Query with capital Q. Also requires Entity for table mapping.

import { Query } from 'react-native-ts-sqlite-orm'

ESM-only; no CommonJS require pattern supported.

import { DbContext } from 'react-native-ts-sqlite-orm'

Export name is lowercase 'encryption', not 'Encrypt'.

import { encryption } from 'react-native-ts-sqlite-orm'

Shows defining an Entity class, initializing DbContext with a driver, saving an entity, and querying with a condition using the Query builder.

import { Entity, Query, DbContext } from 'react-native-ts-sqlite-orm'; // Define an entity class User extends Entity { static get tableName() { return 'users'; } id: number = 0; name: string = ''; } // Initialize DbContext (assuming a SQLite driver is installed) const db = new DbContext({ driver: 'react-native-sqlite-storage', database: 'test.db' }); // Insert a user const user = new User(); user.name = 'Alice'; await db.save(user); // Query users const query = new Query(User); const results = await query.where(u => u.name === 'Alice').toArray(); console.log(results);
Debug
Known footguns
gotchaDbContext requires an external SQLite driver (e.g., react-native-sqlite-storage or expo-sqlite) to be installed separately.
gotchaEntity class must have a static getter `tableName` that returns the database table name.
gotchaThe library is ESM-only; CommonJS require() will not work.
gotchaQuery results are plain objects, not Entity instances, unless you manually map them.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
ahrefsbot
2
Resources