2024-02-22 10:43:39 +07:00
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-02-23 14:10:40 +07:00
|
|
|
"time"
|
2024-02-22 10:43:39 +07:00
|
|
|
|
|
|
|
"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,
|
2024-02-23 14:10:40 +07:00
|
|
|
pasien_id,
|
2024-02-22 10:43:39 +07:00
|
|
|
status,
|
2024-02-23 14:10:40 +07:00
|
|
|
updated_at
|
|
|
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
|
2024-02-22 10:43:39 +07:00
|
|
|
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,
|
2024-02-23 14:10:40 +07:00
|
|
|
time.Now().UTC(),
|
2024-02-22 10:43:39 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
result, err := pgx.CollectExactlyOneRow[model.Alamat](row, pgx.RowToStructByName[model.Alamat])
|
|
|
|
|
|
|
|
return result, err
|
|
|
|
}
|