{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/6132","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/6132/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/6132/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/6132/events","html_url":"https://github.com/Automattic/mongoose/issues/6132","id":296845018,"number":6132,"title":"near does not seem to work","user":{"login":"pronebird","id":704044,"avatar_url":"https://avatars2.githubusercontent.com/u/704044?v=4","gravatar_id":"","url":"https://api.github.com/users/pronebird","html_url":"https://github.com/pronebird","followers_url":"https://api.github.com/users/pronebird/followers","following_url":"https://api.github.com/users/pronebird/following{/other_user}","gists_url":"https://api.github.com/users/pronebird/gists{/gist_id}","starred_url":"https://api.github.com/users/pronebird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pronebird/subscriptions","organizations_url":"https://api.github.com/users/pronebird/orgs","repos_url":"https://api.github.com/users/pronebird/repos","events_url":"https://api.github.com/users/pronebird/events{/privacy}","received_events_url":"https://api.github.com/users/pronebird/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-13T18:46:14Z","updated_at":"2018-02-15T09:21:09Z","closed_at":null,"author_association":"NONE","body":"I have a very simple piece of code that doesn't seem to work with mongoose v5:\r\n\r\nWorks with mongo:\r\n```\r\nMySchema.query.nearBy = function (lon: number, lat: number, maxDistanceKm: number) {\r\n  const maxDistanceRadians = maxDistanceKm / 6371;\r\n  return this.find({\r\n    location: {\r\n      $near: [lon, lat],\r\n      $maxDistance: maxDistanceRadians\r\n    }\r\n  });\r\n};\r\n```\r\n\r\nDoes not work with mongoose:\r\n\r\n```\r\nMySchema.query.nearBy = function (lon: number, lat: number, maxDistanceKm: number) {\r\n  const maxDistanceRadians = maxDistanceKm / 6371;\r\n  return this.near({\r\n    center: [lon, lat],\r\n    maxDistance: maxDistanceRadians\r\n  });\r\n};\r\n```\r\n\r\nUsed in both cases as:\r\n\r\n```\r\nconst result = await MySchema\r\n      .find()\r\n      .nearBy(lon, lat, maxDistance)\r\n      .exec();\r\n```\r\n\r\nWat?"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/365868670","html_url":"https://github.com/Automattic/mongoose/issues/6132#issuecomment-365868670","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/6132","id":365868670,"user":{"login":"lineus","id":6015453,"avatar_url":"https://avatars3.githubusercontent.com/u/6015453?v=4","gravatar_id":"","url":"https://api.github.com/users/lineus","html_url":"https://github.com/lineus","followers_url":"https://api.github.com/users/lineus/followers","following_url":"https://api.github.com/users/lineus/following{/other_user}","gists_url":"https://api.github.com/users/lineus/gists{/gist_id}","starred_url":"https://api.github.com/users/lineus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lineus/subscriptions","organizations_url":"https://api.github.com/users/lineus/orgs","repos_url":"https://api.github.com/users/lineus/repos","events_url":"https://api.github.com/users/lineus/events{/privacy}","received_events_url":"https://api.github.com/users/lineus/received_events","type":"User","site_admin":false},"created_at":"2018-02-15T09:21:08Z","updated_at":"2018-02-15T09:21:08Z","author_association":"CONTRIBUTOR","body":"@pronebird can you please elaborate on what you mean by \"Does not work with mongoose\"? Are you getting an error, is nothing happening? It would help to know your versions of mongoose, mongodb server, and node as well. "}}
{"actor":{"display_login":"lineus"}}