Closed
Description
Have you given much thought as to how to define multiple relationships to the same model? For example:
GET /document/1
{
id: 10,
name: 'My Awesome Document',
created_by: {
id: 5,
name: 'John Anderson'
},
modified_by: {
id: 7,
name: 'Wes Cruver'
}
}
Both created_by
and modified_by
may relate to the users
model, but as far as I can tell, there's no way to do this with the current way of defining relationships.
A backward-compatible way might be to allow an array:
DS.defineResource({
name: 'document',
relations: {
belongsTo: [
{
user: {
localField: 'created_by',
localKey: 'userId'
}
},
{
user: {
localField: 'modified_by',
localKey: 'userId'
}
}
]
}
}
Thoughts?