103 lines
2.3 KiB
Go
103 lines
2.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: update_state.sql
|
|
|
|
package sqlcgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const deleteUpdateState = `-- name: DeleteUpdateState :exec
|
|
DELETE FROM update_states
|
|
WHERE auth_key_id = $1
|
|
AND user_id = $2
|
|
`
|
|
|
|
type DeleteUpdateStateParams struct {
|
|
AuthKeyID int64
|
|
UserID int64
|
|
}
|
|
|
|
func (q *Queries) DeleteUpdateState(ctx context.Context, arg DeleteUpdateStateParams) error {
|
|
_, err := q.db.Exec(ctx, deleteUpdateState, arg.AuthKeyID, arg.UserID)
|
|
return err
|
|
}
|
|
|
|
const deleteUpdateStatesByAuthKey = `-- name: DeleteUpdateStatesByAuthKey :exec
|
|
DELETE FROM update_states
|
|
WHERE auth_key_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteUpdateStatesByAuthKey(ctx context.Context, authKeyID int64) error {
|
|
_, err := q.db.Exec(ctx, deleteUpdateStatesByAuthKey, authKeyID)
|
|
return err
|
|
}
|
|
|
|
const getUpdateState = `-- name: GetUpdateState :one
|
|
SELECT auth_key_id, user_id, pts, qts, date, seq
|
|
FROM update_states
|
|
WHERE auth_key_id = $1
|
|
AND user_id = $2
|
|
`
|
|
|
|
type GetUpdateStateParams struct {
|
|
AuthKeyID int64
|
|
UserID int64
|
|
}
|
|
|
|
type GetUpdateStateRow struct {
|
|
AuthKeyID int64
|
|
UserID int64
|
|
Pts int32
|
|
Qts int32
|
|
Date int32
|
|
Seq int32
|
|
}
|
|
|
|
func (q *Queries) GetUpdateState(ctx context.Context, arg GetUpdateStateParams) (GetUpdateStateRow, error) {
|
|
row := q.db.QueryRow(ctx, getUpdateState, arg.AuthKeyID, arg.UserID)
|
|
var i GetUpdateStateRow
|
|
err := row.Scan(
|
|
&i.AuthKeyID,
|
|
&i.UserID,
|
|
&i.Pts,
|
|
&i.Qts,
|
|
&i.Date,
|
|
&i.Seq,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const upsertUpdateState = `-- name: UpsertUpdateState :exec
|
|
INSERT INTO update_states (auth_key_id, user_id, pts, qts, date, seq)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
ON CONFLICT (auth_key_id, user_id) DO UPDATE SET
|
|
pts = GREATEST(update_states.pts, EXCLUDED.pts),
|
|
qts = GREATEST(update_states.qts, EXCLUDED.qts),
|
|
date = GREATEST(update_states.date, EXCLUDED.date),
|
|
seq = GREATEST(update_states.seq, EXCLUDED.seq),
|
|
updated_at = now()
|
|
`
|
|
|
|
type UpsertUpdateStateParams struct {
|
|
AuthKeyID int64
|
|
UserID int64
|
|
Pts int32
|
|
Qts int32
|
|
Date int32
|
|
Seq int32
|
|
}
|
|
|
|
func (q *Queries) UpsertUpdateState(ctx context.Context, arg UpsertUpdateStateParams) error {
|
|
_, err := q.db.Exec(ctx, upsertUpdateState,
|
|
arg.AuthKeyID,
|
|
arg.UserID,
|
|
arg.Pts,
|
|
arg.Qts,
|
|
arg.Date,
|
|
arg.Seq,
|
|
)
|
|
return err
|
|
}
|