I am trying to get results from DB using geoNear in Moongose but it is giving "can't get query executor" error.
// Schema
let dealSchema = new Schema({
userId: {type: String, required: true},
images: {type: [String], required: true},
location: {
lng: {type: Number},
lat: {type: Number},
name: {type: String, required: true}
},
description: {type: String, required: false, default: ""},
expiredReports: {type: [String], required: false},
inappropriateReports: {type: [String], required: false},
likes: {type: [String], required: false},
dislikes: {type: [String], required: false},
comments: {type: [commentSchema], required: false},
creationDate: {type: Date, default: new Date()},
updationDate: {type: Date, default: new Date()}
}, {collection: TableName.DEAL});
function getAll(radius) {
var point = {type: "Point", coordinates: [9, 9]};
let distance = parseInt(radius);
if (isNaN(distance)) {
return callback(new Error("Invalid Radius"), null)
}
var geoOptions = {
spherical: true,
maxDistance: distance,
num: 10
};
DealData.geoNear(point, geoOptions, function (err, docs, stats) {
console.log(docs);
}
);
}
This is my model of Mongoose and My code to get data from Database.
via user3768061
No comments:
Post a Comment