go_import_excel_pg/internal/repository/wilayah.repository.go
2024-02-22 10:43:39 +07:00

21 lines
481 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 NamaWilayah = $1
`
row, _ := q.db.Query(ctx, findWilayaByNameQuery, name)
result, err := pgx.CollectExactlyOneRow[model.Wilayah](row, pgx.RowToStructByName[model.Wilayah])
return result, err
}