GitHub PullRequestReviewCommentEvent at 2014-11-06 17:45:40
Repository: sequelize
Actor: janmeier
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/sequelize/sequelize/pulls/comments/19960730","id":19960730,"diff_hunk":"@@ -759,6 +759,46 @@ module.exports = (function() {\n   };\n \n   /**\n+   * Undestroy the row corresponding to this instance. Only available for paranoid models.\n+   *\n+   * @param {Object}  [options={}]\n+   *\n+   * @return {Promise<undefined>}\n+   */\n+  Instance.prototype.undestroy = function(options) {\n+    options = Utils._.extend({\n+      hooks: true,\n+      force: false\n+    }, options || {});\n+\n+    var self = this;\n+\n+    // This semi awkward syntax where we can't return the chain directly but have to return the last .then() call is to allow sql proxying\n+    return Promise.try(function() {\n+      // Run before hook\n+      if (options.hooks) {\n+        return self.Model.runHooks('beforeUndestroy', self, options);\n+      }\n+    }).then(function() {\n+      var identifier;\n+\n+      if (!self.Model._timestampAttributes.deletedAt) {\n+        return Promise.reject(new Error(\"Model is not paranoid\"));\n+      } else {\n+        self.dataValues[self.Model._timestampAttributes.deletedAt] = null;\n+        return self.save(_.extend(_.clone(options), {hooks : false, omitNull : false}));\n+      }\n+    }).tap(function(result) {\n+      // Run after hook\n+      if (options.hooks) {\n+        return self.Model.runHooks('afterUndestroy', self, options);\n+      }\n+    }).then(function(result) {\n+      return result;","path":"lib/instance.js","position":39,"original_position":39,"commit_id":"1c5971267d5e7b5d4c3d68ecdc8de0e9d299afb3","original_commit_id":"1c5971267d5e7b5d4c3d68ecdc8de0e9d299afb3","user":{"login":"janmeier","id":1210224,"avatar_url":"https://avatars.githubusercontent.com/u/1210224?v=2","gravatar_id":"","url":"https://api.github.com/users/janmeier","html_url":"https://github.com/janmeier","followers_url":"https://api.github.com/users/janmeier/followers","following_url":"https://api.github.com/users/janmeier/following{/other_user}","gists_url":"https://api.github.com/users/janmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/janmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janmeier/subscriptions","organizations_url":"https://api.github.com/users/janmeier/orgs","repos_url":"https://api.github.com/users/janmeier/repos","events_url":"https://api.github.com/users/janmeier/events{/privacy}","received_events_url":"https://api.github.com/users/janmeier/received_events","type":"User","site_admin":false},"body":"The last `then` shouldn't be needed","created_at":"2014-11-06T17:45:40Z","updated_at":"2014-11-06T17:45:40Z","html_url":"https://github.com/sequelize/sequelize/pull/2540#discussion_r19960730","pull_request_url":"https://api.github.com/repos/sequelize/sequelize/pulls/2540","_links":{"self":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/comments/19960730"},"html":{"href":"https://github.com/sequelize/sequelize/pull/2540#discussion_r19960730"},"pull_request":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/2540"}}},"pull_request":{"url":"https://api.github.com/repos/sequelize/sequelize/pulls/2540","id":23998512,"html_url":"https://github.com/sequelize/sequelize/pull/2540","diff_url":"https://github.com/sequelize/sequelize/pull/2540.diff","patch_url":"https://github.com/sequelize/sequelize/pull/2540.patch","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/2540","number":2540,"state":"open","locked":false,"title":"Undestroy method for paranoid models","user":{"login":"seth-admittedly","id":4643337,"avatar_url":"https://avatars.githubusercontent.com/u/4643337?v=2","gravatar_id":"","url":"https://api.github.com/users/seth-admittedly","html_url":"https://github.com/seth-admittedly","followers_url":"https://api.github.com/users/seth-admittedly/followers","following_url":"https://api.github.com/users/seth-admittedly/following{/other_user}","gists_url":"https://api.github.com/users/seth-admittedly/gists{/gist_id}","starred_url":"https://api.github.com/users/seth-admittedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seth-admittedly/subscriptions","organizations_url":"https://api.github.com/users/seth-admittedly/orgs","repos_url":"https://api.github.com/users/seth-admittedly/repos","events_url":"https://api.github.com/users/seth-admittedly/events{/privacy}","received_events_url":"https://api.github.com/users/seth-admittedly/received_events","type":"User","site_admin":false},"body":"Undestroy allows for restoring destroyed paranoid models. Mirrors the syntax of destroy, with both model (bulk) and instance options.\r\n\r\nImplementing this without resorting to manual SQL required tweaking the query generator to allow for omitNull to be passed as an option with an individual query.","created_at":"2014-11-06T17:42:35Z","updated_at":"2014-11-06T17:45:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7241c28a740f55524884c6fb9ec8c8f76c0167eb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sequelize/sequelize/pulls/2540/commits","review_comments_url":"https://api.github.com/repos/sequelize/sequelize/pulls/2540/comments","review_comment_url":"https://api.github.com/repos/sequelize/sequelize/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/2540/comments","statuses_url":"https://api.github.com/repos/sequelize/sequelize/statuses/1c5971267d5e7b5d4c3d68ecdc8de0e9d299afb3","head":{"label":"seth-admittedly:feature/undestroy","ref":"feature/undestroy","sha":"1c5971267d5e7b5d4c3d68ecdc8de0e9d299afb3","user":{"login":"seth-admittedly","id":4643337,"avatar_url":"https://avatars.githubusercontent.com/u/4643337?v=2","gravatar_id":"","url":"https://api.github.com/users/seth-admittedly","html_url":"https://github.com/seth-admittedly","followers_url":"https://api.github.com/users/seth-admittedly/followers","following_url":"https://api.github.com/users/seth-admittedly/following{/other_user}","gists_url":"https://api.github.com/users/seth-admittedly/gists{/gist_id}","starred_url":"https://api.github.com/users/seth-admittedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seth-admittedly/subscriptions","organizations_url":"https://api.github.com/users/seth-admittedly/orgs","repos_url":"https://api.github.com/users/seth-admittedly/repos","events_url":"https://api.github.com/users/seth-admittedly/events{/privacy}","received_events_url":"https://api.github.com/users/seth-admittedly/received_events","type":"User","site_admin":false},"repo":{"id":10742407,"name":"sequelize","full_name":"seth-admittedly/sequelize","owner":{"login":"seth-admittedly","id":4643337,"avatar_url":"https://avatars.githubusercontent.com/u/4643337?v=2","gravatar_id":"","url":"https://api.github.com/users/seth-admittedly","html_url":"https://github.com/seth-admittedly","followers_url":"https://api.github.com/users/seth-admittedly/followers","following_url":"https://api.github.com/users/seth-admittedly/following{/other_user}","gists_url":"https://api.github.com/users/seth-admittedly/gists{/gist_id}","starred_url":"https://api.github.com/users/seth-admittedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seth-admittedly/subscriptions","organizations_url":"https://api.github.com/users/seth-admittedly/orgs","repos_url":"https://api.github.com/users/seth-admittedly/repos","events_url":"https://api.github.com/users/seth-admittedly/events{/privacy}","received_events_url":"https://api.github.com/users/seth-admittedly/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/seth-admittedly/sequelize","description":"Sequelize is an easy-to-use multi sql dialect object-relationship-mapper for node.js. It currently supports MySQL, SQLite and PostgreSQL.","fork":true,"url":"https://api.github.com/repos/seth-admittedly/sequelize","forks_url":"https://api.github.com/repos/seth-admittedly/sequelize/forks","keys_url":"https://api.github.com/repos/seth-admittedly/sequelize/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seth-admittedly/sequelize/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seth-admittedly/sequelize/teams","hooks_url":"https://api.github.com/repos/seth-admittedly/sequelize/hooks","issue_events_url":"https://api.github.com/repos/seth-admittedly/sequelize/issues/events{/number}","events_url":"https://api.github.com/repos/seth-admittedly/sequelize/events","assignees_url":"https://api.github.com/repos/seth-admittedly/sequelize/assignees{/user}","branches_url":"https://api.github.com/repos/seth-admittedly/sequelize/branches{/branch}","tags_url":"https://api.github.com/repos/seth-admittedly/sequelize/tags","blobs_url":"https://api.github.com/repos/seth-admittedly/sequelize/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seth-admittedly/sequelize/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seth-admittedly/sequelize/git/refs{/sha}","trees_url":"https://api.github.com/repos/seth-admittedly/sequelize/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seth-admittedly/sequelize/statuses/{sha}","languages_url":"https://api.github.com/repos/seth-admittedly/sequelize/languages","stargazers_url":"https://api.github.com/repos/seth-admittedly/sequelize/stargazers","contributors_url":"https://api.github.com/repos/seth-admittedly/sequelize/contributors","subscribers_url":"https://api.github.com/repos/seth-admittedly/sequelize/subscribers","subscription_url":"https://api.github.com/repos/seth-admittedly/sequelize/subscription","commits_url":"https://api.github.com/repos/seth-admittedly/sequelize/commits{/sha}","git_commits_url":"https://api.github.com/repos/seth-admittedly/sequelize/git/commits{/sha}","comments_url":"https://api.github.com/repos/seth-admittedly/sequelize/comments{/number}","issue_comment_url":"https://api.github.com/repos/seth-admittedly/sequelize/issues/comments/{number}","contents_url":"https://api.github.com/repos/seth-admittedly/sequelize/contents/{+path}","compare_url":"https://api.github.com/repos/seth-admittedly/sequelize/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seth-admittedly/sequelize/merges","archive_url":"https://api.github.com/repos/seth-admittedly/sequelize/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seth-admittedly/sequelize/downloads","issues_url":"https://api.github.com/repos/seth-admittedly/sequelize/issues{/number}","pulls_url":"https://api.github.com/repos/seth-admittedly/sequelize/pulls{/number}","milestones_url":"https://api.github.com/repos/seth-admittedly/sequelize/milestones{/number}","notifications_url":"https://api.github.com/repos/seth-admittedly/sequelize/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seth-admittedly/sequelize/labels{/name}","releases_url":"https://api.github.com/repos/seth-admittedly/sequelize/releases{/id}","created_at":"2013-06-17T17:04:17Z","updated_at":"2014-07-31T01:03:00Z","pushed_at":"2014-11-06T17:41:01Z","git_url":"git://github.com/seth-admittedly/sequelize.git","ssh_url":"git@github.com:seth-admittedly/sequelize.git","clone_url":"https://github.com/seth-admittedly/sequelize.git","svn_url":"https://github.com/seth-admittedly/sequelize","homepage":"http://www.sequelizejs.com","size":35635,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sequelize:master","ref":"master","sha":"c6982f2cda654a3c977a0ba2cbdb556cc781e708","user":{"login":"sequelize","id":3591786,"avatar_url":"https://avatars.githubusercontent.com/u/3591786?v=2","gravatar_id":"","url":"https://api.github.com/users/sequelize","html_url":"https://github.com/sequelize","followers_url":"https://api.github.com/users/sequelize/followers","following_url":"https://api.github.com/users/sequelize/following{/other_user}","gists_url":"https://api.github.com/users/sequelize/gists{/gist_id}","starred_url":"https://api.github.com/users/sequelize/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequelize/subscriptions","organizations_url":"https://api.github.com/users/sequelize/orgs","repos_url":"https://api.github.com/users/sequelize/repos","events_url":"https://api.github.com/users/sequelize/events{/privacy}","received_events_url":"https://api.github.com/users/sequelize/received_events","type":"Organization","site_admin":false},"repo":{"id":790359,"name":"sequelize","full_name":"sequelize/sequelize","owner":{"login":"sequelize","id":3591786,"avatar_url":"https://avatars.githubusercontent.com/u/3591786?v=2","gravatar_id":"","url":"https://api.github.com/users/sequelize","html_url":"https://github.com/sequelize","followers_url":"https://api.github.com/users/sequelize/followers","following_url":"https://api.github.com/users/sequelize/following{/other_user}","gists_url":"https://api.github.com/users/sequelize/gists{/gist_id}","starred_url":"https://api.github.com/users/sequelize/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequelize/subscriptions","organizations_url":"https://api.github.com/users/sequelize/orgs","repos_url":"https://api.github.com/users/sequelize/repos","events_url":"https://api.github.com/users/sequelize/events{/privacy}","received_events_url":"https://api.github.com/users/sequelize/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sequelize/sequelize","description":"Sequelize is an easy-to-use multi sql dialect object-relationship-mapper for node.js. It currently supports MySQL, MariaDB, SQLite and PostgreSQL.","fork":false,"url":"https://api.github.com/repos/sequelize/sequelize","forks_url":"https://api.github.com/repos/sequelize/sequelize/forks","keys_url":"https://api.github.com/repos/sequelize/sequelize/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sequelize/sequelize/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sequelize/sequelize/teams","hooks_url":"https://api.github.com/repos/sequelize/sequelize/hooks","issue_events_url":"https://api.github.com/repos/sequelize/sequelize/issues/events{/number}","events_url":"https://api.github.com/repos/sequelize/sequelize/events","assignees_url":"https://api.github.com/repos/sequelize/sequelize/assignees{/user}","branches_url":"https://api.github.com/repos/sequelize/sequelize/branches{/branch}","tags_url":"https://api.github.com/repos/sequelize/sequelize/tags","blobs_url":"https://api.github.com/repos/sequelize/sequelize/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sequelize/sequelize/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sequelize/sequelize/git/refs{/sha}","trees_url":"https://api.github.com/repos/sequelize/sequelize/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sequelize/sequelize/statuses/{sha}","languages_url":"https://api.github.com/repos/sequelize/sequelize/languages","stargazers_url":"https://api.github.com/repos/sequelize/sequelize/stargazers","contributors_url":"https://api.github.com/repos/sequelize/sequelize/contributors","subscribers_url":"https://api.github.com/repos/sequelize/sequelize/subscribers","subscription_url":"https://api.github.com/repos/sequelize/sequelize/subscription","commits_url":"https://api.github.com/repos/sequelize/sequelize/commits{/sha}","git_commits_url":"https://api.github.com/repos/sequelize/sequelize/git/commits{/sha}","comments_url":"https://api.github.com/repos/sequelize/sequelize/comments{/number}","issue_comment_url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/{number}","contents_url":"https://api.github.com/repos/sequelize/sequelize/contents/{+path}","compare_url":"https://api.github.com/repos/sequelize/sequelize/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sequelize/sequelize/merges","archive_url":"https://api.github.com/repos/sequelize/sequelize/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sequelize/sequelize/downloads","issues_url":"https://api.github.com/repos/sequelize/sequelize/issues{/number}","pulls_url":"https://api.github.com/repos/sequelize/sequelize/pulls{/number}","milestones_url":"https://api.github.com/repos/sequelize/sequelize/milestones{/number}","notifications_url":"https://api.github.com/repos/sequelize/sequelize/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sequelize/sequelize/labels{/name}","releases_url":"https://api.github.com/repos/sequelize/sequelize/releases{/id}","created_at":"2010-07-22T07:11:11Z","updated_at":"2014-11-06T13:46:10Z","pushed_at":"2014-11-05T15:44:05Z","git_url":"git://github.com/sequelize/sequelize.git","ssh_url":"git@github.com:sequelize/sequelize.git","clone_url":"https://github.com/sequelize/sequelize.git","svn_url":"https://github.com/sequelize/sequelize","homepage":"http://sequelizejs.com","size":59071,"stargazers_count":2746,"watchers_count":2746,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":616,"mirror_url":null,"open_issues_count":283,"forks":616,"open_issues":283,"watchers":2746,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/2540"},"html":{"href":"https://github.com/sequelize/sequelize/pull/2540"},"issue":{"href":"https://api.github.com/repos/sequelize/sequelize/issues/2540"},"comments":{"href":"https://api.github.com/repos/sequelize/sequelize/issues/2540/comments"},"review_comments":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/2540/comments"},"review_comment":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/2540/commits"},"statuses":{"href":"https://api.github.com/repos/sequelize/sequelize/statuses/1c5971267d5e7b5d4c3d68ecdc8de0e9d299afb3"}}}}