pouchdb / gql Goto Github PK
View Code? Open in Web Editor NEWGoogle Query Language (GQL) interface for PouchDB
Home Page: http://pouchdb.com
Google Query Language (GQL) interface for PouchDB
Home Page: http://pouchdb.com
for ex. name like 'mario' or like '%mario%'
is it there?
i am trying to use GQL plugin using inline javascript in a html file
but i am keep on getting this error "Uncaught TypeError: undefined is not a function "
can you please post a working example for GQL plugin
many thanks
The following test (from my pull request #4), when not commented out, fails. The query never returns, and the test times out. Disabled the timeout and waited several minutes - it still didn't return.
+ /* ------------ test is failing - never returns ------------- */ + // it("should return count aggregation for group by clause", function(done) { + // //this.timeout(0); + // var query = {select: "average(salary), isSenior", groupBy: "isSenior"}; + // //var query = "select lunchTime, count(age) group by isSenior"; + // var expected = [{"lunchTime": "12:00:00", "count-age": "2"}, + // {"lunchTime": "13:00:00", "count-age": "1"}, + // {"lunchTime": "12:00:00", "count-age": "2"}]; + // + // PouchDB.plugin('gql', GQL); + // PouchDB('testdb',function(err,db){ + // db.gql(query, function(err, actual){ + // if(!err){ + // var intersection = expected.filter(function(n) { + // return _.findWhere(actual.rows, n) != undefined + // }); + // console.log(" "); + // for (var i=0; i< actual.rows.length; i++) { + // console.log(actual.rows[i]); + // } + // expect(intersection).to.have.length(expected.length); + // expect(actual.rows.length).to.equal(expected.length); + // done(); + // } + // }); + // }); + // });
PouchDB seems to be fine with case sensitivity but GQL apparently only works with lower case properties.
This seems to come down to the handleDelimitedCharacters
function which performs a toLowerCase
on the query input.
I don't see the benefit of performing the lower case transformation and think it should be removed.
running npm test --coverage
we are at
================== Coverage summary ==================
Statements : 53.61% ( 267/498 )
Branches : 36.84% ( 98/266 )
Functions : 48.84% ( 63/129 )
Lines : 53.61% ( 267/498 )
====================================================
Would be nice if this worked with persisted map/reduce. Not sure what the GQL interface for working with indexes looks like, but it would be a great performance boost compared to using the changes()
API.
Aggregate select test fails (reference file test/test.js for full context, this test is there but commented out). Error differs depending on the group-by column.
name
(which is distinct, so the aggregation is a no-op) and the error is 'Uncaught.'isSenior
and the error message, 'Error: If an aggregation function is used in the select clause, all identifiers in the select clause must be wrapped by an aggregation function or appear in the group-by clause.' is invalid relative to the actual query.
it("should return average aggregation for group by clause", function(done) {
//var query = {select: "name, average(salary)", groupBy: "name"}; //- error is 'Uncaught'
var query = {select: "isSenior, average(salary)", groupBy: "isSenior"};
//- error is 'Error: If an aggregation function is used in the select clause, all identifiers in the select clause must be wrapped by an aggregation function or appear in the group-by clause.'
var expected = [{"isSenior": true, "average-salary": "2"},
{"isSenior": false, "average-salary": "1"}];
PouchDB.plugin('gql', GQL);
PouchDB('testdb',function(err,db){
db.gql(query, function(err, actual){
if(!err){
var intersection = expected.filter(function(n) {
return _.findWhere(actual.rows, n) != undefined
});
console.log(' ');
for (var i=0; i< actual.rows.length; i++) {
console.log(actual.rows[i]);
}
expect(intersection).to.have.length(expected.length);
expect(actual.rows.length).to.equal(expected.length);
done();
} else {
console.log(err);
done(new Error(err.reason));
}
});
});
});
Im building an android app with cordova, and after installing GQL plugin using 'bower install pouchdb-gql' and then including the 'dist/pouchdb.gql.js' in the head of my index, I am getting the error 'db.gql is not a function' when I try to execute a query.
Anyone know what is wrong? Is this plugin still maintained?
Edit: Seen last commit mid 2014. This plugin should be reviewed
there is some room to bring more functions that don't require closures out of the body of other functions, and also some stuff is repeated (operators at first glance) this stuff can be deduped, possibly into their own file.
we need to add tests, wrap it in a umd, and make it available at least via npm
It's not clear from the docs that this has to loop through all the documents in memory. I know it was written at a time when persisted map/reduce didn't exist and so it didn't have the option, but I think people are stumbling across it and not understanding the performance costs.
The following test, from my pull request (see #4). when not commented out, fails. The value of the 'lunchTime' property is null in each returned row. This is not the case when selecting all columns, i.e. select '*'
I suspect it's related to the embedded colons, but it may be that it's attempting to parse the values as number and failing.
/* ------------ test is failing - lunchTime column is returned as null ------------- */ + // it("should return selected columns when one column is a time representation", function(done) { + // var query = {select: "lunchTime, name"}; + // var expected = [{"lunchTime": "12:00:00", "name": "John"}, + // {"lunchTime": "12:00:00", "name": "Dave"}, + // {"lunchTime": "13:00:00", "name": "Sally"}, + // {"lunchTime": "12:00:00", "name": "Ben"}, + // {"lunchTime": "12:00:00", "name": "Dana"}, + // {"lunchTime": "13:00:00", "name": "Mike"}]; + // + // PouchDB.plugin('gql', GQL); + // PouchDB('testdb',function(err,db){ + // db.gql(query, function(err, actual){ + // if(!err){ + // var intersection = expected.filter(function(n) { + // return _.findWhere(actual.rows, n) != undefined + // }); + // console.log(" "); + // for (var i=0; i< actual.rows.length; i++) { + // console.log(actual.rows[i]); + // } + // expect(intersection).to.have.length(expected.length); + // expect(actual.rows.length).to.equal(expected.length); + // done(); + // } else { + // done(err); + // } + // }); + // }); + // });
The version that I get from npm seems like is using the v1 plugin API.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.