Skip to content

Commit

Permalink
Merge pull request #74 from silvolu/master
Browse files Browse the repository at this point in the history
TEST(datastore): add regression test for filtering by key.
  • Loading branch information
Burcu Dogan committed Aug 1, 2014
2 parents 83f1a37 + f2b26dc commit 9103b60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ var q = ds.createQuery('Company')
.filter('size <', 400);
~~~~

To filter by key, use `__key__` for the property name. Filtering on keys
stored as properties is not currently supported.

~~~~ js
var q = ds.createQuery('Company')
.filter('__key__ =', ['Company', 'Google'])
~~~~

In order to filter by ancestors, use `hasAncestor` helper.

~~~ js
Expand Down
10 changes: 10 additions & 0 deletions regression/datastore.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ describe('datastore', function() {
});
});

it('should filter by key', function(done) {
var q = ds.createQuery('Character')
.filter('__key__ =', ['Character', 'Rickard']);
ds.runQuery(q, function(err, keys, objs, nextQuery) {
if (err) return done(err);
assert.equal(objs.length, 1);
done();
});
});

it('should order queries', function(done) {
var q = ds.createQuery('Character').order('+appearances');
ds.runQuery(q, function(err, keys, objs, nextQuery) {
Expand Down

0 comments on commit 9103b60

Please sign in to comment.