Socket
Book a DemoInstallSign in
Socket

monquery

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monquery

mongo query language for humans inspired by Lucene

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
90
45.16%
Maintainers
1
Weekly downloads
 
Created
Source

monquery

Lucene-inspired string-based mongodb query language for humans (and ferrets).

Installation

$ npm install monquery

Why?

  • Nicer UX for the odd search / log filtering
  • Writing JSON queries is a PITA

Example

var compile = require('monquery');
var str = 'level:error OR type:upload';
var query = compile(str);

Querying

Fields

Specify field names with optional values:

level:error

yields

{ level: 'error' }

Booleans

Omit value to imply true:

failed

yields

{ failed: true }

Or specify a boolean-ish value (true, false, yes, no):

failed: no

yields

{ failed: false }

Operators

Currently supports AND / OR, which may be nested:

(level:error AND type:"upload failed") OR user.name.first:Tobi

yields

{ '$or':
   [ { '$and': [ { level: 'error' }, { type: 'upload failed' } ] },
     { 'user.name.first': 'Tobi' } ] }

Regular Expressions

Regexps may be used with the // syntax:

level:info AND name:/^To/

yields

{ '$and': [ { level: 'info' }, { name: /^To/ } ] }

Patterns

Wildcards may be used to generate regular expressions:

level:error AND hostname:api-*

yields

{ '$and': [ { level: 'error' }, { hostname: /^api-.*$/ } ] }

License

MIT

Keywords

lucene

FAQs

Package last updated on 11 Oct 2014

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