// 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 } 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 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, &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 getLogForSlot = `-- name: GetLogForSlot :many SELECT lock, timestamp, state, code, issued_code FROM lock_log WHERE lock = ? AND code = ? ORDER BY timestamp DESC LIMIT 100 ` 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 }