{"action":"created","comment":{"url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/comments/55712181","id":55712181,"diff_hunk":"@@ -29,26 +29,82 @@ mongoose.Promise = global.Promise;\n mongoose.connect('mongodb://localhost/mongoose-crud');\n \n /// ADD YOUR CODE BELOW\n+const db = mongoose.connection;\n+const done = function() {\n+  db.close();\n+};\n+const Movement = require('./models/movement.js');\n \n-const create = (name, description, startYear, endYear) => {};\n+const create = (name, description, startYear, endYear, ancestor) => {\n+  Movement.create({\n+    name: name,\n+    description: description,\n+    startYear: startYear,\n+    endYear: endYear,\n+    ancestor: ancestor\n+  }).then(function(movement) {\n+    console.log(movement.toJson());\n+  }).catch(function(error) {\n+    console.error(error);\n+  }).then(done);\n+};\n // Success -> Print new Movement as JSON\n // Failure -> Console.error\n \n-const index = () => {};\n+const index = () => {\n+  Movement.find().then(function(movement) {\n+    movement.forEach(function(movement) {\n+      console.log(movement.toJSON());\n+    });\n+  }).catch(console.error).then(done);\n+};\n // Success -> Print all Movements as JSON\n // Failure -> Console.error\n \n-const show = (id) => {};\n+const show = (id) => {\n+  Movement.findById(id).then(function(movement) {\n+    if (!movement){\n+      console.log(\"Not Found\");\n+    }\n+    else{\n+      console.log(movement.toJSON());\n+    }\n+  }).catch(console.error).then(done);\n+};\n // Success -> If the specified Movement exists, print it as JSON;\n //              otherwise, print \"Not Found\" and exit.\n // Failure -> Console.error\n \n-const update = (id, field, value) => {};\n+const update = (id, field, value) => {\n+  let modify = {};\n+  modify[field] = value;\n+  Movement.findByIdAndUpdate(id, { $set: modify }, { new: true })\n+    .then(function(movement) {\n+      if (!movement){\n+        console.log(\"Not Found\");\n+      }\n+      else {\n+        console.log(movement.toJSON());\n+      }\n+    })\n+    .catch(console.error)\n+    .then(done);\n+};\n // Success -> If the specified Movement exists, update it and print the\n //              updated Movement as JSON; otherwise, print \"Not Found\" and exit.\n // Failure -> Console.error\n \n-const destroy = (id) => {};\n+const destroy = (id) => {\n+  Movement.findById(id).then(function(movement) {\n+    if (!movement){\n+      console.log(\"Not Found\");\n+    }\n+    else {\n+      return movement.remove();\n+    }\n+  }).catch(console.error\n+  ).then(console.log(\"removed\")).then(done);\n+};","path":"diagnostic.js","position":84,"original_position":84,"commit_id":"f37a9a933a978c655102acebbbd064d0e4b077c8","original_commit_id":"f37a9a933a978c655102acebbbd064d0e4b077c8","user":{"login":"MattB-GA-Boston","id":3653013,"avatar_url":"https://avatars.githubusercontent.com/u/3653013?v=3","gravatar_id":"","url":"https://api.github.com/users/MattB-GA-Boston","html_url":"https://github.com/MattB-GA-Boston","followers_url":"https://api.github.com/users/MattB-GA-Boston/followers","following_url":"https://api.github.com/users/MattB-GA-Boston/following{/other_user}","gists_url":"https://api.github.com/users/MattB-GA-Boston/gists{/gist_id}","starred_url":"https://api.github.com/users/MattB-GA-Boston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattB-GA-Boston/subscriptions","organizations_url":"https://api.github.com/users/MattB-GA-Boston/orgs","repos_url":"https://api.github.com/users/MattB-GA-Boston/repos","events_url":"https://api.github.com/users/MattB-GA-Boston/events{/privacy}","received_events_url":"https://api.github.com/users/MattB-GA-Boston/received_events","type":"User","site_admin":false},"body":"Thought it's not strictly necessary to wait for Mongoose to delete the record before printing, I think doing so is absolutely a good decision.","created_at":"2016-03-10T17:03:59Z","updated_at":"2016-03-10T17:03:59Z","html_url":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic/pull/12#discussion_r55712181","pull_request_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/comments/55712181"},"html":{"href":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic/pull/12#discussion_r55712181"},"pull_request":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12","id":62397277,"html_url":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic/pull/12","diff_url":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic/pull/12.diff","patch_url":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic/pull/12.patch","issue_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/issues/12","number":12,"state":"open","locked":false,"title":"James Friedman Response","user":{"login":"jpfriedman18","id":11454266,"avatar_url":"https://avatars.githubusercontent.com/u/11454266?v=3","gravatar_id":"","url":"https://api.github.com/users/jpfriedman18","html_url":"https://github.com/jpfriedman18","followers_url":"https://api.github.com/users/jpfriedman18/followers","following_url":"https://api.github.com/users/jpfriedman18/following{/other_user}","gists_url":"https://api.github.com/users/jpfriedman18/gists{/gist_id}","starred_url":"https://api.github.com/users/jpfriedman18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpfriedman18/subscriptions","organizations_url":"https://api.github.com/users/jpfriedman18/orgs","repos_url":"https://api.github.com/users/jpfriedman18/repos","events_url":"https://api.github.com/users/jpfriedman18/events{/privacy}","received_events_url":"https://api.github.com/users/jpfriedman18/received_events","type":"User","site_admin":false},"body":"Comfort: 5\r\nClarity: 5\r\n\r\nI used the lesson repo and the Mongoose docs to help with this diagnostic","created_at":"2016-03-10T14:30:07Z","updated_at":"2016-03-10T17:03:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aee55ce4761598b278aea6e51b469690f24756e2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12/commits","review_comments_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12/comments","review_comment_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/issues/12/comments","statuses_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/statuses/f37a9a933a978c655102acebbbd064d0e4b077c8","head":{"label":"jpfriedman18:response","ref":"response","sha":"f37a9a933a978c655102acebbbd064d0e4b077c8","user":{"login":"jpfriedman18","id":11454266,"avatar_url":"https://avatars.githubusercontent.com/u/11454266?v=3","gravatar_id":"","url":"https://api.github.com/users/jpfriedman18","html_url":"https://github.com/jpfriedman18","followers_url":"https://api.github.com/users/jpfriedman18/followers","following_url":"https://api.github.com/users/jpfriedman18/following{/other_user}","gists_url":"https://api.github.com/users/jpfriedman18/gists{/gist_id}","starred_url":"https://api.github.com/users/jpfriedman18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpfriedman18/subscriptions","organizations_url":"https://api.github.com/users/jpfriedman18/orgs","repos_url":"https://api.github.com/users/jpfriedman18/repos","events_url":"https://api.github.com/users/jpfriedman18/events{/privacy}","received_events_url":"https://api.github.com/users/jpfriedman18/received_events","type":"User","site_admin":false},"repo":{"id":53588928,"name":"mongoose-crud-diagnostic","full_name":"jpfriedman18/mongoose-crud-diagnostic","owner":{"login":"jpfriedman18","id":11454266,"avatar_url":"https://avatars.githubusercontent.com/u/11454266?v=3","gravatar_id":"","url":"https://api.github.com/users/jpfriedman18","html_url":"https://github.com/jpfriedman18","followers_url":"https://api.github.com/users/jpfriedman18/followers","following_url":"https://api.github.com/users/jpfriedman18/following{/other_user}","gists_url":"https://api.github.com/users/jpfriedman18/gists{/gist_id}","starred_url":"https://api.github.com/users/jpfriedman18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpfriedman18/subscriptions","organizations_url":"https://api.github.com/users/jpfriedman18/orgs","repos_url":"https://api.github.com/users/jpfriedman18/repos","events_url":"https://api.github.com/users/jpfriedman18/events{/privacy}","received_events_url":"https://api.github.com/users/jpfriedman18/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jpfriedman18/mongoose-crud-diagnostic","description":"Diagnostic for materials on Mongoose CRUD","fork":true,"url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic","forks_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/forks","keys_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/teams","hooks_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/hooks","issue_events_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/issues/events{/number}","events_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/events","assignees_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/assignees{/user}","branches_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/branches{/branch}","tags_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/tags","blobs_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/git/refs{/sha}","trees_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/statuses/{sha}","languages_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/languages","stargazers_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/stargazers","contributors_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/contributors","subscribers_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/subscribers","subscription_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/subscription","commits_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/commits{/sha}","git_commits_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/git/commits{/sha}","comments_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/comments{/number}","issue_comment_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/issues/comments{/number}","contents_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/contents/{+path}","compare_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/merges","archive_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/downloads","issues_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/issues{/number}","pulls_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/pulls{/number}","milestones_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/milestones{/number}","notifications_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/labels{/name}","releases_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/releases{/id}","deployments_url":"https://api.github.com/repos/jpfriedman18/mongoose-crud-diagnostic/deployments","created_at":"2016-03-10T14:02:23Z","updated_at":"2016-03-10T14:02:24Z","pushed_at":"2016-03-10T14:29:06Z","git_url":"git://github.com/jpfriedman18/mongoose-crud-diagnostic.git","ssh_url":"git@github.com:jpfriedman18/mongoose-crud-diagnostic.git","clone_url":"https://github.com/jpfriedman18/mongoose-crud-diagnostic.git","svn_url":"https://github.com/jpfriedman18/mongoose-crud-diagnostic","homepage":null,"size":12,"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":"ga-wdi-boston:master","ref":"master","sha":"30959dddd7cc19e6b4da956d321257db48800b24","user":{"login":"ga-wdi-boston","id":6361298,"avatar_url":"https://avatars.githubusercontent.com/u/6361298?v=3","gravatar_id":"","url":"https://api.github.com/users/ga-wdi-boston","html_url":"https://github.com/ga-wdi-boston","followers_url":"https://api.github.com/users/ga-wdi-boston/followers","following_url":"https://api.github.com/users/ga-wdi-boston/following{/other_user}","gists_url":"https://api.github.com/users/ga-wdi-boston/gists{/gist_id}","starred_url":"https://api.github.com/users/ga-wdi-boston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ga-wdi-boston/subscriptions","organizations_url":"https://api.github.com/users/ga-wdi-boston/orgs","repos_url":"https://api.github.com/users/ga-wdi-boston/repos","events_url":"https://api.github.com/users/ga-wdi-boston/events{/privacy}","received_events_url":"https://api.github.com/users/ga-wdi-boston/received_events","type":"Organization","site_admin":false},"repo":{"id":53261091,"name":"mongoose-crud-diagnostic","full_name":"ga-wdi-boston/mongoose-crud-diagnostic","owner":{"login":"ga-wdi-boston","id":6361298,"avatar_url":"https://avatars.githubusercontent.com/u/6361298?v=3","gravatar_id":"","url":"https://api.github.com/users/ga-wdi-boston","html_url":"https://github.com/ga-wdi-boston","followers_url":"https://api.github.com/users/ga-wdi-boston/followers","following_url":"https://api.github.com/users/ga-wdi-boston/following{/other_user}","gists_url":"https://api.github.com/users/ga-wdi-boston/gists{/gist_id}","starred_url":"https://api.github.com/users/ga-wdi-boston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ga-wdi-boston/subscriptions","organizations_url":"https://api.github.com/users/ga-wdi-boston/orgs","repos_url":"https://api.github.com/users/ga-wdi-boston/repos","events_url":"https://api.github.com/users/ga-wdi-boston/events{/privacy}","received_events_url":"https://api.github.com/users/ga-wdi-boston/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic","description":"Diagnostic for materials on Mongoose CRUD","fork":false,"url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic","forks_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/forks","keys_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/teams","hooks_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/hooks","issue_events_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/issues/events{/number}","events_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/events","assignees_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/assignees{/user}","branches_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/branches{/branch}","tags_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/tags","blobs_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/git/refs{/sha}","trees_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/statuses/{sha}","languages_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/languages","stargazers_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/stargazers","contributors_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/contributors","subscribers_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/subscribers","subscription_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/subscription","commits_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/commits{/sha}","git_commits_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/git/commits{/sha}","comments_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/comments{/number}","issue_comment_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/issues/comments{/number}","contents_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/contents/{+path}","compare_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/merges","archive_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/downloads","issues_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/issues{/number}","pulls_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls{/number}","milestones_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/milestones{/number}","notifications_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/labels{/name}","releases_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/releases{/id}","deployments_url":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/deployments","created_at":"2016-03-06T15:16:43Z","updated_at":"2016-03-10T12:43:50Z","pushed_at":"2016-03-10T14:33:05Z","git_url":"git://github.com/ga-wdi-boston/mongoose-crud-diagnostic.git","ssh_url":"git@github.com:ga-wdi-boston/mongoose-crud-diagnostic.git","clone_url":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic.git","svn_url":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":12,"forks":15,"open_issues":12,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12"},"html":{"href":"https://github.com/ga-wdi-boston/mongoose-crud-diagnostic/pull/12"},"issue":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/issues/12"},"comments":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/ga-wdi-boston/mongoose-crud-diagnostic/statuses/f37a9a933a978c655102acebbbd064d0e4b077c8"}}}}