go_import_excel_pg/internal/repository/alamat.repository.go

54 lines
958 B
Go
Raw Normal View History

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) CreateAlamat(ctx context.Context, arg model.Alamat) (model.Alamat, error) {
createAlamatQuery := `
INSERT INTO "Alamat" (
kategori,
negara,
provinsi,
kabupaten,
kecamatan,
kelurahan,
kode_pos,
nama_jalan,
rt,
rw,
no_hp,
no_telpon,
pasen_id,
status,
created_at,
updated_at,
) VALUES ($1,, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
RETURNING *
`
row, _ := q.db.Query(ctx, createAlamatQuery,
arg.Kategori,
arg.Negara,
arg.Provinsi,
arg.Kabupaten,
arg.Kecamatan,
arg.Kelurahan,
arg.Kode_pos,
arg.Nama_jalan,
arg.Rt,
arg.Rw,
arg.No_hp,
arg.No_telpon,
arg.Pasien_id,
arg.Status,
)
result, err := pgx.CollectExactlyOneRow[model.Alamat](row, pgx.RowToStructByName[model.Alamat])
return result, err
}