Registry / database / node-crate

node-crate

JSON →
library3.0.0jsnpmunverified

An independent Node.js SQL driver for CrateDB using the _sql endpoint REST API. Currently at version 3.0.0, it provides an async interface with conversion from rows to JSON entities, automatic SQL building from JSON, and BLOB support. Key differentiators include its lightweight, REST-based approach compared to the official CrateDB JDBC driver, and built-in support for CrateDB's BLOB storage.

npm install node-crate
INSTALL
IMPORT
SIG · NODE-CRATE
N
node-crate
databasejavascriptv3.0.0
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.

crate
const crate = require('node-crate');
import crate from 'node-crate';
v3 is CJS only; ESM import not supported
crate
import * as crate from 'node-crate';
import crate from 'node-crate';
If using TypeScript/ESM, use namespace import; default import fails
type constants
crate.type.TIMESTAMP
Type constants are accessed via crate.type.TIMESTAMP

Connect to CrateDB on localhost:4200 and execute a quick query to list cluster nodes.

const crate = require('node-crate'); crate.connect('localhost', 4200); crate.execute("select * from sys.nodes").then((res) => { console.log(res.json, res.duration, res.rowcount); }).catch((err) => { console.error('Query failed', err); });
Debug
Known issues
breakingVersion 2+ uses native Promises instead of D.js. Callbacks .success()/.error() removed.
fix
Replace .success(fn) with .then(fn) and .error(fn) with .catch(fn).
affects: >=2.0.0
breakingRequires Node.js >=6.0.0 due to ES6 features.
fix
Upgrade Node.js to version 6.0.0 or higher.
affects: >=2.0.0
gotchaNested JSON objects are not supported for automatic SQL generation (e.g., insert/update).
fix
Use manual SQL execution with placeholders for nested fields.
affects: >=0.0.0
deprecatedBLOB support may be deprecated; not actively maintained for newer CrateDB versions.
fix
Use the CrateDB HTTP BLOB API directly if needed.
affects: >=2.0.0
gotchaUses REST endpoint _sql; performance may degrade for high-frequency queries compared to binary protocol.
fix
Consider using official CrateDB client if throughput is critical.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'node-crate'
Package not installed or incorrect import path.
fix
Run `npm install node-crate` and ensure require/import matches CJS or ESM pattern.
crate.execute is not a function
Using wrong import variant (e.g., default import instead of require).
fix
Use `const crate = require('node-crate');` or `import * as crate from 'node-crate';`
response is not iterable
Using .success()/.error() pattern from v1.
fix
Replace with .then().catch() promise chain.
connect ECONNREFUSED 127.0.0.1:4200
CrateDB not running or wrong host/port.
fix
Ensure CrateDB is started on localhost:4200, or adjust connection parameters.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
node-crate — npm install node-crate · libregistry