🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

mongodb-query-parser

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-query-parser

Parse MongoDB queries

0.1.0
Source
npm
Version published
Weekly downloads
121K
152.43%
Maintainers
1
Weekly downloads
 
Created
Source

mongodb-query-parser travis npm

Parse MongoDB queries

Example

var parse = require('mongodb-query-parser');
var query = '{_id: ObjectId("58c33a794d08b991e3648fd2")}';

// What is this highlighting/language mode for this string?
parse.detect(query);

// >>> `javascript`

// Turn some JS code as a string into a real JS object safely and with no bson type loss.
var EJSON = require('mongodb-extended-json');
var queryAsAnObjectWithTypes = parse(query);

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

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

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

License

Apache 2.0

FAQs

Package last updated on 13 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts