Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizFelipeNeves committed Aug 26, 2019
1 parent 1c04d7c commit ce8aed6
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions graphql/resolvers/Freight/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,31 @@ export default {
const conditions = { ...resto };
if (vehicles) conditions.vehicles = { vehicles: { $in: vehicles } };
if (bodies) conditions.bodies = { bodies: { $in: bodies } };
const res = await Freight.aggregate([
{
$geoNear: {
near: { type: "Point", coordinates },
distanceField: "dist.calculated",
spherical: true,
key: "origin.location",
includeLocs: "location",
maxDistance: range,
query: conditions
}
},
...freightquery,
{ $skip: (page - 1) * perpage },
{ $limit: perpage }
const list = await Freight.aggregate([
...freightquery
// { $out: "aggr_out" }
]).exec();

console.log(list);

const res = await list
.aggregate(
{
$geoNear: {
near: { type: "Point", coordinates },
distanceField: "dist.calculated",
spherical: true,
key: "origin.location",
// includeLocs: "location",
maxDistance: range,
query: conditions
}
},
{ $skip: (page - 1) * perpage },
{ $limit: perpage }
)
.exec();

return freightfinalquery(res, conditions, page, perpage);
}
},
Expand Down

0 comments on commit ce8aed6

Please sign in to comment.