It is my understanding that the this is all by design. Internally, there is a RecordArrayManager that watches and responds to record changes in the store (adding a record, deleting a record, changing a record), and updates all RecordArrays that care about the model that has changed.
There is a RecordArray and a FilteredRecordArray (and an AdapterPopulatedRecordArray, but that’s not important here), but it is important to note that the RecordArray returned by store.all
, while it is not a FilteredRecordArray instance, it is technically filtered in that it is registered with the RecordArrayManager. Its filter is very simple: it shall contain every record in the store that is of this particular type, regardless of anything else about it–state, isDirty, isNew, isDeleted, etc. So when you display a list backed by the RecordArray returned by store.all
, it makes perfect sense that it immediately shows records that were just created via createRecord
.
What you actually want to do instead of store.all
is store.filter
and set your filter only returns records of that type that are not isNew
.
buildRecord
is private because the client should never be creating records without receiving them from the persistence layer. createRecord
creates records marked as dirty and new so that there can be a future point of synchronization with your persistence layer. If you need a record that is not dirty, you must retrieve it from the persistence layer (or some other trusted single source of truth, such as a local cache). Similarly, you shouldn’t use store.push
because that method expects the deserialized POJOs that are about to be pushed into the store to be of a very specific format (the responsibility of translating the format of the response from your persistence layer into the format that store.push
wants is left to your Adapter and your Serializer)
So while there is nothing saying that you can’t use buildRecord
, what Ember-Data wants you do to is use createRecord when you actually are creating a brand new record that does not exist in the persistence layer, and use store.filter
to make your list only show what you want it to show.
EDIT: I was incorrect when I said “it shall contain every record in the store that is of this particular type, regardless of anything else about it”. The only thing it cares about is whether or not the record isDeleted or isEmpty. Anything else will appear in your all
RecordArray:
https://github.com/emberjs/data/blob/v1.0.0-beta.3/packages/ember-data/lib/system/record_array_manager.js#L139