I am using nodejs mongodb. Here is my code:
var deferred = defer();
User.find({
_id: id
}).then(data => {
User.aggregate([
{
$geoNear: {
near: [data[0].loc[0], data[0].loc[1]],
spherical: true,
distanceField: "dis",
maxDistance : 1000/6378137,
distanceMultiplier: 6378137
}
},{ "$sort": { "dis": 1}}
]).then(count => {
User.aggregate([
{
$geoNear: {
near: [data[0].loc[0], data[0].loc[1]],
spherical: true,
distanceField: "dis",
maxDistance : 1000/6378137,
distanceMultiplier: 6378137
}
},{ "$sort": { "dis": 1}},
{$limit : 1},
{$skip : 1}
]).then(result => {
deferred.resolve({
count: count.length/2,
result: result
})
}, err=> {
console.log(err);
})
}, err=> {
console.log(err);
})
})
The problem is when skip and limit are equal I get empty query. As I understand limit shows number per page. What is problem here?
via Vahe Akhsakhalyan
No comments:
Post a Comment