diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-10-12 00:26:17 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-10-12 00:26:17 +0200 |
commit | 5fe93e048c3f529c80d2d1adb1e49eafebc1af3c (patch) | |
tree | 6cfaa78bc78403d1f913d342cc4625290ae9be3f /model | |
parent | b46012f212a4302b4d1325d8fdf9634e7083e76a (diff) | |
download | gosten-5fe93e048c3f529c80d2d1adb1e49eafebc1af3c.tar.gz gosten-5fe93e048c3f529c80d2d1adb1e49eafebc1af3c.tar.bz2 gosten-5fe93e048c3f529c80d2d1adb1e49eafebc1af3c.zip |
Sort categories on loading
Diffstat (limited to '')
-rw-r--r-- | model/categories.sql.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/model/categories.sql.go b/model/categories.sql.go index 74eb8a9..7df0cb3 100644 --- a/model/categories.sql.go +++ b/model/categories.sql.go @@ -9,31 +9,33 @@ import ( "context" ) -const getCategories = `-- name: GetCategories :many +const getCategoriesOrdered = `-- name: GetCategoriesOrdered :many SELECT id, name FROM categories WHERE user_id = $1 + ORDER BY name ASC ` -type GetCategoriesRow struct { +type GetCategoriesOrderedRow struct { ID int32 Name string } -// GetCategories +// GetCategoriesOrdered // // SELECT id, name // FROM categories // WHERE user_id = $1 -func (q *Queries) GetCategories(ctx context.Context, userID int32) ([]GetCategoriesRow, error) { - rows, err := q.db.Query(ctx, getCategories, userID) +// ORDER BY name ASC +func (q *Queries) GetCategoriesOrdered(ctx context.Context, userID int32) ([]GetCategoriesOrderedRow, error) { + rows, err := q.db.Query(ctx, getCategoriesOrdered, userID) if err != nil { return nil, err } defer rows.Close() - var items []GetCategoriesRow + var items []GetCategoriesOrderedRow for rows.Next() { - var i GetCategoriesRow + var i GetCategoriesOrderedRow if err := rows.Scan(&i.ID, &i.Name); err != nil { return nil, err } |