734 lines
16 KiB
Go
734 lines
16 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: edastore.sql
|
|
|
|
package postgresdb
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const armedBindingsForSource = `-- name: ArmedBindingsForSource :many
|
|
SELECT id, name, source, mapping, workflow, owner, repo, version, status, secret, created_at, updated_at
|
|
FROM bindings WHERE source = $1 AND status = 'armed' ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ArmedBindingsForSource(ctx context.Context, source string) ([]Binding, error) {
|
|
rows, err := q.db.Query(ctx, armedBindingsForSource, source)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Binding
|
|
for rows.Next() {
|
|
var i Binding
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Source,
|
|
&i.Mapping,
|
|
&i.Workflow,
|
|
&i.Owner,
|
|
&i.Repo,
|
|
&i.Version,
|
|
&i.Status,
|
|
&i.Secret,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const deleteBinding = `-- name: DeleteBinding :execrows
|
|
DELETE FROM bindings WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteBinding(ctx context.Context, id string) (int64, error) {
|
|
result, err := q.db.Exec(ctx, deleteBinding, id)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const deleteCapturesBeyondCount = `-- name: DeleteCapturesBeyondCount :exec
|
|
DELETE FROM captures WHERE id NOT IN (
|
|
SELECT id FROM captures ORDER BY received_at DESC LIMIT $1
|
|
)
|
|
`
|
|
|
|
func (q *Queries) DeleteCapturesBeyondCount(ctx context.Context, limit int32) error {
|
|
_, err := q.db.Exec(ctx, deleteCapturesBeyondCount, limit)
|
|
return err
|
|
}
|
|
|
|
const deleteCapturesOlderThan = `-- name: DeleteCapturesOlderThan :exec
|
|
DELETE FROM captures WHERE received_at < $1
|
|
`
|
|
|
|
func (q *Queries) DeleteCapturesOlderThan(ctx context.Context, receivedAt time.Time) error {
|
|
_, err := q.db.Exec(ctx, deleteCapturesOlderThan, receivedAt)
|
|
return err
|
|
}
|
|
|
|
const deleteEventType = `-- name: DeleteEventType :execrows
|
|
DELETE FROM event_types WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteEventType(ctx context.Context, id string) (int64, error) {
|
|
result, err := q.db.Exec(ctx, deleteEventType, id)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const deleteMapping = `-- name: DeleteMapping :execrows
|
|
DELETE FROM mappings WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteMapping(ctx context.Context, id string) (int64, error) {
|
|
result, err := q.db.Exec(ctx, deleteMapping, id)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const deletePlaybookDispatches = `-- name: DeletePlaybookDispatches :exec
|
|
DELETE FROM playbook_dispatches WHERE playbook_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeletePlaybookDispatches(ctx context.Context, playbookID string) error {
|
|
_, err := q.db.Exec(ctx, deletePlaybookDispatches, playbookID)
|
|
return err
|
|
}
|
|
|
|
const eventTypesForSource = `-- name: EventTypesForSource :many
|
|
SELECT id, source, name, rule, schema, created_at, updated_at
|
|
FROM event_types WHERE source = $1 ORDER BY name
|
|
`
|
|
|
|
func (q *Queries) EventTypesForSource(ctx context.Context, source string) ([]EventType, error) {
|
|
rows, err := q.db.Query(ctx, eventTypesForSource, source)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []EventType
|
|
for rows.Next() {
|
|
var i EventType
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Source,
|
|
&i.Name,
|
|
&i.Rule,
|
|
&i.Schema,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getBinding = `-- name: GetBinding :one
|
|
SELECT id, name, source, mapping, workflow, owner, repo, version, status, secret, created_at, updated_at
|
|
FROM bindings WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetBinding(ctx context.Context, id string) (Binding, error) {
|
|
row := q.db.QueryRow(ctx, getBinding, id)
|
|
var i Binding
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Source,
|
|
&i.Mapping,
|
|
&i.Workflow,
|
|
&i.Owner,
|
|
&i.Repo,
|
|
&i.Version,
|
|
&i.Status,
|
|
&i.Secret,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getEventType = `-- name: GetEventType :one
|
|
SELECT id, source, name, rule, schema, created_at, updated_at
|
|
FROM event_types WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetEventType(ctx context.Context, id string) (EventType, error) {
|
|
row := q.db.QueryRow(ctx, getEventType, id)
|
|
var i EventType
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Source,
|
|
&i.Name,
|
|
&i.Rule,
|
|
&i.Schema,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getMapping = `-- name: GetMapping :one
|
|
SELECT id, name, source_hint, fields, created_at, updated_at
|
|
FROM mappings WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetMapping(ctx context.Context, id string) (Mapping, error) {
|
|
row := q.db.QueryRow(ctx, getMapping, id)
|
|
var i Mapping
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.SourceHint,
|
|
&i.Fields,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertBinding = `-- name: InsertBinding :exec
|
|
INSERT INTO bindings (id, name, source, mapping, workflow, owner, repo, version, status, secret)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, 1, $8, $9)
|
|
`
|
|
|
|
type InsertBindingParams struct {
|
|
ID string
|
|
Name string
|
|
Source string
|
|
Mapping string
|
|
Workflow string
|
|
Owner string
|
|
Repo string
|
|
Status string
|
|
Secret string
|
|
}
|
|
|
|
func (q *Queries) InsertBinding(ctx context.Context, arg InsertBindingParams) error {
|
|
_, err := q.db.Exec(ctx, insertBinding,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.Source,
|
|
arg.Mapping,
|
|
arg.Workflow,
|
|
arg.Owner,
|
|
arg.Repo,
|
|
arg.Status,
|
|
arg.Secret,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertBindingDispatch = `-- name: InsertBindingDispatch :exec
|
|
INSERT INTO binding_dispatches (binding, binding_version, capture, task_id)
|
|
VALUES ($1, $2, $3, $4)
|
|
`
|
|
|
|
type InsertBindingDispatchParams struct {
|
|
Binding string
|
|
BindingVersion int64
|
|
Capture string
|
|
TaskID int64
|
|
}
|
|
|
|
func (q *Queries) InsertBindingDispatch(ctx context.Context, arg InsertBindingDispatchParams) error {
|
|
_, err := q.db.Exec(ctx, insertBindingDispatch,
|
|
arg.Binding,
|
|
arg.BindingVersion,
|
|
arg.Capture,
|
|
arg.TaskID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertCapture = `-- name: InsertCapture :exec
|
|
|
|
INSERT INTO captures (id, source, remote_addr, content_type, headers, body, authenticated, received_at, event_type)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
`
|
|
|
|
type InsertCaptureParams struct {
|
|
ID string
|
|
Source string
|
|
RemoteAddr string
|
|
ContentType string
|
|
Headers string
|
|
Body string
|
|
Authenticated bool
|
|
ReceivedAt time.Time
|
|
EventType string
|
|
}
|
|
|
|
// EDA queries: captures, mappings, bindings, dispatch ledgers, tool_calls.
|
|
func (q *Queries) InsertCapture(ctx context.Context, arg InsertCaptureParams) error {
|
|
_, err := q.db.Exec(ctx, insertCapture,
|
|
arg.ID,
|
|
arg.Source,
|
|
arg.RemoteAddr,
|
|
arg.ContentType,
|
|
arg.Headers,
|
|
arg.Body,
|
|
arg.Authenticated,
|
|
arg.ReceivedAt,
|
|
arg.EventType,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertEventType = `-- name: InsertEventType :exec
|
|
INSERT INTO event_types (id, source, name, rule, schema)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
`
|
|
|
|
type InsertEventTypeParams struct {
|
|
ID string
|
|
Source string
|
|
Name string
|
|
Rule string
|
|
Schema string
|
|
}
|
|
|
|
func (q *Queries) InsertEventType(ctx context.Context, arg InsertEventTypeParams) error {
|
|
_, err := q.db.Exec(ctx, insertEventType,
|
|
arg.ID,
|
|
arg.Source,
|
|
arg.Name,
|
|
arg.Rule,
|
|
arg.Schema,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertMapping = `-- name: InsertMapping :exec
|
|
INSERT INTO mappings (id, name, source_hint, fields)
|
|
VALUES ($1, $2, $3, $4)
|
|
`
|
|
|
|
type InsertMappingParams struct {
|
|
ID string
|
|
Name string
|
|
SourceHint string
|
|
Fields string
|
|
}
|
|
|
|
func (q *Queries) InsertMapping(ctx context.Context, arg InsertMappingParams) error {
|
|
_, err := q.db.Exec(ctx, insertMapping,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.SourceHint,
|
|
arg.Fields,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertPlaybookDispatch = `-- name: InsertPlaybookDispatch :exec
|
|
INSERT INTO playbook_dispatches (playbook_id, playbook_version, event_id, action_id)
|
|
VALUES ($1, $2, $3, $4)
|
|
`
|
|
|
|
type InsertPlaybookDispatchParams struct {
|
|
PlaybookID string
|
|
PlaybookVersion string
|
|
EventID string
|
|
ActionID string
|
|
}
|
|
|
|
func (q *Queries) InsertPlaybookDispatch(ctx context.Context, arg InsertPlaybookDispatchParams) error {
|
|
_, err := q.db.Exec(ctx, insertPlaybookDispatch,
|
|
arg.PlaybookID,
|
|
arg.PlaybookVersion,
|
|
arg.EventID,
|
|
arg.ActionID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertToolCall = `-- name: InsertToolCall :exec
|
|
INSERT INTO tool_calls (id, task_id, attempt, tool, result, error, called_at)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
`
|
|
|
|
type InsertToolCallParams struct {
|
|
ID string
|
|
TaskID int64
|
|
Attempt int64
|
|
Tool string
|
|
Result string
|
|
Error string
|
|
CalledAt time.Time
|
|
}
|
|
|
|
func (q *Queries) InsertToolCall(ctx context.Context, arg InsertToolCallParams) error {
|
|
_, err := q.db.Exec(ctx, insertToolCall,
|
|
arg.ID,
|
|
arg.TaskID,
|
|
arg.Attempt,
|
|
arg.Tool,
|
|
arg.Result,
|
|
arg.Error,
|
|
arg.CalledAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const listBindings = `-- name: ListBindings :many
|
|
SELECT id, name, source, mapping, workflow, owner, repo, version, status, secret, created_at, updated_at
|
|
FROM bindings ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListBindings(ctx context.Context) ([]Binding, error) {
|
|
rows, err := q.db.Query(ctx, listBindings)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Binding
|
|
for rows.Next() {
|
|
var i Binding
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Source,
|
|
&i.Mapping,
|
|
&i.Workflow,
|
|
&i.Owner,
|
|
&i.Repo,
|
|
&i.Version,
|
|
&i.Status,
|
|
&i.Secret,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listCaptures = `-- name: ListCaptures :many
|
|
SELECT id, source, remote_addr, content_type, headers, body, authenticated, received_at, event_type
|
|
FROM captures
|
|
ORDER BY received_at DESC
|
|
LIMIT $1
|
|
`
|
|
|
|
func (q *Queries) ListCaptures(ctx context.Context, limit int32) ([]Capture, error) {
|
|
rows, err := q.db.Query(ctx, listCaptures, limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Capture
|
|
for rows.Next() {
|
|
var i Capture
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Source,
|
|
&i.RemoteAddr,
|
|
&i.ContentType,
|
|
&i.Headers,
|
|
&i.Body,
|
|
&i.Authenticated,
|
|
&i.ReceivedAt,
|
|
&i.EventType,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listEventTypes = `-- name: ListEventTypes :many
|
|
SELECT id, source, name, rule, schema, created_at, updated_at
|
|
FROM event_types ORDER BY source, name
|
|
`
|
|
|
|
func (q *Queries) ListEventTypes(ctx context.Context) ([]EventType, error) {
|
|
rows, err := q.db.Query(ctx, listEventTypes)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []EventType
|
|
for rows.Next() {
|
|
var i EventType
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Source,
|
|
&i.Name,
|
|
&i.Rule,
|
|
&i.Schema,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listMappings = `-- name: ListMappings :many
|
|
SELECT id, name, source_hint, fields, created_at, updated_at
|
|
FROM mappings ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListMappings(ctx context.Context) ([]Mapping, error) {
|
|
rows, err := q.db.Query(ctx, listMappings)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Mapping
|
|
for rows.Next() {
|
|
var i Mapping
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.SourceHint,
|
|
&i.Fields,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listUndispatchedCaptures = `-- name: ListUndispatchedCaptures :many
|
|
SELECT id, source, remote_addr, content_type, headers, body, authenticated, received_at, event_type
|
|
FROM captures
|
|
WHERE source = ANY($1::text[])
|
|
-- An unidentified capture is never dispatched.
|
|
AND event_type <> ''
|
|
AND id NOT IN (SELECT capture FROM binding_dispatches)
|
|
ORDER BY received_at DESC
|
|
LIMIT $2
|
|
`
|
|
|
|
type ListUndispatchedCapturesParams struct {
|
|
Sources []string
|
|
EntryLimit int32
|
|
}
|
|
|
|
func (q *Queries) ListUndispatchedCaptures(ctx context.Context, arg ListUndispatchedCapturesParams) ([]Capture, error) {
|
|
rows, err := q.db.Query(ctx, listUndispatchedCaptures, arg.Sources, arg.EntryLimit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Capture
|
|
for rows.Next() {
|
|
var i Capture
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Source,
|
|
&i.RemoteAddr,
|
|
&i.ContentType,
|
|
&i.Headers,
|
|
&i.Body,
|
|
&i.Authenticated,
|
|
&i.ReceivedAt,
|
|
&i.EventType,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const lockEventTypeSource = `-- name: LockEventTypeSource :exec
|
|
SELECT pg_advisory_xact_lock(hashtext('event_types:' || $1::text))
|
|
`
|
|
|
|
// Serialises saves per source so two concurrent saves cannot each pass the
|
|
// overlap check against a set that excludes the other.
|
|
func (q *Queries) LockEventTypeSource(ctx context.Context, source string) error {
|
|
_, err := q.db.Exec(ctx, lockEventTypeSource, source)
|
|
return err
|
|
}
|
|
|
|
const setBindingArmed = `-- name: SetBindingArmed :execrows
|
|
UPDATE bindings SET status = 'armed', updated_at = now() WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) SetBindingArmed(ctx context.Context, id string) (int64, error) {
|
|
result, err := q.db.Exec(ctx, setBindingArmed, id)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const taskToolCalls = `-- name: TaskToolCalls :many
|
|
SELECT id, task_id, attempt, tool, result, error, called_at
|
|
FROM tool_calls WHERE task_id = $1 ORDER BY called_at ASC
|
|
`
|
|
|
|
type TaskToolCallsRow struct {
|
|
ID string
|
|
TaskID int64
|
|
Attempt int64
|
|
Tool string
|
|
Result string
|
|
Error string
|
|
CalledAt time.Time
|
|
}
|
|
|
|
func (q *Queries) TaskToolCalls(ctx context.Context, taskID int64) ([]TaskToolCallsRow, error) {
|
|
rows, err := q.db.Query(ctx, taskToolCalls, taskID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []TaskToolCallsRow
|
|
for rows.Next() {
|
|
var i TaskToolCallsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.TaskID,
|
|
&i.Attempt,
|
|
&i.Tool,
|
|
&i.Result,
|
|
&i.Error,
|
|
&i.CalledAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateBinding = `-- name: UpdateBinding :execrows
|
|
UPDATE bindings
|
|
SET name = $2, source = $3, mapping = $4, workflow = $5, owner = $6, repo = $7,
|
|
version = version + 1, status = $8,
|
|
secret = CASE WHEN $9::text = '' THEN secret ELSE $9 END,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
`
|
|
|
|
type UpdateBindingParams struct {
|
|
ID string
|
|
Name string
|
|
Source string
|
|
Mapping string
|
|
Workflow string
|
|
Owner string
|
|
Repo string
|
|
Status string
|
|
Secret string
|
|
}
|
|
|
|
// An empty secret means "keep the stored one": the CASE leaves the column
|
|
// untouched so an edit form that does not echo the secret cannot blank an
|
|
// armed binding's HMAC key.
|
|
func (q *Queries) UpdateBinding(ctx context.Context, arg UpdateBindingParams) (int64, error) {
|
|
result, err := q.db.Exec(ctx, updateBinding,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.Source,
|
|
arg.Mapping,
|
|
arg.Workflow,
|
|
arg.Owner,
|
|
arg.Repo,
|
|
arg.Status,
|
|
arg.Secret,
|
|
)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const updateEventType = `-- name: UpdateEventType :execrows
|
|
UPDATE event_types SET name = $2, rule = $3, updated_at = now() WHERE id = $1
|
|
`
|
|
|
|
type UpdateEventTypeParams struct {
|
|
ID string
|
|
Name string
|
|
Rule string
|
|
}
|
|
|
|
func (q *Queries) UpdateEventType(ctx context.Context, arg UpdateEventTypeParams) (int64, error) {
|
|
result, err := q.db.Exec(ctx, updateEventType, arg.ID, arg.Name, arg.Rule)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const updateMapping = `-- name: UpdateMapping :execrows
|
|
UPDATE mappings
|
|
SET name = $2, source_hint = $3, fields = $4, updated_at = now()
|
|
WHERE id = $1
|
|
`
|
|
|
|
type UpdateMappingParams struct {
|
|
ID string
|
|
Name string
|
|
SourceHint string
|
|
Fields string
|
|
}
|
|
|
|
func (q *Queries) UpdateMapping(ctx context.Context, arg UpdateMappingParams) (int64, error) {
|
|
result, err := q.db.Exec(ctx, updateMapping,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.SourceHint,
|
|
arg.Fields,
|
|
)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|