{"action":"opened","issue":{"url":"https://api.github.com/repos/go-pg/pg/issues/866","repository_url":"https://api.github.com/repos/go-pg/pg","labels_url":"https://api.github.com/repos/go-pg/pg/issues/866/labels{/name}","comments_url":"https://api.github.com/repos/go-pg/pg/issues/866/comments","events_url":"https://api.github.com/repos/go-pg/pg/issues/866/events","html_url":"https://github.com/go-pg/pg/issues/866","id":326617451,"number":866,"title":"Best practice on model inheritance","user":{"login":"Alireza-Ta","id":15876148,"avatar_url":"https://avatars0.githubusercontent.com/u/15876148?v=4","gravatar_id":"","url":"https://api.github.com/users/Alireza-Ta","html_url":"https://github.com/Alireza-Ta","followers_url":"https://api.github.com/users/Alireza-Ta/followers","following_url":"https://api.github.com/users/Alireza-Ta/following{/other_user}","gists_url":"https://api.github.com/users/Alireza-Ta/gists{/gist_id}","starred_url":"https://api.github.com/users/Alireza-Ta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alireza-Ta/subscriptions","organizations_url":"https://api.github.com/users/Alireza-Ta/orgs","repos_url":"https://api.github.com/users/Alireza-Ta/repos","events_url":"https://api.github.com/users/Alireza-Ta/events{/privacy}","received_events_url":"https://api.github.com/users/Alireza-Ta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-25T18:10:01Z","updated_at":"2018-05-25T18:10:01Z","closed_at":null,"author_association":"NONE","body":"Lets say i have these models\r\n\r\n```golang\r\ntype BaseModel struct {\r\n\tId        int       `json: \"id\"`\r\n\tCreatedAt time.Time `json:\"created_at\" sql:\"type:timestamptz, default:now()\"`\r\n\tUpdatedAt time.Time `json:\"updated_at\" sql:\"type:timestamptz\"`\r\n}\r\n```\r\n```golang\r\ntype Post struct {\r\n\tBaseModel `pg:\"override\"`\r\n\tAuthorID  int    `json:\"author_id\"`\r\n\tAuthor    *User  `json:\"author\"`\r\n\tVote      int    `json:\"vote\" sql:\"default:0\"`\r\n\tBody      string `json:\"body\" sql:\"type:text\"`\r\n}\r\n```\r\n```golang\r\ntype Question struct {\r\n\tPost     `pg:\"override\"`\r\n\tTitle    string    `json:\"title\"`\r\n\tComments []Comment `json:\"comments\" pg:\"many2many:comments_questions\"`\r\n}\r\n```\r\n```golang\r\ntype Comment struct {\r\n\tPost `pg:\"override\"`\r\n}\r\n```\r\nNow for example if i want to find a question by id i should do something like following:\r\n```golang\r\nq := &Question{\r\n\t\tPost: Post{\r\n\t\t\tBaseModel: BaseModel{\r\n\t\t\t\tId: 2,\r\n\t\t\t},\r\n\t\t},\r\n\t}\r\n\terr := db.Select(q)\r\n...\r\n```\r\nBut this initialization is somehow ugly to me!\r\nI know i can ignore inheritance and everything goes fine but is there any way to improve it or any better idea?\r\nThanks  "}}
{"actor":{"display_login":"Alireza-Ta"}}