0
我有一个模式,看起来像这样:猫鼬之内时,查询或查询
var UserSchema = new Schema({
name: {type : String, required: true},
location_a: {type: [Number], default: [0,0], index: '2dsphere'},
location_b: {type: [Number], default: [0,0], index: '2dsphere'}
});
我搜索的输入有一个位置和距离。现在我想让位于location_a或location_b附近的用户接近搜索到的位置。
我已经尝试了查询,看起来像这样:
query = query.and([
{ $or: [
query.where('location_a').near({
center: {type: 'Point', coordinates: [long, lat]},
maxDistance: distance * 1000, spherical: true
}),
query.where('location_b').near({
center: {type: 'Point', coordinates: [long, lat]},
maxDistance: 100 * 1000, spherical: true
})
]}
]);
但它使我的应用程序崩溃与“的RangeError:最大调用堆栈大小超出”
你的''和'没有做任何事情,而你的'$或'周围的'[]'括号在不正确的位置 –
你确定[]是问题吗?我应该在哪里放置它们? – Vetm
请在显示查询前指定查询的方式 –