{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/4752","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/4752/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/4752/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/4752/events","html_url":"https://github.com/Automattic/mongoose/issues/4752","id":192245751,"number":4752,"title":"Search By ID gives \"Can't use $where with Number.\" error in Mongoose","user":{"login":"vaijal","id":24246242,"avatar_url":"https://avatars.githubusercontent.com/u/24246242?v=3","gravatar_id":"","url":"https://api.github.com/users/vaijal","html_url":"https://github.com/vaijal","followers_url":"https://api.github.com/users/vaijal/followers","following_url":"https://api.github.com/users/vaijal/following{/other_user}","gists_url":"https://api.github.com/users/vaijal/gists{/gist_id}","starred_url":"https://api.github.com/users/vaijal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vaijal/subscriptions","organizations_url":"https://api.github.com/users/vaijal/orgs","repos_url":"https://api.github.com/users/vaijal/repos","events_url":"https://api.github.com/users/vaijal/events{/privacy}","received_events_url":"https://api.github.com/users/vaijal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-29T10:38:44Z","updated_at":"2016-12-03T04:28:07Z","closed_at":null,"body":"I want to search by ID.  Below query works fine with MongoDB but not with mongoose.\r\n\r\ndb.getCollection('country').find({ $where: \"/^51.*/.test(this._id)\" });\r\n\r\nI get below error with mongoose\r\n\r\n\"err\":{\"message\":\"Can't use $where with Number.\",\"name\":\"Error\",\"stack\":\"Error: Can't use $where with Number.\\n  at SchemaNumber.castForQuery (/home/pcuser/Projects/country/node_modules/mongoose/lib/schema/number.js:278:13)\\n \r\n"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/264615831","html_url":"https://github.com/Automattic/mongoose/issues/4752#issuecomment-264615831","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/4752","id":264615831,"user":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"created_at":"2016-12-03T04:28:07Z","updated_at":"2016-12-03T04:28:07Z","body":"Show the query you're executing. We have tests in place for `$where`, and that error makes it look like you're doing something like `MyModel.find({ num: { $where: fn } });`, and `$where` needs to be a top-level operator"}}
{"actor":{"display_login":"vkarpov15"}}