{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/736","labels_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/736/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/736/comments","events_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/736/events","html_url":"https://github.com/tgriesser/bookshelf/pull/736","id":75236795,"number":736,"title":"Run modelMethods on toJSON output not attributes","user":{"login":"tbranyen","id":181635,"avatar_url":"https://avatars.githubusercontent.com/u/181635?v=3","gravatar_id":"","url":"https://api.github.com/users/tbranyen","html_url":"https://github.com/tbranyen","followers_url":"https://api.github.com/users/tbranyen/followers","following_url":"https://api.github.com/users/tbranyen/following{/other_user}","gists_url":"https://api.github.com/users/tbranyen/gists{/gist_id}","starred_url":"https://api.github.com/users/tbranyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbranyen/subscriptions","organizations_url":"https://api.github.com/users/tbranyen/orgs","repos_url":"https://api.github.com/users/tbranyen/repos","events_url":"https://api.github.com/users/tbranyen/events{/privacy}","received_events_url":"https://api.github.com/users/tbranyen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-11T14:15:01Z","updated_at":"2015-05-20T21:32:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tgriesser/bookshelf/pulls/736","html_url":"https://github.com/tgriesser/bookshelf/pull/736","diff_url":"https://github.com/tgriesser/bookshelf/pull/736.diff","patch_url":"https://github.com/tgriesser/bookshelf/pull/736.patch"},"body":"The best way I've found to remove a password from a user object is via\r\nthe `omit` method.  This matches up with the documentation that shows\r\nthe following example:\r\n\r\n``` javascript\r\nCustomer.login(email, password).then(function(customer) {\r\n  res.json(customer.omit('password'));\r\n})\r\n```\r\n\r\nThis works great until you use `withRelated` to fetch a user profile,\r\nfor instance.  `omit` will run on the `attributes` not the merged\r\noutput, so using the above example would strip out the fetched\r\nadditionals.\r\n\r\nThis PR is my naive solution at fixing the problem.  I updated the base\r\nmodel to use `toJSON` as well as the virtuals plugin.\r\n\r\nLet me know if anything else needs documenting or if is avoidable\r\nintentional behavior."},"comment":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/comments/104045593","html_url":"https://github.com/tgriesser/bookshelf/pull/736#issuecomment-104045593","issue_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/736","id":104045593,"user":{"login":"tbranyen","id":181635,"avatar_url":"https://avatars.githubusercontent.com/u/181635?v=3","gravatar_id":"","url":"https://api.github.com/users/tbranyen","html_url":"https://github.com/tbranyen","followers_url":"https://api.github.com/users/tbranyen/followers","following_url":"https://api.github.com/users/tbranyen/following{/other_user}","gists_url":"https://api.github.com/users/tbranyen/gists{/gist_id}","starred_url":"https://api.github.com/users/tbranyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbranyen/subscriptions","organizations_url":"https://api.github.com/users/tbranyen/orgs","repos_url":"https://api.github.com/users/tbranyen/repos","events_url":"https://api.github.com/users/tbranyen/events{/privacy}","received_events_url":"https://api.github.com/users/tbranyen/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T21:32:35Z","updated_at":"2015-05-20T21:32:35Z","body":"Ping @tgriesser any thoughts on this? I know @tkellen mentioned that you're currently in a rewrite, does this work temporarily for you?"}}