{"action":"created","comment":{"url":"https://api.github.com/repos/exma-square/mobious/pulls/comments/36281366","id":36281366,"diff_hunk":"@@ -35,13 +39,43 @@ exports.create = function *() {\n exports.update = function *() {\n \n   let editPost = this.request.body;\n-\n   let UserId = services.user.getAuthStatus(this).sessionUser.id;\n-\n   let result = null;\n \n   try {\n-    let post = yield models.Post.findById(editPost.id);\n+    \n+    let post = yield models.Post.find({\n+      where: {\n+        id: editPost.id\n+      },\n+      include: [ { model: models.Tag } ]\n+    });\n+\n+    // Remove Tag\n+    post.Tags.forEach((tag,index) =>  {\n+      let state = editPost.tags.indexOf(tag.name);\n+      if(state === -1){\n+        // New Post Data not have this tag, Remove Tag.\n+        models.Tag.destroy({\n+          where:{\n+            id:tag.id\n+          }});\n+      }else {\n+        // Is exist remove in editTag\n+        editPost.tags.splice(state,1);\n+      }\n+    });\n+\n+    // Create Tag\n+    editPost.tags.forEach(tag =>{\n+      // Create new Tag\n+      models.Tag.create({","path":"server/controllers/post.js","position":52,"original_position":52,"commit_id":"a7814177f8ace4ab3d34a7b8aca6f3e37bd3c077","original_commit_id":"a7814177f8ace4ab3d34a7b8aca6f3e37bd3c077","user":{"login":"smlsunxie","id":1689227,"avatar_url":"https://avatars.githubusercontent.com/u/1689227?v=3","gravatar_id":"","url":"https://api.github.com/users/smlsunxie","html_url":"https://github.com/smlsunxie","followers_url":"https://api.github.com/users/smlsunxie/followers","following_url":"https://api.github.com/users/smlsunxie/following{/other_user}","gists_url":"https://api.github.com/users/smlsunxie/gists{/gist_id}","starred_url":"https://api.github.com/users/smlsunxie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smlsunxie/subscriptions","organizations_url":"https://api.github.com/users/smlsunxie/orgs","repos_url":"https://api.github.com/users/smlsunxie/repos","events_url":"https://api.github.com/users/smlsunxie/events{/privacy}","received_events_url":"https://api.github.com/users/smlsunxie/received_events","type":"User","site_admin":false},"body":"這邊沒有用 await 會不會有問題","created_at":"2015-08-05T08:55:55Z","updated_at":"2015-08-05T08:55:55Z","html_url":"https://github.com/exma-square/mobious/pull/23#discussion_r36281366","pull_request_url":"https://api.github.com/repos/exma-square/mobious/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/exma-square/mobious/pulls/comments/36281366"},"html":{"href":"https://github.com/exma-square/mobious/pull/23#discussion_r36281366"},"pull_request":{"href":"https://api.github.com/repos/exma-square/mobious/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/exma-square/mobious/pulls/23","id":41653922,"html_url":"https://github.com/exma-square/mobious/pull/23","diff_url":"https://github.com/exma-square/mobious/pull/23.diff","patch_url":"https://github.com/exma-square/mobious/pull/23.patch","issue_url":"https://api.github.com/repos/exma-square/mobious/issues/23","number":23,"state":"open","locked":false,"title":"Feature/post tags","user":{"login":"mrsunboss","id":3950196,"avatar_url":"https://avatars.githubusercontent.com/u/3950196?v=3","gravatar_id":"","url":"https://api.github.com/users/mrsunboss","html_url":"https://github.com/mrsunboss","followers_url":"https://api.github.com/users/mrsunboss/followers","following_url":"https://api.github.com/users/mrsunboss/following{/other_user}","gists_url":"https://api.github.com/users/mrsunboss/gists{/gist_id}","starred_url":"https://api.github.com/users/mrsunboss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrsunboss/subscriptions","organizations_url":"https://api.github.com/users/mrsunboss/orgs","repos_url":"https://api.github.com/users/mrsunboss/repos","events_url":"https://api.github.com/users/mrsunboss/events{/privacy}","received_events_url":"https://api.github.com/users/mrsunboss/received_events","type":"User","site_admin":false},"body":"![2015-08-05 16 20 05](https://cloud.githubusercontent.com/assets/3950196/9081326/f36657c6-3b8d-11e5-8f3b-c4cda282baf1.png)\r\n","created_at":"2015-08-05T08:21:05Z","updated_at":"2015-08-05T08:55:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee23fab2d30077519f56c594805b9228223e1fad","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/exma-square/mobious/pulls/23/commits","review_comments_url":"https://api.github.com/repos/exma-square/mobious/pulls/23/comments","review_comment_url":"https://api.github.com/repos/exma-square/mobious/pulls/comments{/number}","comments_url":"https://api.github.com/repos/exma-square/mobious/issues/23/comments","statuses_url":"https://api.github.com/repos/exma-square/mobious/statuses/a7814177f8ace4ab3d34a7b8aca6f3e37bd3c077","head":{"label":"mrsunboss:feature/post_tags","ref":"feature/post_tags","sha":"a7814177f8ace4ab3d34a7b8aca6f3e37bd3c077","user":{"login":"mrsunboss","id":3950196,"avatar_url":"https://avatars.githubusercontent.com/u/3950196?v=3","gravatar_id":"","url":"https://api.github.com/users/mrsunboss","html_url":"https://github.com/mrsunboss","followers_url":"https://api.github.com/users/mrsunboss/followers","following_url":"https://api.github.com/users/mrsunboss/following{/other_user}","gists_url":"https://api.github.com/users/mrsunboss/gists{/gist_id}","starred_url":"https://api.github.com/users/mrsunboss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrsunboss/subscriptions","organizations_url":"https://api.github.com/users/mrsunboss/orgs","repos_url":"https://api.github.com/users/mrsunboss/repos","events_url":"https://api.github.com/users/mrsunboss/events{/privacy}","received_events_url":"https://api.github.com/users/mrsunboss/received_events","type":"User","site_admin":false},"repo":{"id":39074673,"name":"mobious","full_name":"mrsunboss/mobious","owner":{"login":"mrsunboss","id":3950196,"avatar_url":"https://avatars.githubusercontent.com/u/3950196?v=3","gravatar_id":"","url":"https://api.github.com/users/mrsunboss","html_url":"https://github.com/mrsunboss","followers_url":"https://api.github.com/users/mrsunboss/followers","following_url":"https://api.github.com/users/mrsunboss/following{/other_user}","gists_url":"https://api.github.com/users/mrsunboss/gists{/gist_id}","starred_url":"https://api.github.com/users/mrsunboss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrsunboss/subscriptions","organizations_url":"https://api.github.com/users/mrsunboss/orgs","repos_url":"https://api.github.com/users/mrsunboss/repos","events_url":"https://api.github.com/users/mrsunboss/events{/privacy}","received_events_url":"https://api.github.com/users/mrsunboss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrsunboss/mobious","description":"","fork":true,"url":"https://api.github.com/repos/mrsunboss/mobious","forks_url":"https://api.github.com/repos/mrsunboss/mobious/forks","keys_url":"https://api.github.com/repos/mrsunboss/mobious/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrsunboss/mobious/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrsunboss/mobious/teams","hooks_url":"https://api.github.com/repos/mrsunboss/mobious/hooks","issue_events_url":"https://api.github.com/repos/mrsunboss/mobious/issues/events{/number}","events_url":"https://api.github.com/repos/mrsunboss/mobious/events","assignees_url":"https://api.github.com/repos/mrsunboss/mobious/assignees{/user}","branches_url":"https://api.github.com/repos/mrsunboss/mobious/branches{/branch}","tags_url":"https://api.github.com/repos/mrsunboss/mobious/tags","blobs_url":"https://api.github.com/repos/mrsunboss/mobious/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrsunboss/mobious/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrsunboss/mobious/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrsunboss/mobious/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrsunboss/mobious/statuses/{sha}","languages_url":"https://api.github.com/repos/mrsunboss/mobious/languages","stargazers_url":"https://api.github.com/repos/mrsunboss/mobious/stargazers","contributors_url":"https://api.github.com/repos/mrsunboss/mobious/contributors","subscribers_url":"https://api.github.com/repos/mrsunboss/mobious/subscribers","subscription_url":"https://api.github.com/repos/mrsunboss/mobious/subscription","commits_url":"https://api.github.com/repos/mrsunboss/mobious/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrsunboss/mobious/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrsunboss/mobious/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrsunboss/mobious/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrsunboss/mobious/contents/{+path}","compare_url":"https://api.github.com/repos/mrsunboss/mobious/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrsunboss/mobious/merges","archive_url":"https://api.github.com/repos/mrsunboss/mobious/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrsunboss/mobious/downloads","issues_url":"https://api.github.com/repos/mrsunboss/mobious/issues{/number}","pulls_url":"https://api.github.com/repos/mrsunboss/mobious/pulls{/number}","milestones_url":"https://api.github.com/repos/mrsunboss/mobious/milestones{/number}","notifications_url":"https://api.github.com/repos/mrsunboss/mobious/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrsunboss/mobious/labels{/name}","releases_url":"https://api.github.com/repos/mrsunboss/mobious/releases{/id}","created_at":"2015-07-14T12:53:35Z","updated_at":"2015-07-14T12:53:35Z","pushed_at":"2015-08-05T08:17:17Z","git_url":"git://github.com/mrsunboss/mobious.git","ssh_url":"git@github.com:mrsunboss/mobious.git","clone_url":"https://github.com/mrsunboss/mobious.git","svn_url":"https://github.com/mrsunboss/mobious","homepage":null,"size":743,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"exma-square:develop","ref":"develop","sha":"6b95ff31d603f21f327661f55c6a7073b90554a9","user":{"login":"exma-square","id":9804557,"avatar_url":"https://avatars.githubusercontent.com/u/9804557?v=3","gravatar_id":"","url":"https://api.github.com/users/exma-square","html_url":"https://github.com/exma-square","followers_url":"https://api.github.com/users/exma-square/followers","following_url":"https://api.github.com/users/exma-square/following{/other_user}","gists_url":"https://api.github.com/users/exma-square/gists{/gist_id}","starred_url":"https://api.github.com/users/exma-square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exma-square/subscriptions","organizations_url":"https://api.github.com/users/exma-square/orgs","repos_url":"https://api.github.com/users/exma-square/repos","events_url":"https://api.github.com/users/exma-square/events{/privacy}","received_events_url":"https://api.github.com/users/exma-square/received_events","type":"Organization","site_admin":false},"repo":{"id":35322650,"name":"mobious","full_name":"exma-square/mobious","owner":{"login":"exma-square","id":9804557,"avatar_url":"https://avatars.githubusercontent.com/u/9804557?v=3","gravatar_id":"","url":"https://api.github.com/users/exma-square","html_url":"https://github.com/exma-square","followers_url":"https://api.github.com/users/exma-square/followers","following_url":"https://api.github.com/users/exma-square/following{/other_user}","gists_url":"https://api.github.com/users/exma-square/gists{/gist_id}","starred_url":"https://api.github.com/users/exma-square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exma-square/subscriptions","organizations_url":"https://api.github.com/users/exma-square/orgs","repos_url":"https://api.github.com/users/exma-square/repos","events_url":"https://api.github.com/users/exma-square/events{/privacy}","received_events_url":"https://api.github.com/users/exma-square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/exma-square/mobious","description":"","fork":false,"url":"https://api.github.com/repos/exma-square/mobious","forks_url":"https://api.github.com/repos/exma-square/mobious/forks","keys_url":"https://api.github.com/repos/exma-square/mobious/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exma-square/mobious/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exma-square/mobious/teams","hooks_url":"https://api.github.com/repos/exma-square/mobious/hooks","issue_events_url":"https://api.github.com/repos/exma-square/mobious/issues/events{/number}","events_url":"https://api.github.com/repos/exma-square/mobious/events","assignees_url":"https://api.github.com/repos/exma-square/mobious/assignees{/user}","branches_url":"https://api.github.com/repos/exma-square/mobious/branches{/branch}","tags_url":"https://api.github.com/repos/exma-square/mobious/tags","blobs_url":"https://api.github.com/repos/exma-square/mobious/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exma-square/mobious/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exma-square/mobious/git/refs{/sha}","trees_url":"https://api.github.com/repos/exma-square/mobious/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exma-square/mobious/statuses/{sha}","languages_url":"https://api.github.com/repos/exma-square/mobious/languages","stargazers_url":"https://api.github.com/repos/exma-square/mobious/stargazers","contributors_url":"https://api.github.com/repos/exma-square/mobious/contributors","subscribers_url":"https://api.github.com/repos/exma-square/mobious/subscribers","subscription_url":"https://api.github.com/repos/exma-square/mobious/subscription","commits_url":"https://api.github.com/repos/exma-square/mobious/commits{/sha}","git_commits_url":"https://api.github.com/repos/exma-square/mobious/git/commits{/sha}","comments_url":"https://api.github.com/repos/exma-square/mobious/comments{/number}","issue_comment_url":"https://api.github.com/repos/exma-square/mobious/issues/comments{/number}","contents_url":"https://api.github.com/repos/exma-square/mobious/contents/{+path}","compare_url":"https://api.github.com/repos/exma-square/mobious/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exma-square/mobious/merges","archive_url":"https://api.github.com/repos/exma-square/mobious/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exma-square/mobious/downloads","issues_url":"https://api.github.com/repos/exma-square/mobious/issues{/number}","pulls_url":"https://api.github.com/repos/exma-square/mobious/pulls{/number}","milestones_url":"https://api.github.com/repos/exma-square/mobious/milestones{/number}","notifications_url":"https://api.github.com/repos/exma-square/mobious/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exma-square/mobious/labels{/name}","releases_url":"https://api.github.com/repos/exma-square/mobious/releases{/id}","created_at":"2015-05-09T09:19:43Z","updated_at":"2015-07-20T16:28:33Z","pushed_at":"2015-08-05T08:21:05Z","git_url":"git://github.com/exma-square/mobious.git","ssh_url":"git@github.com:exma-square/mobious.git","clone_url":"https://github.com/exma-square/mobious.git","svn_url":"https://github.com/exma-square/mobious","homepage":null,"size":1193,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":6,"forks":5,"open_issues":6,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/exma-square/mobious/pulls/23"},"html":{"href":"https://github.com/exma-square/mobious/pull/23"},"issue":{"href":"https://api.github.com/repos/exma-square/mobious/issues/23"},"comments":{"href":"https://api.github.com/repos/exma-square/mobious/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/exma-square/mobious/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/exma-square/mobious/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/exma-square/mobious/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/exma-square/mobious/statuses/a7814177f8ace4ab3d34a7b8aca6f3e37bd3c077"}}}}