some fixes and new features

This commit is contained in:
2026-01-23 15:14:21 +03:00
parent 336abd5517
commit 65e6dfabd7
9 changed files with 80 additions and 31 deletions

View File

@@ -62,6 +62,12 @@ func (rep *WaifuRepository) GetByUserId(userId int) ([]*Waifu, error) {
return waifus, nil
}
func (rep *WaifuRepository) GetCountByUserId(userId int) (int64, error) {
var count int64 = 0
err := rep.db.QueryRow("SELECT COUNT(*) FROM waifus WHERE owner_id=$1;", userId).Scan(&count)
return count, err
}
func (rep *WaifuRepository) GetFree() ([]*Waifu, error) {
waifus, err := sqlx.List[*Waifu](rep.db, "SELECT * FROM waifus WHERE owner_id IS NULL;")
return waifus, err