Mongoose $ geoWithin,找到距离英里

时间:2018-05-25 00:09:17

标签: javascript mongodb express mongoose geolocation

我有一个正常工作的查询,但我想根据英里而不是坐标平原来制作半径。这是它的样子($ text:search和$ geoWithin:$ center search。

之间的组合
let query = {
    user_type: type,
    $text: {$search: keyword},
    'loc': { "$geoWithin": { "$center": [ [longitude, latitude],  1] } }
};

Profile.find(query, {score: {$meta: "textScore"}})

阅读https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center后 好像是the circle’s radius, as measured in the units used by the coordinate system.

我如何传递一英里值并将其转换为半径系统?

0 个答案:

没有答案