mongo-control
Advanced tools
Comparing version 1.0.68 to 1.0.69
@@ -477,2 +477,4 @@ var MongoClient = require('mongodb').MongoClient | ||
if (params.query) { | ||
@@ -496,7 +498,20 @@ if (typeof params.query === 'string') { | ||
var query = { | ||
$and: [params.query] | ||
} | ||
if(params.next) { | ||
params.query._id = {$gt: new ObjectID(params.next)} | ||
var nextObj = {$or: [{$gt: params.next}]} | ||
if(reMongoId.test(params.next)) { | ||
nextObj.$or.push({$gt: new ObjectID(params.next)}) | ||
} | ||
query.$and.push(nextObj) | ||
params.limit = 1 | ||
} else if(params.prev) { | ||
params.query._id = {$lt: new ObjectID(params.prev)} | ||
var prevObj = {$or: [{$lt: params.prev}]} | ||
if(reMongoId.test(params.prev)) { | ||
prevObj.$or.push({$lt: new ObjectID(params.prev)}) | ||
} | ||
query.$and.push(prevObj) | ||
params.limit = 1 | ||
@@ -523,3 +538,3 @@ params.sortBy = {_id: -1} | ||
db.collection(params.collection).find(params.query, params.projection).sort(params.sortBy).limit(params.limit).toArray(function (e, docs) { | ||
db.collection(params.collection).find(query, params.projection).sort(params.sortBy).limit(params.limit).toArray(function (e, docs) { | ||
if (e) return err(e) | ||
@@ -526,0 +541,0 @@ |
{ | ||
"name": "mongo-control", | ||
"version": "1.0.68", | ||
"version": "1.0.69", | ||
"description": "Simple functions to control mongo", | ||
@@ -5,0 +5,0 @@ "main": "mongo.control.js", |
30707
969