Registry / database / jsonquery

jsonquery

JSON →
library0.2.0jsnpmunverified

Node.js streaming filter that implements MongoDB query language for filtering JSON documents in a pipeline. Stable version 0.2.0, with low release cadence (last release years ago). Differentiators: lightweight, streams-based, supports full MongoDB query syntax including $and, $or, $gt, $in, etc. Use with any readable stream of JSON objects, commonly paired with levelup/leveldb. Alternatives like mongodb native driver are heavier and not stream-oriented.

npm install jsonquery
INSTALL
IMPORT
SIG · JSONQUERY
J
jsonquery
databasejavascriptv0.2.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.

jsonquery
var jsonquery = require('jsonquery');
import jsonquery from 'jsonquery';
CJS only; no default export for ESM. Use require.
Stream
const stream = require('jsonquery')({...});
const stream = new jsonquery({...});
jsonquery returns a Transform stream, not a constructor that requires 'new'.
Filter function
var jsonquery = require('jsonquery'); var filter = jsonquery({ query });
const { filter } = require('jsonquery');
jsonquery exports a factory function, not named exports.

Creates a readable stream of objects, pipes through jsonquery filter, and logs matched documents.

var jsonquery = require('jsonquery'); var stream = require('stream'); var input = new stream.Readable({ objectMode: true }); input._read = function() {}; // no-op var counter = 0; input .pipe(jsonquery({ val: { $gte: 50 } })) .on('data', function(doc) { console.log('Matched:', doc); counter++; }) .on('end', function() { console.log('Total matches:', counter); }); input.push({ val: 30 }); input.push({ val: 70 }); input.push(null);
Debug
Known issues
gotchajsonquery expects objectMode streams; piping non-objectMode streams will cause unexpected behavior (raw buffers).
fix
Ensure both input and output streams use objectMode: true.
affects: >=0.1.0
deprecatednpm package 'jsonquery' has had no updates for many years; the query syntax may not cover all MongoDB operators (e.g., $geoNear, $expr).
fix
For modern MongoDB query needs, consider using the official mongodb driver or a more maintained library.
affects: 0.2.0
gotchaThe returned stream is a Transform that pushes matched objects; it does not validate input objects, so malformed JSON may cause runtime errors.
fix
Ensure source stream outputs valid JavaScript objects with expected property types.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read property 'pipe' of undefined
Calling jsonquery() without arguments or with non-function arguments results in undefined factory.
fix
Always call jsonquery(queryObject) where queryObject is a valid MongoDB query object.
stream.push() after EOF
Pushing data after ending the readable stream.
fix
Call input.push(null) only after all data has been enqueued, not before.
Error: .pipe() called with non-stream
Piping into jsonquery result before calling jsonquery() (i.e., using require('jsonquery') as a stream).
fix
Assign jsonquery(query) to a variable first: var filter = jsonquery(query); source.pipe(filter);
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
jsonquery — npm install jsonquery · libregistry