Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
mongodb-language-model
Advanced tools
Readme
Parses a MongoDB query and creates an abstract syntax tree (AST) with part of speech tagging. Currently, only strict extended json syntax is supported (which means keys have to be surrounded by double quotes and values have to match the strict syntax of the extended-json format.);
The main module exposes two functions: accepts(queryStr)
and parse(queryStr)
.
accepts(queryStr)
The accepts(queryStr)
function takes a query string and returns true
if the
string is a valid MongoDB query, false
otherwise.
Example:
var accepts = require('mongodb-language-model').accepts;
var assert = require('assert');
assert.ok(accepts('{"foo": 1}'));
assert.ok(accepts('{"age": {"$gt": 35}}'));
assert.ok(accepts('{"$or": [{"email": {"$exists": true}}, {"phone": {"$exists": true}}]}'));
assert.equal(accepts('{"$invalid": "key"}'), false);
parse(queryStr)
The parse(queryStr)
function takes a query string and returns an abstract
syntax tree (AST) as a javascript object, if the query is valid. If the
query is not valid, the function throws a pegjs.SyntaxError
with a message
explaining the failure.
Example:
var parse = require('mongodb-language-model').parse;
var assert = require('assert');
var pegjs = require('pegjs');
var ast = parse('{"foo": "bar"}');
assert.deepEqual(ast, {
'pos': 'expression',
'clauses': [
{
'pos': 'leaf-clause',
'key': 'foo',
'value': {
'pos': 'leaf-value',
'value': 'bar'
}
}
]
});
This is the hierarchical model that is created when a query is parsed:
npm install --save mongodb-language-model
npm test
FAQs
Parses MongoDB query language and returns an abstract syntax tree
The npm package mongodb-language-model receives a total of 5,358 weekly downloads. As such, mongodb-language-model popularity was classified as popular.
We found that mongodb-language-model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 28 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.