diff --git a/README.md b/README.md index 5cd5472dd5e..6a120370f76 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/regression/datastore.js b/regression/datastore.js index eb7c50ea656..8db08131ee6 100644 --- a/regression/datastore.js +++ b/regression/datastore.js @@ -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) {