{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/3237","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/3237/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/3237/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/3237/events","html_url":"https://github.com/Automattic/mongoose/issues/3237","id":99338697,"number":3237,"title":"ObjectId equality not working","user":{"login":"joshperry","id":298053,"avatar_url":"https://avatars.githubusercontent.com/u/298053?v=3","gravatar_id":"","url":"https://api.github.com/users/joshperry","html_url":"https://github.com/joshperry","followers_url":"https://api.github.com/users/joshperry/followers","following_url":"https://api.github.com/users/joshperry/following{/other_user}","gists_url":"https://api.github.com/users/joshperry/gists{/gist_id}","starred_url":"https://api.github.com/users/joshperry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshperry/subscriptions","organizations_url":"https://api.github.com/users/joshperry/orgs","repos_url":"https://api.github.com/users/joshperry/repos","events_url":"https://api.github.com/users/joshperry/events{/privacy}","received_events_url":"https://api.github.com/users/joshperry/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/won't%20fix","name":"won't fix","color":"006b75"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-06T02:14:17Z","updated_at":"2015-08-07T15:17:37Z","closed_at":"2015-08-06T04:35:43Z","body":"The ObjectID equality doesn't seem to be working properly which makes it really difficult to work with arrays of ObjectIds.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/298053/9102553/01c7e41a-3bb1-11e5-99a5-916921782c38.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/128729477","html_url":"https://github.com/Automattic/mongoose/issues/3237#issuecomment-128729477","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/3237","id":128729477,"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":"2015-08-07T15:17:36Z","updated_at":"2015-08-07T15:17:36Z","body":"By definition, ObjectIds are 12 arbitrary bytes. The string form is convenient because you can represent 12 arbitrary bytes as 24 hex chars, and thus easily transfer ObjectIds using text-encoded protocols like JSON. However, in NodeJS, the actual ObjectId type is an object with a 12 byte buffer - we don't use a plain-old buffer because then there's no good way to say \"I really mean for this buffer to be an ObjectId\". You can also compare the ObjectId's `.id` field, which is the buffer.\r\n\r\n```\r\n$ node\r\n> var mongodb = require('mongodb');\r\nundefined\r\n> var o1 = mongodb.ObjectId()\r\nundefined\r\n> o1\r\n55c4caa4ece723b21cad5ffc\r\n> var o2 = new mongodb.ObjectId(\"55c4caa4ece723b21cad5ffc\");\r\nundefined\r\n> o2\r\n55c4caa4ece723b21cad5ffc\r\n> o2 === o1\r\nfalse\r\n> o1.id === o2.id\r\ntrue\r\n> o1.id\r\n'UÄÊ¤ìç#²\\u001c­_ü'\r\n```"}}