{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/1181","labels_url":"https://api.github.com/repos/balderdashy/waterline/issues/1181/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/waterline/issues/1181/comments","events_url":"https://api.github.com/repos/balderdashy/waterline/issues/1181/events","html_url":"https://github.com/balderdashy/waterline/issues/1181","id":110362518,"number":1181,"title":"Checking values in database before allowing an update","user":{"login":"Alaneor","id":3058150,"avatar_url":"https://avatars.githubusercontent.com/u/3058150?v=3","gravatar_id":"","url":"https://api.github.com/users/Alaneor","html_url":"https://github.com/Alaneor","followers_url":"https://api.github.com/users/Alaneor/followers","following_url":"https://api.github.com/users/Alaneor/following{/other_user}","gists_url":"https://api.github.com/users/Alaneor/gists{/gist_id}","starred_url":"https://api.github.com/users/Alaneor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alaneor/subscriptions","organizations_url":"https://api.github.com/users/Alaneor/orgs","repos_url":"https://api.github.com/users/Alaneor/repos","events_url":"https://api.github.com/users/Alaneor/events{/privacy}","received_events_url":"https://api.github.com/users/Alaneor/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-08T02:49:42Z","updated_at":"2015-10-08T16:10:49Z","closed_at":"2015-10-08T03:14:42Z","body":"1. Let's say I have an existing User model saved in database.\r\n1. Let's say I want this model's name to be updated to a new value, but only allow such update if the user's `suspended` attribute in database is not `true`.\r\n\r\n**How do I achieve this?**\r\n\r\nMy approach so far has been to write a `beforeUpdate()` hook, but:\r\n\r\n1. I don't know how to get the user's ID which is about to be updated (if there is any way)\r\n1. I don't know how to obtain the model's current data from the database - the lifecycle callback only gets the properties to be changed.\r\n\r\nThanks for any guidance on this matter!"},"comment":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/comments/146595342","html_url":"https://github.com/balderdashy/waterline/issues/1181#issuecomment-146595342","issue_url":"https://api.github.com/repos/balderdashy/waterline/issues/1181","id":146595342,"user":{"login":"particlebanana","id":370260,"avatar_url":"https://avatars.githubusercontent.com/u/370260?v=3","gravatar_id":"","url":"https://api.github.com/users/particlebanana","html_url":"https://github.com/particlebanana","followers_url":"https://api.github.com/users/particlebanana/followers","following_url":"https://api.github.com/users/particlebanana/following{/other_user}","gists_url":"https://api.github.com/users/particlebanana/gists{/gist_id}","starred_url":"https://api.github.com/users/particlebanana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particlebanana/subscriptions","organizations_url":"https://api.github.com/users/particlebanana/orgs","repos_url":"https://api.github.com/users/particlebanana/repos","events_url":"https://api.github.com/users/particlebanana/events{/privacy}","received_events_url":"https://api.github.com/users/particlebanana/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T16:10:49Z","updated_at":"2015-10-08T16:10:49Z","body":"In the above example you have the user's id - 123. "}}