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
請在顯示查詢前指定查詢的方式 –