Cereal Killer
Cereal Killer

Reputation: 3414

Model relationships in Ember

Can someone explain the meaning of the option you can use for relationships in Ember data?

for example I can have:

products: DS.hasMany('product', {embedded: 'always'})

or

products: DS.hasMany('product', {async: 'true'})

The first one tells Ember data that products records are sideloaded and the second one tells to send asynchronous GET request for products when they are needed; is that right? These two are the only options available? Is there some place where you can find more docs about relationships?

Upvotes: 1

Views: 325

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Honestly documentation is kind of waiting on the api to solidify. The best place for documentation right now is the transition document https://github.com/emberjs/data/blob/master/TRANSITION.md and the source code https://github.com/emberjs/data .

Additionally {embedded: always} is deprecated/removed. Now you define embedded on the serializer whilst using the EmbeddedRecordsMixin.

App.PostSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
    attrs: {
      comments: {embedded: 'always'}
    }
  })

There is more info in the source here: https://github.com/emberjs/data/blob/master/packages/activemodel-adapter/lib/system/embedded_records_mixin.js

Upvotes: 2

Related Questions