User orgs api

This commit is contained in:
2015-03-05 22:25:26 +07:00
parent 317ee6e075
commit 1bcebaed59
4 changed files with 59 additions and 4 deletions
+30
View File
@@ -0,0 +1,30 @@
package db
type (
Org struct {
Login string
Descr string
ID int64
AvatarURL string
}
)
const (
userOrgsQuery = "select org from members where user = ?"
)
func UserOrgs(login string) (orgs []string) {
if res, err := stmt(userOrgsQuery).Query(login); err == nil {
defer res.Close()
for res.Next() {
var org string
if err := res.Scan(&org); err != nil {
panic(err)
}
orgs = append(orgs, org)
}
} else {
panic(err)
}
return
}