go_import_excel_pg/internal/repository/wilayah.repository.go
2024-02-23 14:10:40 +07:00

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
}