2024-02-22 10:43:39 +07:00
|
|
|
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"
|
2024-02-23 14:10:40 +07:00
|
|
|
WHERE nama_wilayah = $1
|
2024-02-22 10:43:39 +07:00
|
|
|
`
|
|
|
|
|
|
|
|
row, _ := q.db.Query(ctx, findWilayaByNameQuery, name)
|
|
|
|
result, err := pgx.CollectExactlyOneRow[model.Wilayah](row, pgx.RowToStructByName[model.Wilayah])
|
|
|
|
|
|
|
|
return result, err
|
|
|
|
}
|