{"action":"closed","issue":{"url":"https://api.github.com/repos/Vincit/objection.js/issues/147","repository_url":"https://api.github.com/repos/Vincit/objection.js","labels_url":"https://api.github.com/repos/Vincit/objection.js/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/Vincit/objection.js/issues/147/comments","events_url":"https://api.github.com/repos/Vincit/objection.js/issues/147/events","html_url":"https://github.com/Vincit/objection.js/issues/147","id":159749968,"number":147,"title":"Fetching pivot data from join table","user":{"login":"fl0w","id":71882,"avatar_url":"https://avatars.githubusercontent.com/u/71882?v=3","gravatar_id":"","url":"https://api.github.com/users/fl0w","html_url":"https://github.com/fl0w","followers_url":"https://api.github.com/users/fl0w/followers","following_url":"https://api.github.com/users/fl0w/following{/other_user}","gists_url":"https://api.github.com/users/fl0w/gists{/gist_id}","starred_url":"https://api.github.com/users/fl0w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fl0w/subscriptions","organizations_url":"https://api.github.com/users/fl0w/orgs","repos_url":"https://api.github.com/users/fl0w/repos","events_url":"https://api.github.com/users/fl0w/events{/privacy}","received_events_url":"https://api.github.com/users/fl0w/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-11T01:48:59Z","updated_at":"2016-06-11T10:31:53Z","closed_at":"2016-06-11T10:31:53Z","body":"I'm not sure if I'm missing something in docs, or if I'm approaching this the wrong way.\r\nI'm trying to get some values from the join table of a ManyToManyRelation while eager loading.\r\n\r\nI'd like to request support to fetch pivot data from join table, perhaps like so:\r\n```js\r\nclass MyModel extends Model {\r\n  static get relationMappings () {\r\n    return {\r\n      myOtherModels: {\r\n        relation: Model.ManyToManyRelation,\r\n        modelClass: MyOtherModel,\r\n        join: {\r\n          from: 'MyModel.id',\r\n          through: {\r\n            modelClass: MyJoinModel,\r\n            from: 'MyJoinModel.myModelId',\r\n            to: 'MyJoinModel.myOtherModelId',\r\n            // `select` to follow knex naming convention\r\n            // but could be `with`, or `include`\r\n            // bookshelfjs uses `withRelated`\r\n            select: ['column1', 'column2']\r\n          },\r\n          to: 'MyOtherModel.id'\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nNot sure if those against objection.js philosophy, in which case; How would I solve this in current (`-rc.5`) codebase? My guess is to use `context` and `onBuild` or `runBefore`, but would appreciate any pointer.\r\n\r\nOr perhaps the eager(fn) is to be played with to solve this?"}}
{"actor":{"display_login":"fl0w"}}