Skip to content

Commit 1c04d7c

Browse files
fix index
1 parent a0b7d34 commit 1c04d7c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

graphql/resolvers/Freight/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,18 @@ export default {
131131
if (vehicles) conditions.vehicles = { vehicles: { $in: vehicles } };
132132
if (bodies) conditions.bodies = { bodies: { $in: bodies } };
133133
const res = await Freight.aggregate([
134-
...freightquery,
135-
{ $match: conditions },
136-
/*{
134+
{
137135
$geoNear: {
138136
near: { type: "Point", coordinates },
139137
distanceField: "dist.calculated",
140138
spherical: true,
141139
key: "origin.location",
142-
maxDistance: range
140+
includeLocs: "location",
141+
maxDistance: range,
142+
query: conditions
143143
}
144-
},*/
144+
},
145+
...freightquery,
145146
{ $skip: (page - 1) * perpage },
146147
{ $limit: perpage }
147148
]).exec();

server/models/Location.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ const LocSchema = new Schema({
4141
}
4242
});
4343

44-
LocSchema.index({ coordinates: "2dsphere" });
44+
LocSchema.index({ location: "2dsphere" });
4545

4646
export default mongoose.model("Location", LocSchema);

0 commit comments

Comments
 (0)