{"action":"created","issue":{"url":"https://api.github.com/repos/aldeed/meteor-simple-schema/issues/344","labels_url":"https://api.github.com/repos/aldeed/meteor-simple-schema/issues/344/labels{/name}","comments_url":"https://api.github.com/repos/aldeed/meteor-simple-schema/issues/344/comments","events_url":"https://api.github.com/repos/aldeed/meteor-simple-schema/issues/344/events","html_url":"https://github.com/aldeed/meteor-simple-schema/issues/344","id":70467452,"number":344,"title":"Can't access _id in custom validator","user":{"login":"mkarliner","id":1651042,"avatar_url":"https://avatars.githubusercontent.com/u/1651042?v=3","gravatar_id":"","url":"https://api.github.com/users/mkarliner","html_url":"https://github.com/mkarliner","followers_url":"https://api.github.com/users/mkarliner/followers","following_url":"https://api.github.com/users/mkarliner/following{/other_user}","gists_url":"https://api.github.com/users/mkarliner/gists{/gist_id}","starred_url":"https://api.github.com/users/mkarliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkarliner/subscriptions","organizations_url":"https://api.github.com/users/mkarliner/orgs","repos_url":"https://api.github.com/users/mkarliner/repos","events_url":"https://api.github.com/users/mkarliner/events{/privacy}","received_events_url":"https://api.github.com/users/mkarliner/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-23T17:28:21Z","updated_at":"2015-04-24T08:28:34Z","closed_at":"2015-04-24T08:28:34Z","body":"First, I admit to being a bit nervous, as every issue I've raised with you has been !=bug. Ah well, here goes.\r\n\r\nIn a custom validator I'm trying to ascertain if there is another  document with the same title.\r\nTo do this I do this for the title field\r\n\t\tcustom: function (a) {\r\n\t\t\tf = Feeds.findOne({title: this.value});\r\n\t\t\tconsole.log(\"FEEDS\", f, \"THIS\", this.field(\"_id\"));\r\n\t\t\tif(f && (f._id != this.field(\"_id\"))) {\r\n\t\t\t\treturn \"uniqueFeed\";\r\n\t\t\t}\r\n\t\t},\r\n\r\nBut I can't access _id even if I include it in the schema. \r\n\r\nThe reason I'm not using a unique index, by the way, is that there is a 'public' flag which governs the visibility of my Feeds, so I would need a compound index.\r\n\r\nI expect there is a good reason why I'm not allowed to get hold of _id, but what can I do in these circumstances."},"comment":{"url":"https://api.github.com/repos/aldeed/meteor-simple-schema/issues/comments/95851789","html_url":"https://github.com/aldeed/meteor-simple-schema/issues/344#issuecomment-95851789","issue_url":"https://api.github.com/repos/aldeed/meteor-simple-schema/issues/344","id":95851789,"user":{"login":"mkarliner","id":1651042,"avatar_url":"https://avatars.githubusercontent.com/u/1651042?v=3","gravatar_id":"","url":"https://api.github.com/users/mkarliner","html_url":"https://github.com/mkarliner","followers_url":"https://api.github.com/users/mkarliner/followers","following_url":"https://api.github.com/users/mkarliner/following{/other_user}","gists_url":"https://api.github.com/users/mkarliner/gists{/gist_id}","starred_url":"https://api.github.com/users/mkarliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkarliner/subscriptions","organizations_url":"https://api.github.com/users/mkarliner/orgs","repos_url":"https://api.github.com/users/mkarliner/repos","events_url":"https://api.github.com/users/mkarliner/events{/privacy}","received_events_url":"https://api.github.com/users/mkarliner/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T08:28:34Z","updated_at":"2015-04-24T08:28:34Z","body":"I just found https://github.com/aldeed/meteor-simple-schema/issues/268. Which solves this."}}