{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/2946","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/2946/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/2946/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/2946/events","html_url":"https://github.com/Automattic/mongoose/issues/2946","id":72248200,"number":2946,"title":"Setters don't run on findOneAndUpdate","user":{"login":"buunguyen","id":406631,"avatar_url":"https://avatars.githubusercontent.com/u/406631?v=3","gravatar_id":"","url":"https://api.github.com/users/buunguyen","html_url":"https://github.com/buunguyen","followers_url":"https://api.github.com/users/buunguyen/followers","following_url":"https://api.github.com/users/buunguyen/following{/other_user}","gists_url":"https://api.github.com/users/buunguyen/gists{/gist_id}","starred_url":"https://api.github.com/users/buunguyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buunguyen/subscriptions","organizations_url":"https://api.github.com/users/buunguyen/orgs","repos_url":"https://api.github.com/users/buunguyen/repos","events_url":"https://api.github.com/users/buunguyen/events{/privacy}","received_events_url":"https://api.github.com/users/buunguyen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/discussion","name":"discussion","color":"d4c5f9"},{"url":"https://api.github.com/repos/Automattic/mongoose/labels/new%20feature","name":"new feature","color":"e102d8"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Automattic/mongoose/milestones/31","html_url":"https://github.com/Automattic/mongoose/milestones/5.0","labels_url":"https://api.github.com/repos/Automattic/mongoose/milestones/31/labels","id":995902,"number":31,"title":"5.0","description":"","creator":{"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},"open_issues":56,"closed_issues":0,"state":"open","created_at":"2015-02-25T21:12:19Z","updated_at":"2016-05-07T16:19:32Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2015-04-30T18:47:42Z","updated_at":"2016-05-27T01:19:27Z","closed_at":null,"body":"I'm not sure if this is intended or a bug, but schema setters don't seem to run in atomic find-and-modify operations. If it's intended, it's quite a big limitation because I use these almost exclusively throughout the app to perform updates.  Is there a page that documents behaviors of find-and-modify when coming to validation, setters etc.\r\n\r\nMongoose version: 4.0.1."},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/222037530","html_url":"https://github.com/Automattic/mongoose/issues/2946#issuecomment-222037530","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/2946","id":222037530,"user":{"login":"xavdid","id":1231935,"avatar_url":"https://avatars.githubusercontent.com/u/1231935?v=3","gravatar_id":"","url":"https://api.github.com/users/xavdid","html_url":"https://github.com/xavdid","followers_url":"https://api.github.com/users/xavdid/followers","following_url":"https://api.github.com/users/xavdid/following{/other_user}","gists_url":"https://api.github.com/users/xavdid/gists{/gist_id}","starred_url":"https://api.github.com/users/xavdid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavdid/subscriptions","organizations_url":"https://api.github.com/users/xavdid/orgs","repos_url":"https://api.github.com/users/xavdid/repos","events_url":"https://api.github.com/users/xavdid/events{/privacy}","received_events_url":"https://api.github.com/users/xavdid/received_events","type":"User","site_admin":false},"created_at":"2016-05-27T01:19:27Z","updated_at":"2016-05-27T01:19:27Z","body":"Dunno if this is still in the works, but I got around it by only ever writing to mongo in one place and just using my setter manually. I passed this as the second argument to `findOneAndUpdate`\r\n\r\n```\r\n{\r\n  $set: {\r\n    access_token: encrypt(access_token),\r\n    name: name\r\n  }\r\n}\r\n```"}}
{"actor":{"display_login":"xavdid"}}