// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: user_memory.sql package store import ( "context" ) const deleteUserMemoryKey = `-- name: DeleteUserMemoryKey :exec DELETE FROM user_memory WHERE user_id = ? AND key = ? ` type DeleteUserMemoryKeyParams struct { UserID string `json:"user_id"` Key string `json:"key"` } func (q *Queries) DeleteUserMemoryKey(ctx context.Context, arg DeleteUserMemoryKeyParams) error { _, err := q.db.ExecContext(ctx, deleteUserMemoryKey, arg.UserID, arg.Key) return err } const getUserMemory = `-- name: GetUserMemory :many SELECT user_id, "key", value, created_at, updated_at FROM user_memory WHERE user_id = ? ORDER BY key ` func (q *Queries) GetUserMemory(ctx context.Context, userID string) ([]UserMemory, error) { rows, err := q.db.QueryContext(ctx, getUserMemory, userID) if err != nil { return nil, err } defer rows.Close() items := []UserMemory{} for rows.Next() { var i UserMemory if err := rows.Scan( &i.UserID, &i.Key, &i.Value, &i.CreatedAt, &i.UpdatedAt, ); 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 getUserMemoryKey = `-- name: GetUserMemoryKey :one SELECT user_id, "key", value, created_at, updated_at FROM user_memory WHERE user_id = ? AND key = ? ` type GetUserMemoryKeyParams struct { UserID string `json:"user_id"` Key string `json:"key"` } func (q *Queries) GetUserMemoryKey(ctx context.Context, arg GetUserMemoryKeyParams) (UserMemory, error) { row := q.db.QueryRowContext(ctx, getUserMemoryKey, arg.UserID, arg.Key) var i UserMemory err := row.Scan( &i.UserID, &i.Key, &i.Value, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const upsertUserMemory = `-- name: UpsertUserMemory :exec INSERT INTO user_memory (user_id, key, value, created_at, updated_at) VALUES (?, ?, ?, unixepoch(), unixepoch()) ON CONFLICT(user_id, key) DO UPDATE SET value = excluded.value, updated_at = unixepoch() ` type UpsertUserMemoryParams struct { UserID string `json:"user_id"` Key string `json:"key"` Value string `json:"value"` } func (q *Queries) UpsertUserMemory(ctx context.Context, arg UpsertUserMemoryParams) error { _, err := q.db.ExecContext(ctx, upsertUserMemory, arg.UserID, arg.Key, arg.Value) return err }