-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
// Add in Model mongoDB
location: {
type: {
type: String,
enum: [“Point”],
default: “Point”
},
coordinates: {
type: [Number],
default: [0, 0]
}
},
// Find with mongoose
const { longitude, latitude, radius } = req.fields;
let KM = radius / 1000;
if (!longitude || !latitude || !radius) {
res.status(400).json({ error: "Missing Geoloc parameters" });
} else {
const allProducers = await Producers.find({
location: {
$geoWithin: { $centerSphere: [[longitude, latitude], KM / 6371] }
}
});
res.json(allProducers);
}
//Update field in New model
location: { type: "Point", coordinates: [longitude, latitude] },Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels