{"action":"created","comment":{"url":"https://api.github.com/repos/emberjs/guides/pulls/comments/181575414","pull_request_review_id":112230767,"id":181575414,"diff_hunk":"@@ -277,31 +277,37 @@ export default DS.Model.extend({\n });\n ```\n \n-When a user comments on a blogPost, we need to create a relationship between the two records. We can simply set the `belongsTo` relationship in our new comment:\n+Now, suppose we want to add comments to an existing blogPost. We can do this in two ways, but for both of them, we will first need a reference to our existing blogPost as given below:\n+\n+```javascript\n+let myBlogPost = this.get('store').peekRecord('blog-post', 1);\n+```\n+Now we can either set the `belongsTo` relationship in our new comment, or, update the blogPost's `hasMany` relationship. As you might observe, we don't need to set both `hasMany` and `belongsTo` for a record, ember data will do that for us.\n+\n+First, let's look at setting the `belongsTo` relationship in our new comment:\n \n ```javascript\n-let blogPost = this.get('store').peekRecord('blog-post', 1);\n let comment = this.get('store').createRecord('comment', {\n-  blogPost: blogPost\n+  blogPost: myBlogPost\n });\n comment.save();\n ```\n \n-This will create a new `comment` record and save it to the server. Ember Data will also update the blogPost to include our newly created comment in its `comments` relationship.\n+In the above snippet, we have referenced `myBlogPost` while creating the record. This will let ember know that the newly created comment belongs to `myBlogPost`.","path":"source/models/relationships.md","position":null,"original_position":42,"commit_id":"67a50b9210392e326654c6077f6756d7d94a5fcc","original_commit_id":"dc8cb29b23e928e60c47939167dab9766b2c8518","user":{"login":"karan-pathak","id":23016266,"avatar_url":"https://avatars2.githubusercontent.com/u/23016266?v=4","gravatar_id":"","url":"https://api.github.com/users/karan-pathak","html_url":"https://github.com/karan-pathak","followers_url":"https://api.github.com/users/karan-pathak/followers","following_url":"https://api.github.com/users/karan-pathak/following{/other_user}","gists_url":"https://api.github.com/users/karan-pathak/gists{/gist_id}","starred_url":"https://api.github.com/users/karan-pathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karan-pathak/subscriptions","organizations_url":"https://api.github.com/users/karan-pathak/orgs","repos_url":"https://api.github.com/users/karan-pathak/repos","events_url":"https://api.github.com/users/karan-pathak/events{/privacy}","received_events_url":"https://api.github.com/users/karan-pathak/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2018-04-15T09:00:06Z","updated_at":"2018-04-15T09:00:06Z","html_url":"https://github.com/emberjs/guides/pull/2318#discussion_r181575414","pull_request_url":"https://api.github.com/repos/emberjs/guides/pulls/2318","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/emberjs/guides/pulls/comments/181575414"},"html":{"href":"https://github.com/emberjs/guides/pull/2318#discussion_r181575414"},"pull_request":{"href":"https://api.github.com/repos/emberjs/guides/pulls/2318"}},"in_reply_to_id":181276084},"pull_request":{"url":"https://api.github.com/repos/emberjs/guides/pulls/2318","id":179418365,"html_url":"https://github.com/emberjs/guides/pull/2318","diff_url":"https://github.com/emberjs/guides/pull/2318.diff","patch_url":"https://github.com/emberjs/guides/pull/2318.patch","issue_url":"https://api.github.com/repos/emberjs/guides/issues/2318","number":2318,"state":"open","locked":false,"title":"update create record documentation for ember relationships","user":{"login":"karan-pathak","id":23016266,"avatar_url":"https://avatars2.githubusercontent.com/u/23016266?v=4","gravatar_id":"","url":"https://api.github.com/users/karan-pathak","html_url":"https://github.com/karan-pathak","followers_url":"https://api.github.com/users/karan-pathak/followers","following_url":"https://api.github.com/users/karan-pathak/following{/other_user}","gists_url":"https://api.github.com/users/karan-pathak/gists{/gist_id}","starred_url":"https://api.github.com/users/karan-pathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karan-pathak/subscriptions","organizations_url":"https://api.github.com/users/karan-pathak/orgs","repos_url":"https://api.github.com/users/karan-pathak/repos","events_url":"https://api.github.com/users/karan-pathak/events{/privacy}","received_events_url":"https://api.github.com/users/karan-pathak/received_events","type":"User","site_admin":false},"body":"#2307","created_at":"2018-04-04T14:57:16Z","updated_at":"2018-04-15T09:00:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ec5f921859b446c533bbb203d73e9808a67d9ed5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/emberjs/guides/pulls/2318/commits","review_comments_url":"https://api.github.com/repos/emberjs/guides/pulls/2318/comments","review_comment_url":"https://api.github.com/repos/emberjs/guides/pulls/comments{/number}","comments_url":"https://api.github.com/repos/emberjs/guides/issues/2318/comments","statuses_url":"https://api.github.com/repos/emberjs/guides/statuses/67a50b9210392e326654c6077f6756d7d94a5fcc","head":{"label":"karan-pathak:update/creating_record","ref":"update/creating_record","sha":"67a50b9210392e326654c6077f6756d7d94a5fcc","user":{"login":"karan-pathak","id":23016266,"avatar_url":"https://avatars2.githubusercontent.com/u/23016266?v=4","gravatar_id":"","url":"https://api.github.com/users/karan-pathak","html_url":"https://github.com/karan-pathak","followers_url":"https://api.github.com/users/karan-pathak/followers","following_url":"https://api.github.com/users/karan-pathak/following{/other_user}","gists_url":"https://api.github.com/users/karan-pathak/gists{/gist_id}","starred_url":"https://api.github.com/users/karan-pathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karan-pathak/subscriptions","organizations_url":"https://api.github.com/users/karan-pathak/orgs","repos_url":"https://api.github.com/users/karan-pathak/repos","events_url":"https://api.github.com/users/karan-pathak/events{/privacy}","received_events_url":"https://api.github.com/users/karan-pathak/received_events","type":"User","site_admin":false},"repo":{"id":127884718,"name":"guides","full_name":"karan-pathak/guides","owner":{"login":"karan-pathak","id":23016266,"avatar_url":"https://avatars2.githubusercontent.com/u/23016266?v=4","gravatar_id":"","url":"https://api.github.com/users/karan-pathak","html_url":"https://github.com/karan-pathak","followers_url":"https://api.github.com/users/karan-pathak/followers","following_url":"https://api.github.com/users/karan-pathak/following{/other_user}","gists_url":"https://api.github.com/users/karan-pathak/gists{/gist_id}","starred_url":"https://api.github.com/users/karan-pathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karan-pathak/subscriptions","organizations_url":"https://api.github.com/users/karan-pathak/orgs","repos_url":"https://api.github.com/users/karan-pathak/repos","events_url":"https://api.github.com/users/karan-pathak/events{/privacy}","received_events_url":"https://api.github.com/users/karan-pathak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/karan-pathak/guides","description":"The source for http://guides.emberjs.com","fork":true,"url":"https://api.github.com/repos/karan-pathak/guides","forks_url":"https://api.github.com/repos/karan-pathak/guides/forks","keys_url":"https://api.github.com/repos/karan-pathak/guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/karan-pathak/guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/karan-pathak/guides/teams","hooks_url":"https://api.github.com/repos/karan-pathak/guides/hooks","issue_events_url":"https://api.github.com/repos/karan-pathak/guides/issues/events{/number}","events_url":"https://api.github.com/repos/karan-pathak/guides/events","assignees_url":"https://api.github.com/repos/karan-pathak/guides/assignees{/user}","branches_url":"https://api.github.com/repos/karan-pathak/guides/branches{/branch}","tags_url":"https://api.github.com/repos/karan-pathak/guides/tags","blobs_url":"https://api.github.com/repos/karan-pathak/guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/karan-pathak/guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/karan-pathak/guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/karan-pathak/guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/karan-pathak/guides/statuses/{sha}","languages_url":"https://api.github.com/repos/karan-pathak/guides/languages","stargazers_url":"https://api.github.com/repos/karan-pathak/guides/stargazers","contributors_url":"https://api.github.com/repos/karan-pathak/guides/contributors","subscribers_url":"https://api.github.com/repos/karan-pathak/guides/subscribers","subscription_url":"https://api.github.com/repos/karan-pathak/guides/subscription","commits_url":"https://api.github.com/repos/karan-pathak/guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/karan-pathak/guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/karan-pathak/guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/karan-pathak/guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/karan-pathak/guides/contents/{+path}","compare_url":"https://api.github.com/repos/karan-pathak/guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/karan-pathak/guides/merges","archive_url":"https://api.github.com/repos/karan-pathak/guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/karan-pathak/guides/downloads","issues_url":"https://api.github.com/repos/karan-pathak/guides/issues{/number}","pulls_url":"https://api.github.com/repos/karan-pathak/guides/pulls{/number}","milestones_url":"https://api.github.com/repos/karan-pathak/guides/milestones{/number}","notifications_url":"https://api.github.com/repos/karan-pathak/guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/karan-pathak/guides/labels{/name}","releases_url":"https://api.github.com/repos/karan-pathak/guides/releases{/id}","deployments_url":"https://api.github.com/repos/karan-pathak/guides/deployments","created_at":"2018-04-03T09:32:38Z","updated_at":"2018-04-03T09:32:41Z","pushed_at":"2018-04-15T08:55:21Z","git_url":"git://github.com/karan-pathak/guides.git","ssh_url":"git@github.com:karan-pathak/guides.git","clone_url":"https://github.com/karan-pathak/guides.git","svn_url":"https://github.com/karan-pathak/guides","homepage":null,"size":39781,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"emberjs:master","ref":"master","sha":"5c0239b43865b48e2e960db582a33392a29ec3e1","user":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars2.githubusercontent.com/u/1253363?v=4","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"repo":{"id":22767401,"name":"guides","full_name":"emberjs/guides","owner":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars2.githubusercontent.com/u/1253363?v=4","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/emberjs/guides","description":"The source for http://guides.emberjs.com","fork":false,"url":"https://api.github.com/repos/emberjs/guides","forks_url":"https://api.github.com/repos/emberjs/guides/forks","keys_url":"https://api.github.com/repos/emberjs/guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emberjs/guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emberjs/guides/teams","hooks_url":"https://api.github.com/repos/emberjs/guides/hooks","issue_events_url":"https://api.github.com/repos/emberjs/guides/issues/events{/number}","events_url":"https://api.github.com/repos/emberjs/guides/events","assignees_url":"https://api.github.com/repos/emberjs/guides/assignees{/user}","branches_url":"https://api.github.com/repos/emberjs/guides/branches{/branch}","tags_url":"https://api.github.com/repos/emberjs/guides/tags","blobs_url":"https://api.github.com/repos/emberjs/guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emberjs/guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emberjs/guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/emberjs/guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emberjs/guides/statuses/{sha}","languages_url":"https://api.github.com/repos/emberjs/guides/languages","stargazers_url":"https://api.github.com/repos/emberjs/guides/stargazers","contributors_url":"https://api.github.com/repos/emberjs/guides/contributors","subscribers_url":"https://api.github.com/repos/emberjs/guides/subscribers","subscription_url":"https://api.github.com/repos/emberjs/guides/subscription","commits_url":"https://api.github.com/repos/emberjs/guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/emberjs/guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/emberjs/guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/emberjs/guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/emberjs/guides/contents/{+path}","compare_url":"https://api.github.com/repos/emberjs/guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emberjs/guides/merges","archive_url":"https://api.github.com/repos/emberjs/guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emberjs/guides/downloads","issues_url":"https://api.github.com/repos/emberjs/guides/issues{/number}","pulls_url":"https://api.github.com/repos/emberjs/guides/pulls{/number}","milestones_url":"https://api.github.com/repos/emberjs/guides/milestones{/number}","notifications_url":"https://api.github.com/repos/emberjs/guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emberjs/guides/labels{/name}","releases_url":"https://api.github.com/repos/emberjs/guides/releases{/id}","deployments_url":"https://api.github.com/repos/emberjs/guides/deployments","created_at":"2014-08-08T18:25:02Z","updated_at":"2018-04-09T01:36:32Z","pushed_at":"2018-04-15T08:55:23Z","git_url":"git://github.com/emberjs/guides.git","ssh_url":"git@github.com:emberjs/guides.git","clone_url":"https://github.com/emberjs/guides.git","svn_url":"https://github.com/emberjs/guides","homepage":null,"size":39752,"stargazers_count":302,"watchers_count":302,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1027,"mirror_url":null,"archived":false,"open_issues_count":97,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1027,"open_issues":97,"watchers":302,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/emberjs/guides/pulls/2318"},"html":{"href":"https://github.com/emberjs/guides/pull/2318"},"issue":{"href":"https://api.github.com/repos/emberjs/guides/issues/2318"},"comments":{"href":"https://api.github.com/repos/emberjs/guides/issues/2318/comments"},"review_comments":{"href":"https://api.github.com/repos/emberjs/guides/pulls/2318/comments"},"review_comment":{"href":"https://api.github.com/repos/emberjs/guides/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/emberjs/guides/pulls/2318/commits"},"statuses":{"href":"https://api.github.com/repos/emberjs/guides/statuses/67a50b9210392e326654c6077f6756d7d94a5fcc"}},"author_association":"NONE"}}
{"actor":{"display_login":"karan-pathak"}}