1
私はデータベースとしてループバック角度プロジェクト、mongoDBを使って作業しています。ループバックのmongoDBクエリで最も近いユーザを緯度と経度で検索し、 'near'キーワードを使用してエラーを引き起こします。ループバックMongoDB地理的なクライアントからの地理的に近い質問
注:2dで 'loc'フィールドのインデックスを作成しました。
エラー:
> D:\nodejs\your-time\version_1\node_modules\mongodb\lib\utils.js:98
process.nextTick(function() { throw err; });
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
at ServerResponse.header (D:\nodejs\your-time\version_1\node_modules\express
\lib\response.js:719:10)
at HttpContext.done (D:\nodejs\your-time\version_1\node_modules\strong-remot
ing\lib\http-context.js:651:9)
at D:\nodejs\your-time\version_1\node_modules\strong-remoting\lib\rest-adapt
er.js:492:11
at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
sync\lib\async.js:251:17
at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
sync\lib\async.js:154:25
at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
sync\lib\async.js:248:21
at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
sync\lib\async.js:612:34
at interceptInvocationErrors (D:\nodejs\your-time\version_1\node_modules\str
ong-remoting\lib\remote-objects.js:690:22)
at D:\nodejs\your-time\version_1\node_modules\loopback-phase\node_modules\as
ync\lib\async.js:154:25
そして、私のコードは以下の通りです:私は間違って何をやっている
Profile.find({
filter: {
where: {
type: 'expert',
is_verified: 1,
expert_category: $scope.expertCategory,
loc: {
'near': [lat, lng]
}
}
}
}).$promise.then(function(users) {
console.log(users);
$scope.users = users;
});
?
問題は他にもあるようですが、あなたは 'loc '{'の近く ':[lat、lng]}'を削除しようとしましたか?緯度/経度パラメータなしで動作していることを確認してください。 – jaym
'{where:{near:{lat:42.266271、lng:-72.6700016}}}}'を試してください - 配列の代わりにJSオブジェクトを使用してください。 – jaym
同じ問題を試しました。私はループバックが2dsphere(2dで索引付けされた)以上のジオクエリーをサポートしていることを発見しました。 – shoeab