I have two ember models with a relationship like this
App.Foo = DS.Model.extend
bar: DS.belongsTo("App.Bar", embedded: true)
App.Bar = DS.Model.extend
primaryKey: "blah"
blah: DS.attr "string
If I create and save a new record like this:
foo = App.store.createRecord App.Foo
foo.set "bar", App.Bar.createRecord(blah: "blahblah")
App.store.commit()
I see 2 post requests to the server:
URL: /foos
Payload: {"foo":{"bar":null}}
and
URL: /bars
Payload: {"bar":{"blah":"blahblah"}}
The association is embedded so I would like to see:
URL: /foos
Payload: {"foo":{"bar":{"blah":"blahblah"}}}
Can I achieve this with the ember-data REST adapter or do I need to write my own code to do this?
Polymorphism. Polymorphism is a powerful concept which allows a developer to abstract common functionality into a base class. Consider the following example: a user with multiple payment methods. They could have a linked PayPal account, and a couple credit cards on file.
<br> `therefore` 512 cannot be the number of reflexive relations defined on a set A.
Class Store The store contains all of the data for records loaded from the server. It is also responsible for creating instances of Model that wrap the individual data for a record, so that they can be bound to in your Handlebars templates. Define your application's store like this: app/services/store.js.
I am observing the same behavior in my application. Setting 'embedded' to true only helps you get data as embedded, but while you post it separate requests will be generated. You have write your in code if you want to achieve it in one request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With