Open
Description
It seems that js-data does not support compound primary keys. #116 is marked as wontfix.
However, in #78, it is observed that you can create a computed property and use that as the key:
var SongModel = DS.defineResource({
name: 'song',
idAttribute: 'compoundId',
computed: {
compoundId: ['albumID', 'trackNumber', function (albumID, trackNumber) {
return '' + albumID + '_' + trackNumber
}]
}
});
However, this does not currently work with getter properties:
var SongModel = DS.defineResource({
name: 'song',
idAttribute: 'compoundId',
computed: {
compoundId: {
get: function () {
return this.albumID + '_' + this.trackNumber
}
}]
}
});
Results in TypeError: Cannot read property 'apply' of undefined
. This is because it's assuming an array of [field1, field2, func]
.
Is this something that might be possible to implement?
This would allow the compoundId to be marked as enumerable: false
, which would prevent it from being sent over the wire unnecessarily.