backbone-db-mongodb
Advanced tools
Comparing version 0.2.19 to 0.2.20
@@ -319,4 +319,3 @@ var _ = require('lodash'), | ||
function(err, res) { | ||
callback(err, res || options.ignoreFailures ? 1 : res); | ||
callback(err, res || options.ignoreFailures ? {} : res); | ||
} | ||
@@ -323,0 +322,0 @@ ); |
{ | ||
"name": "backbone-db-mongodb", | ||
"version": "0.2.19", | ||
"version": "0.2.20", | ||
"description": "MongoDB driver for Backbone.Db", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -127,2 +127,4 @@ var setup = require('./setup'); | ||
ignoreFailures: true | ||
}).then(function(res) { | ||
assert.equal(typeof res, 'object'); | ||
}); | ||
@@ -129,0 +131,0 @@ }); |
@@ -355,7 +355,7 @@ var setup = require('./setup'); | ||
it('should fetch models with before_id and -created_at sort & limit (1)', function() { | ||
it('should fetch models with before_id (2) and -created_at sort & limit (1)', function() { | ||
var opts = { | ||
sort: '-created_at', | ||
limit: 1, | ||
before_id: 1 | ||
before_id: 2 | ||
}; | ||
@@ -366,3 +366,3 @@ return collection | ||
assert.equal(collection.length, 1); | ||
assert(collection.at(0).id === 2); | ||
assert(collection.at(0).id === 3); | ||
}); | ||
@@ -417,2 +417,24 @@ }); | ||
it('should page through models with after_id and -created_at sort & limit (1)', function() { | ||
var opts = { | ||
sort: '-created_at' | ||
}; | ||
return collection | ||
.fetch(opts) | ||
.then(function() { | ||
assert(collection.at(0).id === 4); | ||
assert(collection.at(1).id === 3); | ||
assert(collection.at(2).id === 2); | ||
assert(collection.at(3).id === 1); | ||
return collection.fetch({ | ||
sort: opts.sort, | ||
limit: 1, | ||
after_id: 3 | ||
}).then(function() { | ||
assert(collection.at(0).id === 2); | ||
}); | ||
}); | ||
}); | ||
it('should fetch collections first page sorted descending', function() { | ||
@@ -419,0 +441,0 @@ var opts = { |
36040
13
1051