Giter VIP home page Giter VIP logo

jsonquery's Introduction

jsonquery

MongoDB query language implemented as a Streaming filter.

This library implements the entire MongoDB query language as a node.js filtering stream;

build status

Installation

To install, use npm:

$ npm install jsonquery

Examples

Here's an example of usage:

var jsonquery = require('jsonquery');

var count = 0;
generator(100) // a readable stream that outputs JSON documents
  .pipe(jsonquery({ val: { $and: [ { $gt: 970 }, { $gt: 950 } ] } })) // filter
  .on('data', function (doc) {
    expect(doc.val).to.be.above(970);
    expect(doc.val).to.be.above(950);
    count++;
  })
  .on('end', function () {
    expect(count).to.equal(2);
  });

jsonquery's People

Contributors

eugeneware avatar mikebild avatar nrw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jsonquery's Issues

$elemMatch not matching

Hi Eugene,

Thanks for the module!

I have a query regarding $elemMatch condition. I have an input JSON object represented something like:

{
    users : [
        {
            name : 'john doe'
        }
    ]
}

My JSON query looks like:

{
    users : {
        $elemMatch : {
            name : 'john doe'
        }
    }
}

However, this isn't matching the input object at present, even though is a valid matching MongoDB query. Any ideas?

Thanks.

level-search

hi,

I just noticed this module yesterday,
which was exciting, because I had just implemented a
search api for level.

basically, each pair of keys in every document are indexed:

{ name: 'foo',
  repository: { type: 'git', url: 'https://github.com/foofoo/foo.git'},
  dependencies: {
    bar: '1.0.0'
  }
}

would index that file by the pairs:

name foo
repository type
repository url
type git
url https://github.com/dominictarr/level-search
dependencies bar
bar 1.0.0

this makes it possible to do nearly any search,
you could probably get really clever, but as a first step,
I just search on the pair that seems the least likely,
and then filter.

is there a way to get the keys involved in the query from jsonquery so that I could combine it with level-search?

value constructor doesn't match

In my case (OSX nodejs v0.10.33) in line 58 v.constructor === Object doesn't match against query

{ id: { $exists: true }}

My fix

(v.constructor === Object || typeof v === 'object')

Can you reproduce this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.