Registry / database / database-ql

database-ql

JSON →
library1.0.0jsnpmunverified

A MongoDB-like query syntax library for JavaScript/TypeScript environments, designed for use with Laf cloud development platform. Version 1.0.0 (beta) provides a fluent API for database operations including CRUD, query commands (eq, gt, in, etc.), update commands (inc, push, etc.), aggregation, and regex queries. It supports both client-side (laf-client-sdk) and server-side (laf) usage, with ESM and TypeScript support. Unlike direct MongoDB drivers, it offers a simplified, promise-based interface with automatic request batching and Laf-specific security features (CVE-2023-48225 fixed in beta.14).

npm install database-ql
INSTALL
IMPORT
SIG · DATABASE-QL
D
database-ql
databasejavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

Database
import { Database } from 'database-ql'
const Database = require('database-ql')
ESM-only package; CommonJS require may fail in Node.js < 14 or without ESM support.
cloud.database
import cloud from '@lafjs/cloud'; const db = cloud.database()
const db = new Database()
In Laf environment, database is obtained via cloud.database() not directly instantiated.
db.command
import cloud from '@lafjs/cloud'; const db = cloud.database(); const _ = db.command
import { command } from 'database-ql'
The query/update commands are accessed via db.command, not a named export.
Collection
import { Collection } from 'database-ql'
Available for TypeScript type annotations, but not typically used directly.

Basic CRUD operations using the Laf cloud database with query and update commands.

import cloud from '@lafjs/cloud'; export default async function (ctx: FunctionContext) { const db = cloud.database(); const collection = db.collection('users'); // Insert a document const { id } = await collection.add({ name: 'Alice', age: 30 }); // Query with conditions const result = await collection.where({ age: db.command.gte(18) }).get(); console.log('Users:', result.data); // Update using update commands await collection.doc(id).update({ age: db.command.inc(1) }); // Delete a document await collection.doc(id).remove(); }
Debug
Known issues
breakingCVE-2023-48225: Unauthorized database access due to missing permission checks in laf before beta.14.
fix
Upgrade to laf >=1.0.0-beta.14 or apply the security patch.
affects: <1.0.0-beta.14
deprecatedThe `serverDate` function is deprecated in favor of `Date` object or server-side timestamps.
fix
Use `new Date()` or rely on laf's automatic timestamp insertion.
affects: >=1.0.0
gotchaThe `get()` method returns `{ data: [], requestId: string }` not a direct array.
fix
Access the array via `result.data` instead of treating the result as an array.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'database-ql'
Package not installed or missing in package.json dependencies.
fix
Run `npm install database-ql` and ensure version is >=1.0.0.
TypeError: db.collection is not a function
Using `new Database()` directly instead of `cloud.database()`.
fix
Use `const db = cloud.database();` where `cloud` is imported from `@lafjs/cloud`.
Property 'command' does not exist on type 'Database'
Attempting to access `db.command` without initializing via `cloud.database()`.
fix
Ensure you call `cloud.database()` first to get the db instance with commands.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
database-ql — npm install database-ql · libregistry