{"action":"closed","issue":{"url":"https://api.github.com/repos/Vincit/objection.js/issues/1032","repository_url":"https://api.github.com/repos/Vincit/objection.js","labels_url":"https://api.github.com/repos/Vincit/objection.js/issues/1032/labels{/name}","comments_url":"https://api.github.com/repos/Vincit/objection.js/issues/1032/comments","events_url":"https://api.github.com/repos/Vincit/objection.js/issues/1032/events","html_url":"https://github.com/Vincit/objection.js/issues/1032","id":347294160,"node_id":"MDU6SXNzdWUzNDcyOTQxNjA=","number":1032,"title":"Object relations without db tables","user":{"login":"wubzz","id":10179061,"node_id":"MDQ6VXNlcjEwMTc5MDYx","avatar_url":"https://avatars2.githubusercontent.com/u/10179061?v=4","gravatar_id":"","url":"https://api.github.com/users/wubzz","html_url":"https://github.com/wubzz","followers_url":"https://api.github.com/users/wubzz/followers","following_url":"https://api.github.com/users/wubzz/following{/other_user}","gists_url":"https://api.github.com/users/wubzz/gists{/gist_id}","starred_url":"https://api.github.com/users/wubzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wubzz/subscriptions","organizations_url":"https://api.github.com/users/wubzz/orgs","repos_url":"https://api.github.com/users/wubzz/repos","events_url":"https://api.github.com/users/wubzz/events{/privacy}","received_events_url":"https://api.github.com/users/wubzz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-03T07:47:04Z","updated_at":"2018-08-03T08:32:37Z","closed_at":"2018-08-03T08:32:37Z","author_association":"NONE","body":"I'm not sure how to describe this, so bare with me..\r\n\r\nCurrently working on incorporating objection.js into our pretty large application, primarily for the ease of formatting db/json response via `$parseDatabaseJson` and `$parseJson` but also for the `eager` loading which is very convenient to say the least. Previously we had a service to format models json <--> db on demand, which wasn't good in practise as we'd often miss calling these formatters.\r\n\r\nOur API consists of several hundered routes, some of which are objects built strictly around combining multiple tables into compact data, that is to say there is no dedicated database table for these objects. My issue right now is not being able to use objections markup for these objects since the relations depend on a join and is therefor a requirement.\r\n\r\nExample markup:\r\n\r\n```javascript\r\nclass Sub1 extends Model {}\r\nclass Sub2 extends Model {}\r\nclass Head extends Model {\r\n\tstatic get relationMappings() {\r\n\t\treturn {\r\n\t\t\tSub1: {\r\n\t\t\t\tmodelClass: Sub1,\r\n\t\t\t},\r\n\t\t\tSub2: {\r\n\t\t\t\tmodelClass: Sub2\r\n\t\t\t},\r\n\t\t};\r\n\t}\r\n}\r\n\r\n//Data loaded from multiple tables\r\nconst dataTableOne = [];\r\nconst dataTableTwo = [];\r\nconst dataTableThree = [];\r\n\r\n<-----Process data----->\r\n\r\n//Final data after processing data from multiple tables = API Response\r\nconst finalData = _.map([{ //Objects of Head, not yet Models\r\n\tSomeField: 'SomeValue', //Head field\r\n\tSub1: [{...}], //Objects of Sub1, not yet Models\r\n\tSub2: [{...}], //Objects of Sub2, not yet Models\r\n}, {...}], Head.fromJson); //Attempt to make Models\r\n```\r\n\r\nThis will yield a lot of errors, primarily about missing 'relation', 'join', 'tableName', etc on the relationMappings/model markup.\r\n\r\nIs there any way to workaround this and have Objection create the Head class with corresponding Relations modelClasses without specifying relation, joins, or tablenames?\r\n\r\nI realize this is probably a bit out of scope for the library and not what it's intended for, so feel free to close if need be."}}
{"actor":{"display_login":"wubzz"}}