Registry / database / firesql

firesql

JSON →
library2.0.2jsnpmunverified

FireSQL is a JavaScript library (v2.0.2, latest stable) that enables querying Cloud Firestore using SQL syntax. Built on the official Firebase SDK, it translates SQL SELECT statements into Firestore queries, minimizing server requests. Key differentiators: support for SELECT, WHERE, ORDER BY, LIMIT, GROUP BY, aggregate functions (AVG, MIN, MAX, SUM), nested field access with backtick syntax, and realtime updates via RxJS observables (requires rxfire). Limitations include no INSERT/UPDATE/DELETE, no JOINs, limited LIKE, and no COUNT. Releases are infrequent; maintained on GitHub.

npm install firesql
INSTALL
IMPORT
SIG · FIRESQL
F
firesql
databasejavascriptv2.0.2
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.

FireSQL
import { FireSQL } from 'firesql'
const FireSQL = require('firesql')
ESM-only since v2. CommonJS require will fail.
FireSQL (realtime)
import { FireSQL } from 'firesql'; import 'firesql/rx'
import { FireSQL } from 'firesql/rx'
The rx module is a side-effect import that must be loaded separately.
FireSQL (Firebase compat)
import { FireSQL } from 'firesql'
import FireSQL from 'firesql'
FireSQL is a named export, not a default export.

Initializes FireSQL with a Firestore reference and runs a simple SELECT query.

import { FireSQL } from 'firesql'; import firebase from 'firebase/app'; import 'firebase/firestore'; firebase.initializeApp({ apiKey: process.env.FIREBASE_API_KEY ?? '', authDomain: process.env.FIREBASE_AUTH_DOMAIN ?? '', projectId: process.env.FIREBASE_PROJECT_ID ?? '' }); const fireSQL = new FireSQL(firebase.firestore()); fireSQL.query('SELECT * FROM cities WHERE country = "USA" LIMIT 5') .then(cities => { console.log(cities); }) .catch(err => console.error(err));
Debug
Known issues
breakingFireSQL v2 dropped CommonJS support and is ESM-only.
fix
Use ESM imports (import { FireSQL } from 'firesql') and ensure your environment supports ES modules.
affects: >=2.0.0
deprecatedFirebase v9+ uses modular SDK; FireSQL v2 still expects the compat layer (firebase/app/compat).
fix
Use firebase/compat for now, or wait for FireSQL update. Example: import firebase from 'firebase/compat/app'; import 'firebase/compat/firestore';
affects: >=9.0.0 (Firebase)
gotchaRealtime queries require the rx module import: import 'firesql/rx'.
fix
Add import 'firesql/rx' before using .rxQuery(). Also install rxjs and rxfire.
affects: *
gotchaGROUP BY cannot be combined with ORDER BY or LIMIT.
fix
Avoid using ORDER BY or LIMIT in queries that contain GROUP BY.
affects: *
gotchaSpecial field `__name__` is not automatically available; you must select it explicitly as a field.
fix
Include `__name__` in your SELECT statement, e.g., SELECT __name__, name FROM collection.
affects: *
gotchaLIKE only supports prefix matching (e.g., 'value%') or exact match (no wildcard meaning).
fix
Use LIKE 'value%' for prefix search; for other patterns, use alternative filtering.
affects: *
gotchaFireSQL does not support nested collection queries (queries on subcollections are not SQL-friendly).
fix
Create a new FireSQL instance referencing the document or subcollection path manually.
affects: *
Errors
Common errors & fixes
Cannot find module 'firesql'
Package not installed or ESM-only environment not configured.
fix
Run 'npm install firesql firebase' and ensure 'type': 'module' in package.json or use .mjs extension.
FireSQL is not a constructor
Default import used instead of named import.
fix
Change import statement to: import { FireSQL } from 'firesql'
firebase.firestore is not a function
Firebase v9+ modular SDK used without compat layer.
fix
Install firebase/compat: import firebase from 'firebase/compat/app'; import 'firebase/compat/firestore';
rxjs is not defined
Missing rxjs dependency when using .rxQuery.
fix
Install rxjs and rxfire: npm install rxjs rxfire
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
firebaserequiredPeer dependency; provides Firestore instance.
rxjsoptionalRequired for realtime queries (.rxQuery) and if using the reactive module.
rxfireoptionalRequired for realtime queries (.rxQuery) and if using the reactive module.
Agent activity
4 hits · last 30 days
node
4
Resources