{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/3079","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/3079/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/3079/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/3079/events","html_url":"https://github.com/Automattic/mongoose/issues/3079","id":89043087,"number":3079,"title":"findById returns no results even with correct ObjectId","user":{"login":"florianheinemann","id":6122601,"avatar_url":"https://avatars.githubusercontent.com/u/6122601?v=3","gravatar_id":"","url":"https://api.github.com/users/florianheinemann","html_url":"https://github.com/florianheinemann","followers_url":"https://api.github.com/users/florianheinemann/followers","following_url":"https://api.github.com/users/florianheinemann/following{/other_user}","gists_url":"https://api.github.com/users/florianheinemann/gists{/gist_id}","starred_url":"https://api.github.com/users/florianheinemann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/florianheinemann/subscriptions","organizations_url":"https://api.github.com/users/florianheinemann/orgs","repos_url":"https://api.github.com/users/florianheinemann/repos","events_url":"https://api.github.com/users/florianheinemann/events{/privacy}","received_events_url":"https://api.github.com/users/florianheinemann/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/can't%20reproduce","name":"can't reproduce","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-06-17T15:06:17Z","updated_at":"2016-06-17T17:57:26Z","closed_at":"2015-08-03T21:46:15Z","body":"Configuration: Mongoose 4.0.5, MongoDb 3.0.4, Node 0.12.4\r\nIssue does **not appear** on Mongoose 3.8.30\r\n\r\nMy database has the following data:\r\n```\r\ndb.users.find()\r\n{ \"_id\" : ObjectId(\"5580c79aa11e7310b2985ab1\"), \"email\" : \"an_email\", \"color\" : \"\", \"username\" : \"\", \"__v\" : 0 }\r\n```\r\nI query it with Mongoose using the following syntax:\r\n```\r\nUser.findById(\"5580c79aa11e7310b2985ab1\", function(error, user) { }\r\n```\r\nwhich returns **null for both error and user**. Strangely enough Mongoose's debugging shows the following, correct query:\r\n```\r\nusers.findOne({ _id: ObjectId(\"5580c79aa11e7310b2985ab1\") })\r\n```\r\nwhich queried directly on MongoDB finds the expected data:\r\n```\r\ndb.users.findOne({ _id: new ObjectId(\"5580c79aa11e7310b2985ab1\") })\r\n{\r\n    \"_id\" : ObjectId(\"5580c79aa11e7310b2985ab1\"),\r\n    \"email\" : \"an_email\",\r\n    \"color\" : \"\",\r\n    \"username\" : \"\",\r\n    \"__v\" : 0\r\n}\r\n```\r\nI tried various alternatives such as directly initializing an ObjectId object or taking an ObjectId from a `find()` result which leads to no results either. As stated above reverting back to Mongoose 3.8 resolves the issue."},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/226837974","html_url":"https://github.com/Automattic/mongoose/issues/3079#issuecomment-226837974","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/3079","id":226837974,"user":{"login":"slinkydeveloper","id":6706544,"avatar_url":"https://avatars.githubusercontent.com/u/6706544?v=3","gravatar_id":"","url":"https://api.github.com/users/slinkydeveloper","html_url":"https://github.com/slinkydeveloper","followers_url":"https://api.github.com/users/slinkydeveloper/followers","following_url":"https://api.github.com/users/slinkydeveloper/following{/other_user}","gists_url":"https://api.github.com/users/slinkydeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/slinkydeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slinkydeveloper/subscriptions","organizations_url":"https://api.github.com/users/slinkydeveloper/orgs","repos_url":"https://api.github.com/users/slinkydeveloper/repos","events_url":"https://api.github.com/users/slinkydeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/slinkydeveloper/received_events","type":"User","site_admin":false},"created_at":"2016-06-17T17:57:26Z","updated_at":"2016-06-17T17:57:26Z","body":"I was having same issue, i resolved changing the name of collection. Thank you @skecskes "}}
{"actor":{"display_login":"slinkydeveloper"}}