migration to chi

This commit is contained in:
2025-03-12 16:30:40 +03:00
parent ae81fbcce9
commit 45bb32e7a6
46 changed files with 1352 additions and 1323 deletions
+21
View File
@@ -0,0 +1,21 @@
package database
type Club struct {
ID uint16 `json:"id"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Owner int `json:"-"`
IsPrivate bool `json:"is_private" db:"is_private"`
}
func GetClubs(userId int) ([]*Club, error) {
clubs := make([]*Club, 0)
err := Database.Select(&clubs, "select clubs.* from clubs join club_member cm on clubs.id = cm.club_id where not is_private or cm.user_id=$1;", userId)
return clubs, err
}
func GetClub(id int, userId uint64) (*Club, error) {
club := new(Club)
err := Database.Get(club, "select clubs.* from clubs join club_member cm on clubs.id = cm.club_id where club_id=$1 and (not is_private or cm.user_id=$2);", id, userId)
return club, err
}