{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/3530","labels_url":"https://api.github.com/repos/emberjs/data/issues/3530/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/3530/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/3530/events","html_url":"https://github.com/emberjs/data/issues/3530","id":94362540,"number":3530,"title":"Add a public API for adding and unshifting internalModels onto an existing RecordArray","user":{"login":"aortbals","id":871328,"avatar_url":"https://avatars.githubusercontent.com/u/871328?v=3","gravatar_id":"","url":"https://api.github.com/users/aortbals","html_url":"https://github.com/aortbals","followers_url":"https://api.github.com/users/aortbals/followers","following_url":"https://api.github.com/users/aortbals/following{/other_user}","gists_url":"https://api.github.com/users/aortbals/gists{/gist_id}","starred_url":"https://api.github.com/users/aortbals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aortbals/subscriptions","organizations_url":"https://api.github.com/users/aortbals/orgs","repos_url":"https://api.github.com/users/aortbals/repos","events_url":"https://api.github.com/users/aortbals/events{/privacy}","received_events_url":"https://api.github.com/users/aortbals/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-07-10T18:17:52Z","updated_at":"2015-09-12T07:09:01Z","closed_at":null,"body":"In our application, there are cases where adding a new record to an existing record array is necessary, sometimes at the beginning of the array. However, the API for this is unclear. This used to be possible, but isn't any longer. It has been the most difficult change in moving to the latest Ember Data `1.13.x` for us.\r\n\r\nAdding items to a `RecordArray` via `pushObject(s)`, `addObject(s)`, `unshiftObject(s)`, etc throws the following error, and it is difficult to debug because the backtrace doesn't show the root cause in some cases.\r\n\r\n> internalModel.getRecord is not a function\r\n\r\nDoes not work, used to work:\r\n\r\n```js\r\nthis.get('content').unshiftObject(item)\r\n```\r\n\r\n```js\r\nthis.get('content').pushObjects(items)\r\n```\r\n\r\n```js\r\nthis.get('content').pushObjects(items.toArray())\r\n```\r\n\r\nThe solution is to use the internal models:\r\n\r\n```js\r\nthis.get('content').unshiftObject(item._internalModel)\r\n```\r\n\r\n```js\r\nthis.get('content').pushObjects(items.content)\r\n```\r\n\r\nObviously this isn't ideal. Can we add a recommended API for adding or unshifting objects onto an existing record array without reaching for private methods? I'm sure that if these previously-working APIs were fixed it would help many upgrades.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/139737684","html_url":"https://github.com/emberjs/data/issues/3530#issuecomment-139737684","issue_url":"https://api.github.com/repos/emberjs/data/issues/3530","id":139737684,"user":{"login":"tchak","id":12428,"avatar_url":"https://avatars.githubusercontent.com/u/12428?v=3","gravatar_id":"","url":"https://api.github.com/users/tchak","html_url":"https://github.com/tchak","followers_url":"https://api.github.com/users/tchak/followers","following_url":"https://api.github.com/users/tchak/following{/other_user}","gists_url":"https://api.github.com/users/tchak/gists{/gist_id}","starred_url":"https://api.github.com/users/tchak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchak/subscriptions","organizations_url":"https://api.github.com/users/tchak/orgs","repos_url":"https://api.github.com/users/tchak/repos","events_url":"https://api.github.com/users/tchak/events{/privacy}","received_events_url":"https://api.github.com/users/tchak/received_events","type":"User","site_admin":false},"created_at":"2015-09-12T07:09:01Z","updated_at":"2015-09-12T07:09:01Z","body":"> Creating a record in some manner, persisting it on the server, and the unshifting it onto a hasMany relationship is what comes to mind. If you were to request the array again it actually would be identical.\r\n\r\n```\r\nstore.find('post').get('contacts').createRecord({ text: 'hello' });\r\n```\r\n\r\nor even this is supported I think\r\n\r\n```\r\ncontact = store.createRecord('contact', { text: 'hello' });\r\nstore.find('post').get('contacts').pushObject(contact);\r\n```\r\n\r\nHas many are definitly muttable."}}