{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/2352","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/2352/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/2352/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/2352/events","html_url":"https://github.com/Automattic/mongoose/issues/2352","id":45129979,"node_id":"MDU6SXNzdWU0NTEyOTk3OQ==","number":2352,"title":"Using String for _id locally, but ObjectId in Database","user":{"login":"bendytree","id":352285,"node_id":"MDQ6VXNlcjM1MjI4NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/352285?v=4","gravatar_id":"","url":"https://api.github.com/users/bendytree","html_url":"https://github.com/bendytree","followers_url":"https://api.github.com/users/bendytree/followers","following_url":"https://api.github.com/users/bendytree/following{/other_user}","gists_url":"https://api.github.com/users/bendytree/gists{/gist_id}","starred_url":"https://api.github.com/users/bendytree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendytree/subscriptions","organizations_url":"https://api.github.com/users/bendytree/orgs","repos_url":"https://api.github.com/users/bendytree/repos","events_url":"https://api.github.com/users/bendytree/events{/privacy}","received_events_url":"https://api.github.com/users/bendytree/received_events","type":"User","site_admin":false},"labels":[{"id":31695135,"node_id":"MDU6TGFiZWwzMTY5NTEzNQ==","url":"https://api.github.com/repos/Automattic/mongoose/labels/help","name":"help","color":"FFFFFF","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2014-10-07T16:38:26Z","updated_at":"2018-11-01T22:16:33Z","closed_at":"2015-01-20T20:57:15Z","author_association":"NONE","body":"Is there a way to have `_id` be a string on the model, but an `ObjectId` in MongoDB?\n\nBasically it's a bit painful to do equality with `ObjectId`, and I don't get much out of it being an `ObjectId` on my side. For example, finding a document in a collection:\n##### Using ObjectId\n\n```\nvar match = _.find(documents, function(document){\n  return String(document._id) === String(someId);\n}); \n```\n##### Using String\n\n```\nvar match = _.find(documents, {_id:someId});\n```\n"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/435205755","html_url":"https://github.com/Automattic/mongoose/issues/2352#issuecomment-435205755","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/2352","id":435205755,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTIwNTc1NQ==","user":{"login":"bendytree","id":352285,"node_id":"MDQ6VXNlcjM1MjI4NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/352285?v=4","gravatar_id":"","url":"https://api.github.com/users/bendytree","html_url":"https://github.com/bendytree","followers_url":"https://api.github.com/users/bendytree/followers","following_url":"https://api.github.com/users/bendytree/following{/other_user}","gists_url":"https://api.github.com/users/bendytree/gists{/gist_id}","starred_url":"https://api.github.com/users/bendytree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendytree/subscriptions","organizations_url":"https://api.github.com/users/bendytree/orgs","repos_url":"https://api.github.com/users/bendytree/repos","events_url":"https://api.github.com/users/bendytree/events{/privacy}","received_events_url":"https://api.github.com/users/bendytree/received_events","type":"User","site_admin":false},"created_at":"2018-11-01T22:16:33Z","updated_at":"2018-11-01T22:16:33Z","author_association":"NONE","body":"4 years later, I'll poke my head in again and say it'd still be nice if `_id` could be a string.\r\n\r\nI'm sure `ObjectId`'s benefit some folks, but it's constant pain for me. I can count on one hand the number of times I've needed an actual `ObjectId` and would prefer calling the constructor in those scenarios.\r\n\r\nOver and over I have to call `String(doc._id)` for comparisons or patch libs like `lodash` which isn't just ugly, but also very slow in tight loops. A string would work perfectly everywhere.\r\n\r\nTotally recognize this is a mongodb thing and so maybe it's just impossible. Either way, mongoose is great and I really appreciate the library as-is."}}
{"actor":{"display_login":"bendytree"}}