Registry / database / sqlite-simplifier

sqlite-simplifier

JSON →
library1.0.3jsnpmunverified

A type-safe, fluent SQLite query builder for React Native and Node.js (≥16), wrapping react-native-sqlite-storage. Current stable version: 1.0.3. Provides a clean builder API with features like select, join, aggregate functions (COUNT, SUM, AVG, MIN, MAX), advanced WHERE conditions (IN, BETWEEN, OR), duplicate query blocking, query caching, and SQL injection protection. Ships TypeScript types. Differentiators vs knex: focused on React Native, simpler API, built-in caching and deduplication. Release cadence: early stage, infrequent updates.

npm install sqlite-simplifier
INSTALL
IMPORT
SIG · SQLITE-SIMPLIFIER
S
sqlite-simplifier
databasejavascriptv1.0.3
harness data pending
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.

createAdvancedQuery
import { createAdvancedQuery } from 'sqlite-simplifier'
const createAdvancedQuery = require('sqlite-simplifier').createAdvancedQuery
ESM-only; requires a Database instance (accepted by the library, not from react-native-sqlite-storage directly).
where / orWhere
import { where, orWhere } from 'sqlite-simplifier'
const where = require('sqlite-simplifier').where
Used in advanced WHERE conditions; these are named exports.
SimplifiedQueryBuilder (chainable API)
import { createAdvancedQuery } from 'sqlite-simplifier'; const query = createAdvancedQuery(db, true); const result = await query.query('transactions').select('id').get();
import { SimplifiedQueryBuilder } from 'sqlite-simplifier'
SimplifiedQueryBuilder is not exported directly; use the returned object from createAdvancedQuery.

Shows how to initialize the library, perform a basic find, use the chainable query builder with a join and aggregation, and use advanced WHERE clauses.

import { createAdvancedQuery } from 'sqlite-simplifier'; import { Database } from './Database'; // your Database class wrapping react-native-sqlite-storage const db = new Database(); const query = createAdvancedQuery(db, true); // Simple SELECT * const all = await query.find('transactions'); console.log(all); // Chainable query with join const result = await query .query('transactions') .select('id', 'title', 'amount') .leftJoin('categories', 'category_id', 'id') .count('total', 'transactions.id') .groupBy('transactions.id') .orderBy('amount', 'DESC') .limit(10) .get(); console.log(result); // Advanced WHERE import { where, orWhere } from 'sqlite-simplifier'; const filtered = await query.find('transactions', { where: [where('amount', '>', 1000), orWhere('type', '=', 'income')], }); console.log(filtered);
Debug
Known issues
gotchacreateAdvancedQuery expects a Database instance that wraps react-native-sqlite-storage, not the raw Sqlite object.
fix
Ensure you pass an instance of your Database class (e.g., from a wrapper) as first argument.
affects: >=1.0.0
gotchaThe 'select' field in the options object uses an object with database column mappings, not an array of column names.
fix
Use { id: 'id', title: 'transactions.title' } not ['id', 'title']. For simple select, use the chainable .select() instead.
affects: >=1.0.0
deprecatedThe 'SimplifiedQueryBuilder' class is not exported; use the chainable query from createAdvancedQuery result.
fix
Do not import SimplifiedQueryBuilder. Use createAdvancedQuery and then call .query() to get the builder.
affects: >=1.0.0
gotchaWhen using WHERE with IN operator, the value must be an array, not a comma-separated string.
fix
Pass array: where('id', 'IN', [1,2,3]) instead of where('id', 'IN', '1,2,3').
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: createAdvancedQuery is not a function
Using CommonJS require instead of ESM import.
fix
Use import { createAdvancedQuery } from 'sqlite-simplifier' or ensure your environment supports ESM.
Error: Invalid database instance. Expected a Database object.
First argument to createAdvancedQuery is not a valid Database instance.
fix
Create a Database instance (e.g., from a wrapper) before passing it: const db = new Database(); const query = createAdvancedQuery(db, true);
Error: Table name is required.
Calling .find() without a table name or .query() without a table.
fix
Provide a table name string: await query.find('transactions') or query.query('transactions')...
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
reactoptionalpeer dependency — used in React Native apps
react-nativeoptionalpeer dependency — the primary platform target
react-native-sqlite-storageoptionalpeer dependency — underlying SQLite driver
Agent activity
15 hits · last 30 days
node
12
Meta
2
OpenAI (training)
1
Resources
sqlite-simplifier — npm install sqlite-simplifier · libregistry