ListClients()

This commit is contained in:
2022-11-19 12:47:23 +01:00
parent 35ef2175bc
commit f555f0f1cf
12 changed files with 307 additions and 19 deletions

View File

@@ -202,3 +202,22 @@ func (db *Database) UpdateUserProToken(ctx TxContext, userid int64, protoken *st
return nil
}
func (db *Database) ListClients(ctx TxContext, userid int64) ([]models.Client, error) {
tx, err := ctx.GetOrCreateTransaction(db)
if err != nil {
return nil, err
}
rows, err := tx.QueryContext(ctx, "SELECT * FROM clients WHERE user_id = ?", userid)
if err != nil {
return nil, err
}
data, err := models.DecodeClients(rows)
if err != nil {
return nil, err
}
return data, nil
}