I have this schema:
var Place = mongoose.Schema({
lat: Number,
lng: Number,
icon: String,
name: String,
place_id: String,
types: [String],
vicinity: String
});
Place.methods.isInsideRadius = (centerLocation, radius) => {
console.log(radius);
console.log(centerLocation);
console.log(this);
return true;
}
How can I access the properties of the instance that is calling this method? I tried printing the this but it returns an empty object.
答案 0 :(得分:5)
Ah my mistake was I was using the fat arrow function. When I used the function() it already worked.