I’m looking to extract out embedded records from the ActiveModelSerializer, it seems like something that should be used more on a model by model basis and is such a departure from the normal serializer anyways.
PR is here https://github.com/emberjs/data/pull/1505.
It is technically a breaking change, but there hasn’t even been an RC since it was added, so I’m comfortable with that
I’d love to hear opinions on this move, anyone particularly against it?
I’m particularly for it. I think embedded records should be treated as an atypical use case.
Ember Data is most useful when it has an opinion about how your data works. I’m reminded of this quote for the “Ember Data Progress Update”:
Ember Data will now focus on being the best possible library for Ember.js apps to communicate with consistent, conventional APIs.
The API conventions developing in Ember Data and jsonapi.org are really helpful. Without these guidelines everyone is making up their own stuff and usually struggling. If someone has unusual data structures (e.g. embedded records from a document-oriented database) it has to be up to them to present a sane and conventional API to the client.
That being said, I do empathize with situations where an API is impractical or impossible to change and understand that is it helpful to configure Ember Data for these cases.
Support for embedded records should be and also id-less embedded records should be supported. Ember data operates with JSON and nested data structure is a part of JSON. Currently ember-data is like Rails in early state when you can’t go sidestep.
@bradleypriest thanks for breaking out the DS.EmbeddedRecordsMixin that become very helpful for extending support for embedded records using Mongo, I ended up forking the DS.EmbeddedRecordsMixin, here: ember-data-extensions