Browse Source

Add the cursor.size method

saintedlama/travis-non-legacy
Eduardo Sorribas 11 years ago
parent
commit
4de6a44805
  1. 4
      index.js
  2. 21
      tests/test-cursor-size.js

4
index.js

@ -95,6 +95,10 @@ Cursor.prototype.map = function(mapfn, callback) {
});
};
Cursor.prototype.size = function(callback) {
this.count(true, callback);
};
Cursor.prototype._apply = function(fn, args) {
this._get(function(err, cursor) {
if (err) return getCallback(args)(err);

21
tests/test-cursor-size.js

@ -0,0 +1,21 @@
var assert = require('assert');
var insert = require('./insert');
insert([{
hello:'world1'
},{
hello:'world2'
},{
hello:'world3'
},{
hello:'world4'
}], function(db, done) {
db.a.find().skip(1).size(function(err, thesize) {
assert.equal(thesize, 3);
db.a.find().limit(2).size(function(err, theothersize) {
assert.equal(theothersize, 2);
done();
});
});
});
Loading…
Cancel
Save