Last active
January 25, 2017 19:44
-
-
Save benbabics/8f0b6c133d003a31a75dfff1af25ba01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Model.extend({ | |
users: hasMany( 'user', { inverse: 'company' } ), | |
usersBilling: hasMany( 'user', { inverse: 'billingCompany' } ), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Model.extend({ | |
company: belongsTo( 'account' ), | |
billingCompany: belongsTo( 'account' ) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// result (when serializers-user's `include` is commented out) | |
{ | |
user: { | |
id: "1", | |
billingCompanyId: "4", | |
companyId: "1" | |
} | |
} | |
// result (when serializers-user's `include` exists) | |
{ | |
user: { | |
id: "1", | |
billingCompanyId: "4", | |
account: { name: 'State of Maine' } | |
} | |
} | |
// expected | |
{ | |
user: { | |
id: "1", | |
billingCompany: { name: 'Washington County' }, | |
company: { name: 'State of Maine' } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const accounts = [ | |
server.create( 'account', { name: 'State of Maine' } ), | |
server.create( 'account', { name: 'Aroostook County' } ), | |
server.create( 'account', { name: 'Cumberland County' } ), | |
server.create( 'account', { name: 'Washington County' } ), | |
server.create( 'account', { name: 'Androscoggin County' } ) | |
]; | |
server.create('user', { | |
company: accounts[0], | |
billingCompany: accounts[3] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ApplicationSerializer.extend({ | |
include: [ 'company', 'billingCompany' ] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment