lockserver/db/lock_log.sql.go

136 lines
2.9 KiB
Go
Raw Permalink Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.20.0
// source: lock_log.sql
package db
import (
"context"
"database/sql"
)
const addLogEntry = `-- name: AddLogEntry :exec
INSERT INTO lock_log (lock, state, code) VALUES (?, ?, ?)
`
type AddLogEntryParams struct {
Lock int64
State string
Code sql.NullInt64
}
func (q *Queries) AddLogEntry(ctx context.Context, arg AddLogEntryParams) error {
_, err := q.db.ExecContext(ctx, addLogEntry, arg.Lock, arg.State, arg.Code)
return err
}
2024-11-25 00:08:06 +00:00
const getLastLogForSlot = `-- name: GetLastLogForSlot :many
SELECT lock, timestamp, state, code, issued_code FROM lock_log WHERE lock = ? AND code = ? ORDER BY timestamp DESC LIMIT 1
`
type GetLastLogForSlotParams struct {
Lock int64
Code sql.NullInt64
}
func (q *Queries) GetLastLogForSlot(ctx context.Context, arg GetLastLogForSlotParams) ([]LockLog, error) {
rows, err := q.db.QueryContext(ctx, getLastLogForSlot, arg.Lock, arg.Code)
if err != nil {
return nil, err
}
defer rows.Close()
var items []LockLog
for rows.Next() {
var i LockLog
if err := rows.Scan(
&i.Lock,
&i.Timestamp,
&i.State,
&i.Code,
&i.IssuedCode,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getLogForLock = `-- name: GetLogForLock :many
2024-11-23 03:50:18 +00:00
SELECT lock, timestamp, state, code, issued_code FROM lock_log WHERE lock = ? ORDER BY timestamp DESC
`
func (q *Queries) GetLogForLock(ctx context.Context, lock int64) ([]LockLog, error) {
rows, err := q.db.QueryContext(ctx, getLogForLock, lock)
if err != nil {
return nil, err
}
defer rows.Close()
var items []LockLog
for rows.Next() {
var i LockLog
if err := rows.Scan(
&i.Lock,
&i.Timestamp,
&i.State,
&i.Code,
2024-11-23 03:50:18 +00:00
&i.IssuedCode,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
2024-11-25 00:08:06 +00:00
const getLogForSlot = `-- name: GetLogForSlot :many
SELECT lock, timestamp, state, code, issued_code FROM lock_log WHERE lock = ? AND code = ? ORDER BY timestamp DESC
`
type GetLogForSlotParams struct {
Lock int64
Code sql.NullInt64
}
func (q *Queries) GetLogForSlot(ctx context.Context, arg GetLogForSlotParams) ([]LockLog, error) {
rows, err := q.db.QueryContext(ctx, getLogForSlot, arg.Lock, arg.Code)
if err != nil {
return nil, err
}
defer rows.Close()
var items []LockLog
for rows.Next() {
var i LockLog
if err := rows.Scan(
&i.Lock,
&i.Timestamp,
&i.State,
&i.Code,
&i.IssuedCode,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}