2015-03-05 15:25:26 +00:00
|
|
|
package db
|
|
|
|
|
2015-03-06 10:00:04 +00:00
|
|
|
type Org struct {
|
|
|
|
Login string `json:"login"`
|
|
|
|
Descr string `json:"descr"`
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
AvatarURL string `json:"avatar_url"`
|
|
|
|
}
|
2015-03-05 15:25:26 +00:00
|
|
|
|
2015-03-06 10:00:04 +00:00
|
|
|
const userOrgsQuery = `select o.* from members m join orgs o on o.login = m.org where user = ?`
|
2015-03-05 15:25:26 +00:00
|
|
|
|
2015-03-05 16:06:45 +00:00
|
|
|
func UserOrgs(login string) (orgs []*Org) {
|
2015-03-06 10:00:04 +00:00
|
|
|
if err := conn.Select(&orgs, userOrgsQuery, login); err != nil {
|
2015-03-05 15:25:26 +00:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|