Skip to content

Commit ce8aed6

Browse files
Update index.js
1 parent 1c04d7c commit ce8aed6

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

graphql/resolvers/Freight/index.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,31 @@ export default {
130130
const conditions = { ...resto };
131131
if (vehicles) conditions.vehicles = { vehicles: { $in: vehicles } };
132132
if (bodies) conditions.bodies = { bodies: { $in: bodies } };
133-
const res = await Freight.aggregate([
134-
{
135-
$geoNear: {
136-
near: { type: "Point", coordinates },
137-
distanceField: "dist.calculated",
138-
spherical: true,
139-
key: "origin.location",
140-
includeLocs: "location",
141-
maxDistance: range,
142-
query: conditions
143-
}
144-
},
145-
...freightquery,
146-
{ $skip: (page - 1) * perpage },
147-
{ $limit: perpage }
133+
const list = await Freight.aggregate([
134+
...freightquery
135+
// { $out: "aggr_out" }
148136
]).exec();
137+
138+
console.log(list);
139+
140+
const res = await list
141+
.aggregate(
142+
{
143+
$geoNear: {
144+
near: { type: "Point", coordinates },
145+
distanceField: "dist.calculated",
146+
spherical: true,
147+
key: "origin.location",
148+
// includeLocs: "location",
149+
maxDistance: range,
150+
query: conditions
151+
}
152+
},
153+
{ $skip: (page - 1) * perpage },
154+
{ $limit: perpage }
155+
)
156+
.exec();
157+
149158
return freightfinalquery(res, conditions, page, perpage);
150159
}
151160
},

0 commit comments

Comments
 (0)