{"action":"created","comment":{"url":"https://api.github.com/repos/strongloop/loopback/pulls/comments/25669118","id":25669118,"diff_hunk":"@@ -81,8 +81,14 @@ module.exports = function(Application) {\n    * A hook to generate keys before creation\n    * @param next\n    */\n-  Application.beforeCreate = function(next) {\n-    var app = this;\n+  Application.observe('before save', function(ctx, next) {\n+    if (!ctx.instance) {\n+      // Example: Application.updateAll() and Application.updateOrCreate()\n+      var msg = 'Application object does not support data-based updates';\n+      return next(new Error(msg));","path":"common/models/application.js","position":10,"original_position":10,"commit_id":"b27e96c20812040df709ce8f3b91a8f8af1f3220","original_commit_id":"e65cd290beb72d4a90b50defd6925c52cbb5f1a0","user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars.githubusercontent.com/u/1140553?v=3","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"body":"There is already a unit-test for this and it's passing: https://github.com/strongloop/loopback/blob/baf372b8d7f1bd578759e11e596ec7d633b70cb5/test/model.application.test.js#L97-L120","created_at":"2015-03-03T08:09:08Z","updated_at":"2015-03-03T08:09:08Z","html_url":"https://github.com/strongloop/loopback/pull/1148#discussion_r25669118","pull_request_url":"https://api.github.com/repos/strongloop/loopback/pulls/1148","_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/comments/25669118"},"html":{"href":"https://github.com/strongloop/loopback/pull/1148#discussion_r25669118"},"pull_request":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/1148"}}},"pull_request":{"url":"https://api.github.com/repos/strongloop/loopback/pulls/1148","id":30278567,"html_url":"https://github.com/strongloop/loopback/pull/1148","diff_url":"https://github.com/strongloop/loopback/pull/1148.diff","patch_url":"https://github.com/strongloop/loopback/pull/1148.patch","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/1148","number":1148,"state":"open","locked":false,"title":"Replace deprecated hooks with Operation hooks","user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars.githubusercontent.com/u/1140553?v=3","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"body":"```\r\nAccessToken.beforeCreate -> AccessToken.observe('before save')\r\nApplication.beforeCreate -> Application.observe('before save')\r\nCheckpoint.beforeSave -> Checkpoint.observe('before save')\r\n```\r\n\r\n/to @ritch please review\r\n/cc @raymondfeng \r\n\r\nLoosely related: https://github.com/strongloop/loopback/issues/838 that will implement `ctx.isNewInstance`. Although I don't think it will be very helpful in these three cases.","created_at":"2015-03-02T12:13:43Z","updated_at":"2015-03-03T08:09:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3a7c6db256c53c3c74a6beb935a6e4a9c370112d","assignee":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars.githubusercontent.com/u/1140553?v=3","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/strongloop/loopback/pulls/1148/commits","review_comments_url":"https://api.github.com/repos/strongloop/loopback/pulls/1148/comments","review_comment_url":"https://api.github.com/repos/strongloop/loopback/pulls/comments{/number}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1148/comments","statuses_url":"https://api.github.com/repos/strongloop/loopback/statuses/b27e96c20812040df709ce8f3b91a8f8af1f3220","head":{"label":"strongloop:fix/juggler-deprecation-warnings","ref":"fix/juggler-deprecation-warnings","sha":"b27e96c20812040df709ce8f3b91a8f8af1f3220","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":9325315,"name":"loopback","full_name":"strongloop/loopback","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback","description":"LoopBack is an open source Node.js framework built on top of Express optimized for building APIs for mobile, web, and other devices. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services and data, connect using JS, iOS & Android SDKs.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback","forks_url":"https://api.github.com/repos/strongloop/loopback/forks","keys_url":"https://api.github.com/repos/strongloop/loopback/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback/events","assignees_url":"https://api.github.com/repos/strongloop/loopback/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback/merges","archive_url":"https://api.github.com/repos/strongloop/loopback/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback/releases{/id}","created_at":"2013-04-09T16:02:18Z","updated_at":"2015-03-03T01:49:19Z","pushed_at":"2015-03-03T00:33:25Z","git_url":"git://github.com/strongloop/loopback.git","ssh_url":"git@github.com:strongloop/loopback.git","clone_url":"https://github.com/strongloop/loopback.git","svn_url":"https://github.com/strongloop/loopback","homepage":"http://loopback.io","size":13895,"stargazers_count":3298,"watchers_count":3298,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":293,"mirror_url":null,"open_issues_count":309,"forks":293,"open_issues":309,"watchers":3298,"default_branch":"master"}},"base":{"label":"strongloop:master","ref":"master","sha":"d24da8c37d9b5ba26c7572f5cc950698c0831e3d","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":9325315,"name":"loopback","full_name":"strongloop/loopback","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars.githubusercontent.com/u/3020012?v=3","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback","description":"LoopBack is an open source Node.js framework built on top of Express optimized for building APIs for mobile, web, and other devices. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services and data, connect using JS, iOS & Android SDKs.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback","forks_url":"https://api.github.com/repos/strongloop/loopback/forks","keys_url":"https://api.github.com/repos/strongloop/loopback/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback/events","assignees_url":"https://api.github.com/repos/strongloop/loopback/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback/merges","archive_url":"https://api.github.com/repos/strongloop/loopback/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback/releases{/id}","created_at":"2013-04-09T16:02:18Z","updated_at":"2015-03-03T01:49:19Z","pushed_at":"2015-03-03T00:33:25Z","git_url":"git://github.com/strongloop/loopback.git","ssh_url":"git@github.com:strongloop/loopback.git","clone_url":"https://github.com/strongloop/loopback.git","svn_url":"https://github.com/strongloop/loopback","homepage":"http://loopback.io","size":13895,"stargazers_count":3298,"watchers_count":3298,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":293,"mirror_url":null,"open_issues_count":309,"forks":293,"open_issues":309,"watchers":3298,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/1148"},"html":{"href":"https://github.com/strongloop/loopback/pull/1148"},"issue":{"href":"https://api.github.com/repos/strongloop/loopback/issues/1148"},"comments":{"href":"https://api.github.com/repos/strongloop/loopback/issues/1148/comments"},"review_comments":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/1148/comments"},"review_comment":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/strongloop/loopback/pulls/1148/commits"},"statuses":{"href":"https://api.github.com/repos/strongloop/loopback/statuses/b27e96c20812040df709ce8f3b91a8f8af1f3220"}}}}