Node.js 在猫鼬模型上找不到geoNear?
我不明白为什么在我的猫鼬模型上找不到geoNear:Node.js 在猫鼬模型上找不到geoNear?,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我不明白为什么在我的猫鼬模型上找不到geoNear: var location = { type : 'Point', coordinates : coordinates }; Shift.geoNear(location, { maxDistance : 5, spherical : true }, function(err, results, stats) { response.json(results); console.log(stats); }); TypeErro
var location = { type : 'Point', coordinates : coordinates };
Shift.geoNear(location, { maxDistance : 5, spherical : true }, function(err, results, stats) {
response.json(results);
console.log(stats);
});
TypeError: Object function model(doc, fields, skipId) {
if (!(this instanceof model))
return new model(doc, fields, skipId);
Model.call(this, doc, fields, skipId);
} has no method 'geoNear'
您确定
Shift
是您的模型,而不是您的模式吗?例如,ThingModel=mongoose.model('Thing',ThingSchema)代码>是的,我可以用它进行查询,例如Shift.find({}),等等……忘记geoNear的混乱吧。请参考以下答案: