{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/821","labels_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/821/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/821/comments","events_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/821/events","html_url":"https://github.com/tgriesser/bookshelf/issues/821","id":93858086,"number":821,"title":"How to know programmactly when a model has relations?","user":{"login":"rkmax","id":395707,"avatar_url":"https://avatars.githubusercontent.com/u/395707?v=3","gravatar_id":"","url":"https://api.github.com/users/rkmax","html_url":"https://github.com/rkmax","followers_url":"https://api.github.com/users/rkmax/followers","following_url":"https://api.github.com/users/rkmax/following{/other_user}","gists_url":"https://api.github.com/users/rkmax/gists{/gist_id}","starred_url":"https://api.github.com/users/rkmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkmax/subscriptions","organizations_url":"https://api.github.com/users/rkmax/orgs","repos_url":"https://api.github.com/users/rkmax/repos","events_url":"https://api.github.com/users/rkmax/events{/privacy}","received_events_url":"https://api.github.com/users/rkmax/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tgriesser/bookshelf/labels/change","name":"change","color":"009800"},{"url":"https://api.github.com/repos/tgriesser/bookshelf/labels/discussion","name":"discussion","color":"fad8c7"},{"url":"https://api.github.com/repos/tgriesser/bookshelf/labels/relations","name":"relations","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-07-08T18:25:50Z","updated_at":"2015-07-09T01:38:47Z","closed_at":null,"body":"I have a model, example\r\n\r\n```\r\nvar Task = Bookshelf.Model.extend({\r\n  others: function() {\r\n    return this.hasMany(OtherModel);\r\n  },\r\n  getOther: function() {\r\n    return this.related('others');\r\n  }\r\n});\r\n```\r\n\r\nHow to know which are relations without call `.fetch({withRelated: [...]})`?"},"comment":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/comments/119778975","html_url":"https://github.com/tgriesser/bookshelf/issues/821#issuecomment-119778975","issue_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/821","id":119778975,"user":{"login":"rhys-vdw","id":822105,"avatar_url":"https://avatars.githubusercontent.com/u/822105?v=3","gravatar_id":"","url":"https://api.github.com/users/rhys-vdw","html_url":"https://github.com/rhys-vdw","followers_url":"https://api.github.com/users/rhys-vdw/followers","following_url":"https://api.github.com/users/rhys-vdw/following{/other_user}","gists_url":"https://api.github.com/users/rhys-vdw/gists{/gist_id}","starred_url":"https://api.github.com/users/rhys-vdw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhys-vdw/subscriptions","organizations_url":"https://api.github.com/users/rhys-vdw/orgs","repos_url":"https://api.github.com/users/rhys-vdw/repos","events_url":"https://api.github.com/users/rhys-vdw/events{/privacy}","received_events_url":"https://api.github.com/users/rhys-vdw/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T01:38:47Z","updated_at":"2015-07-09T01:38:47Z","body":"I think I might build a plugin that overrides `Model.extend`, adding an extra method that identifies all relations and adds them to an array using the method here https://github.com/tgriesser/bookshelf/pull/815#issuecomment-118842318.\r\n\r\nThis extra method (`Model#relationNames()` perhaps) would be a temporary fix until we've settled on a nicer API for relations.\r\n\r\nFeel free to make suggestions."}}