eugeneware / jsonquery-engine

A full MongoDB query language implementation with INDEXES for querying your levelup/leveldb database.
55 stars 5 forks source link

operator $in not working? #5

Open hems opened 9 years ago

hems commented 9 years ago
var db, jsonqueryEngine, levelQuery, levelup, pairs;

levelQuery = require('level-queryengine');

jsonqueryEngine = require('jsonquery-engine');

pairs = require('pairs');

levelup = require('levelup');

db = levelQuery(levelup("./db", {
  valueEncoding: 'json'
}));

db.query.use(jsonqueryEngine());

db.ensureIndex('Id');

then if i execute:

dbl.query( { Id: 1 } ).on( "data", function(data){ console.log( "got data", data); } ).on( "end", function(){console.log( "end" )});

i get one result on "data"

but if i execute:

dbl.query( { Id: { $in: [1] } } ).on( "data", function(data){ console.log( "got data", data); } ).on( "end", function(){console.log( "end" )});

only the "end" event is being triggered.

any ideas?

hems commented 9 years ago

cloning the repository and running the tests works, but for some reason it seems that with the data i inserted on my test the operator $in doesn't work although querying for Id works.

eugeneware commented 9 years ago

Did you make sure that the indexing engine installed before inserting the data? Your code example didn't cover the inserting behaviour.

hems commented 9 years ago

by the index engine, you mean having

db.query.use(jsonqueryEngine());

db.ensureIndex('Id');

before inserting?

eugeneware commented 9 years ago

Yes. When are you inserting your data? The indexers need to be installed before data is inserted.

See the test cases for an example: https://github.com/eugeneware/jsonquery-engine/blob/master/test/level-plan.js#L199-L207

hems commented 9 years ago

everything works now.

still i have an issue that when i hit a db with "jsonquery engine" it seems to load the whole thing ( couple hundreds mb of data ) into memory ( not only indexes ) and it's freezing the UI of my app..