All Projects → mongodb-js → query-parser

mongodb-js / query-parser

Licence: Apache-2.0 license
Safe parsing and validation for MongoDB queries (filters), projections, and more.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to query-parser

mongodb-schema
Infer a probabilistic schema for a MongoDB collection.
Stars: ✭ 106 (+278.57%)
Mutual labels:  mongodb-cli, compass-tools
Noproto
Flexible, Fast & Compact Serialization with RPC
Stars: ✭ 138 (+392.86%)
Mutual labels:  bson
Objcmongodb
Mac OS and iOS library for MongoDB and BSON
Stars: ✭ 166 (+492.86%)
Mutual labels:  bson
BSON
Native Swift library for BSON (http://bsonspec.org)
Stars: ✭ 98 (+250%)
Mutual labels:  bson
Bson4jackson
A pluggable BSON generator and parser for the Jackson JSON processor.
Stars: ✭ 244 (+771.43%)
Mutual labels:  bson
querqy-elasticsearch
Querqy for Elasticsearch
Stars: ✭ 37 (+32.14%)
Mutual labels:  query-parser
flatbson
Recursively flatten a Go struct using its BSON tags
Stars: ✭ 54 (+92.86%)
Mutual labels:  bson
electron-license
Tools for electron apps to work with licenses.
Stars: ✭ 18 (-35.71%)
Mutual labels:  compass-tools
magnet
A JSON/BSON schema generator
Stars: ✭ 16 (-42.86%)
Mutual labels:  bson
nason
🗜 Ultra tiny serializer / encoder with plugin-support. Useful to build binary files containing images, strings, numbers and more!
Stars: ✭ 30 (+7.14%)
Mutual labels:  bson
X2struct
Convert between json string and c++ object. json字符串和c++结构体之间互相转换
Stars: ✭ 251 (+796.43%)
Mutual labels:  bson
undatum
undatum: a command-line tool for data processing. Brings CSV simplicity to JSON lines and BSON
Stars: ✭ 39 (+39.29%)
Mutual labels:  bson
python-bsonjs
A fast BSON to MongoDB Extended JSON converter for Python - This Repository is NOT a supported MongoDB product
Stars: ✭ 35 (+25%)
Mutual labels:  bson
Mgodatagen
Generate random data for MongoDB
Stars: ✭ 206 (+635.71%)
Mutual labels:  bson
bafi
Universal JSON, BSON, YAML, CSV, XML converter with templates
Stars: ✭ 65 (+132.14%)
Mutual labels:  bson
Mongo Kafka
MongoDB Kafka Connector
Stars: ✭ 166 (+492.86%)
Mutual labels:  bson
transfer
Converts from one encoding to another. Supported formats HCL ⇄ JSON ⇄ YAML⇄TOML⇄XML⇄plist⇄pickle⇄properties ...
Stars: ✭ 70 (+150%)
Mutual labels:  bson
bsoncodec
Collection of org.bson.codecs.Codec implementations for MongoDB
Stars: ✭ 18 (-35.71%)
Mutual labels:  bson
uri-query-parser
a parser and a builder to work with URI query string the right way in PHP
Stars: ✭ 38 (+35.71%)
Mutual labels:  query-parser
mongodb-language-model
Parses MongoDB query language and creates hierarchical Ampersand.js models to interact with the query tree
Stars: ✭ 26 (-7.14%)
Mutual labels:  compass-tools

mongodb-query-parser Check and Test npm

Safe parsing and validation for MongoDB queries (filters), projections, and more.

Example

Turn some JS code as a string into a real JS object safely and with no bson type loss:

require('mongodb-query-parser')('{_id: ObjectId("58c33a794d08b991e3648fd2")}');
// >>> {_id: ObjectId('58c33a794d08b991e3648fd2'x)}

Usage with codemirror

var parser = require('mongodb-query-parser');
var query = '{_id: ObjectId("58c33a794d08b991e3648fd2")}';
// What is this highlighting/language mode for this string?
parser.detect(query);
// >>> `javascript`

var queryAsJSON = '{"_id":{"$oid":"58c33a794d08b991e3648fd2"}}';
// What is this highlighting/language mode for this string?
parser.detect(queryAsJSON);
// >>> `json`

// Turn it into a JS string that looks pretty in codemirror:
parser.toJavascriptString(parse(query));
// >>> '{_id:ObjectId(\'58c33a794d08b991e3648fd2\')}'

Extended JSON Support

var parser = require('mongodb-query-parser');
var EJSON = require('mongodb-extended-json');
var queryAsAnObjectWithTypes = parser.parseFilter(query);

// Use extended json to prove types are intact
EJSON.stringify(queryAsAnObjectWithTypes);
// >>> '{"_id":{"$oid":"58c33a794d08b991e3648fd2"}}'

var queryAsJSON = '{"_id":{"$oid":"58c33a794d08b991e3648fd2"}}';
parser.detect(queryAsJSON);
// >>> `json`

Migrations

We aim to not have any API breaking changes in this library as we consider it stable, but breakages may occur whenever we upgrade a core dependency or perform a major refactor.

We have a migration guide which covers what to look out for between releases.

Related

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].