{"action":"created","issue":{"url":"https://api.github.com/repos/js-data/js-data/issues/392","repository_url":"https://api.github.com/repos/js-data/js-data","labels_url":"https://api.github.com/repos/js-data/js-data/issues/392/labels{/name}","comments_url":"https://api.github.com/repos/js-data/js-data/issues/392/comments","events_url":"https://api.github.com/repos/js-data/js-data/issues/392/events","html_url":"https://github.com/js-data/js-data/issues/392","id":170650938,"number":392,"title":"Allow a getter property to be used as a key","user":{"login":"SystemParadox","id":1228777,"avatar_url":"https://avatars.githubusercontent.com/u/1228777?v=3","gravatar_id":"","url":"https://api.github.com/users/SystemParadox","html_url":"https://github.com/SystemParadox","followers_url":"https://api.github.com/users/SystemParadox/followers","following_url":"https://api.github.com/users/SystemParadox/following{/other_user}","gists_url":"https://api.github.com/users/SystemParadox/gists{/gist_id}","starred_url":"https://api.github.com/users/SystemParadox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SystemParadox/subscriptions","organizations_url":"https://api.github.com/users/SystemParadox/orgs","repos_url":"https://api.github.com/users/SystemParadox/repos","events_url":"https://api.github.com/users/SystemParadox/events{/privacy}","received_events_url":"https://api.github.com/users/SystemParadox/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-11T13:52:07Z","updated_at":"2016-09-05T07:39:21Z","closed_at":null,"body":"It seems that js-data does not support compound primary keys. #116 is marked as wontfix.\r\n\r\nHowever, in #78, it is observed that you can create a computed property and use that as the key:\r\n\r\n```\r\nvar SongModel = DS.defineResource({\r\n  name: 'song',\r\n  idAttribute: 'compoundId',\r\n  computed: {\r\n    compoundId: ['albumID', 'trackNumber', function (albumID, trackNumber) {\r\n      return '' + albumID + '_' + trackNumber\r\n    }]\r\n  }\r\n});\r\n```\r\n\r\nHowever, this does not currently work with getter properties:\r\n\r\n```\r\nvar SongModel = DS.defineResource({\r\n  name: 'song',\r\n  idAttribute: 'compoundId',\r\n  computed: {\r\n    compoundId: {\r\n      get: function () {\r\n        return this.albumID + '_' + this.trackNumber\r\n      }\r\n    }]\r\n  }\r\n});\r\n```\r\n\r\nResults in `TypeError: Cannot read property 'apply' of undefined`. This is because it's assuming an array of `[field1, field2, func]`.\r\n\r\nIs this something that might be possible to implement?\r\n\r\nThis would allow the compoundId to be marked as `enumerable: false`, which would prevent it from being sent over the wire unnecessarily."},"comment":{"url":"https://api.github.com/repos/js-data/js-data/issues/comments/244678439","html_url":"https://github.com/js-data/js-data/issues/392#issuecomment-244678439","issue_url":"https://api.github.com/repos/js-data/js-data/issues/392","id":244678439,"user":{"login":"SystemParadox","id":1228777,"avatar_url":"https://avatars.githubusercontent.com/u/1228777?v=3","gravatar_id":"","url":"https://api.github.com/users/SystemParadox","html_url":"https://github.com/SystemParadox","followers_url":"https://api.github.com/users/SystemParadox/followers","following_url":"https://api.github.com/users/SystemParadox/following{/other_user}","gists_url":"https://api.github.com/users/SystemParadox/gists{/gist_id}","starred_url":"https://api.github.com/users/SystemParadox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SystemParadox/subscriptions","organizations_url":"https://api.github.com/users/SystemParadox/orgs","repos_url":"https://api.github.com/users/SystemParadox/repos","events_url":"https://api.github.com/users/SystemParadox/events{/privacy}","received_events_url":"https://api.github.com/users/SystemParadox/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T07:39:21Z","updated_at":"2016-09-05T07:39:21Z","body":"I did have a go with js-data 3.x but ran into similar issues. Is there any method which is supposed to work in js-data 3.x?"}}
{"actor":{"display_login":"SystemParadox"}}