Build dynamic relationship in ember data


#1

I have access to API endpoints to only get, cannot suggest or apply any modifications.

This a sample schema of each api:

var person = DS.Model.extend {
    firstName: DS.attr(),
    lastName: DS.attr()
}

var credit = DS.Model.extend {
    name: DS.attr(),
    personId: : DS.belongsTo()
}

var debit = DS.Model.extend {
    name: DS.attr(),
    personId: : DS.belongsTo()
}

I can get api/person, api/credit, api/debit individually. After fetching the data. I want to map relationship between person and credit/debit similar to this…

var person = DS.Model.extend {
    firstName: DS.attr(),
    lastName: DS.attr(),
    **debits: DS.hasMany('debit'),**
    **credits: DS.hasMany('credit')**
}

How can I accomplish this in ember-data?