Registry / database / n1-sql

n1-sql

JSON →
library0.1.8jsnpmunverified

An npm package (v0.1.8) for interacting with an N1 SQL service endpoint, providing a privacy-preserving SQL query builder. It uses a purely functional, fluent API to construct queries against virtual databases. It supports joins, aggregations (sum, count), filters, and can be used both in Node.js (via require) and in the browser (via a bundled script). Release cadence is not specified; the library is currently in early development. Key differentiators: privacy-preserving SQL layer over N1 analytics.

npm install n1-sql
INSTALL
IMPORT
SIG · N1-SQL
N
n1-sql
databasejavascriptv0.1.8
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.

n1_sql
import n1_sql from 'n1-sql'
const n1_sql = require('n1-sql');
The default export is a function. Both ESM and CommonJS are supported, but the README shows require style.
N1Sql (browser global)
<!-- in HTML --> <script src="n1-sql.js"></script> <!-- then use window.N1Sql -->
In browser, the library sets a global variable N1Sql. No module imports.
Immutable (peer)
import Immutable from 'immutable'
Immutable.js is a peer dependency often used alongside n1-sql for immutable data structures.

Connects to an N1 SQL service, selects two tables from a virtual database, joins them on id, sums spend from dp2, filters age > 40, and prints the result rows.

const n1_sql = require('n1-sql'); n1_sql('http://localhost:9000') .vdbs('mock-20') .useTable('dp1', 'orgA.t') .useTable('dp2', 'orgB.t') .join(c => c.column('dp1.id').eq().column('dp2.id')) .selectSum('dp2.spend', 'spend') .where(c => c.column('dp1.age').gt(40)) .exec().then(j => { console.info(j.rows); });
Debug
Known issues
gotchaThe library requires immutable.js as a dependency. Not installing it will cause runtime errors.
fix
Run: npm install immutable
affects: >=0.1.0
gotchaThe exec() method returns a promise. Omitting .then() or await will result in unhandled promise rejection.
fix
Always handle the promise: .exec().then(...) or await n1_sql(...).exec()
affects: >=0.1.0
gotchaThe library uses a fluent API that returns new immutable contexts. Modifying a context or reusing it after mutation may lead to unexpected behavior.
fix
Treat each method call as creating a new query plan. Do not reuse the same context after calling exec().
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'immutable'
Missing immutable dependency.
fix
Run: npm install immutable
TypeError: n1_sql is not a function
Incorrect import style (e.g., using named import instead of default).
fix
Use: const n1_sql = require('n1-sql'); or import n1_sql from 'n1-sql';
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'rows' of undefined
The promise from exec() was not awaited or .then() was omitted, and the client tried to access j.rows before the promise resolved.
fix
Add .then(j => {...}) or use await.
Upgrade
Version history
0.1.8latest on npm
Audit
Dependencies
immutablerequiredRequired for the functional/immutable API patterns used throughout the library.
Agent activity
4 hits · last 30 days
node
4
Resources
packagen1-sql
n1-sql — npm install n1-sql · libregistry