Skip to content

Commit

Permalink
fix index
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizFelipeNeves committed Aug 26, 2019
1 parent a0b7d34 commit 1c04d7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions graphql/resolvers/Freight/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,18 @@ export default {
if (vehicles) conditions.vehicles = { vehicles: { $in: vehicles } };
if (bodies) conditions.bodies = { bodies: { $in: bodies } };
const res = await Freight.aggregate([
...freightquery,
{ $match: conditions },
/*{
{
$geoNear: {
near: { type: "Point", coordinates },
distanceField: "dist.calculated",
spherical: true,
key: "origin.location",
maxDistance: range
includeLocs: "location",
maxDistance: range,
query: conditions
}
},*/
},
...freightquery,
{ $skip: (page - 1) * perpage },
{ $limit: perpage }
]).exec();
Expand Down
2 changes: 1 addition & 1 deletion server/models/Location.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ const LocSchema = new Schema({
}
});

LocSchema.index({ coordinates: "2dsphere" });
LocSchema.index({ location: "2dsphere" });

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

0 comments on commit 1c04d7c

Please sign in to comment.