21 lines
482 B
Go
21 lines
482 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.nochill.in/nochill/excel_import_playground/model"
|
|
"github.com/jackc/pgx/v5"
|
|
)
|
|
|
|
func (q *Queries) FindWilayahByName(ctx context.Context, name string) (model.Wilayah, error) {
|
|
findWilayaByNameQuery := `
|
|
SELECT * FROM "Wilayah"
|
|
WHERE nama_wilayah = $1
|
|
`
|
|
|
|
row, _ := q.db.Query(ctx, findWilayaByNameQuery, name)
|
|
result, err := pgx.CollectExactlyOneRow[model.Wilayah](row, pgx.RowToStructByName[model.Wilayah])
|
|
|
|
return result, err
|
|
}
|