Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
#*#
node_modules
24 changes: 24 additions & 0 deletions test/query.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var expect = require('expect.js');
var async = require('async');
var Backend = require('sharedb').Backend;

// Call this function inside a `describe` block. Assumes that
// `this.db` is set to be a ShareDB instance that supports certain
Expand Down Expand Up @@ -28,6 +29,29 @@ module.exports = function() {
});
});

it('$count with createSubscribeQuery', function(done) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put in separate describe block

var connection = new Backend({db: this.db}) .connect();
async.parallel([
function(cb) { connection.get('testcollection', 'test1').create({x: 1, y: 1}, cb); },
function(cb) { connection.get('testcollection', 'test2').create({x: 2, y: 2}, cb); },
function(cb) { connection.get('testcollection', 'test3').create({x: 3, y: 2}, cb); }
], function(err) {
var query = {$count: true, y: 2};
if (err) return done(err);
var query = connection.createSubscribeQuery('testcollection', query, null, function(err, results, extra) {
if (err) return done(err);

expect(results).eql([]);
expect(extra).eql(2);
connection.get('testcollection', 'test3').submitOp({p: ['y'], na: 1});
});
query.on('extra', function(extra) {
expect(extra).eql(1);
done();
});
});
});

it('$sort, $skip and $limit should order, skip and limit', function(done) {
var snapshots = [
{type: 'json0', v: 1, data: {x: 1}, id: "test1"},
Expand Down