sqlite

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, db *sql.DB) error

Apply runs every embedded migration that hasn't already been recorded in paste_migrations, in lexicographic filename order. Idempotent — safe to call on every server boot.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the SQLite-backed paste.Storage implementation.

func New

func New(db *sql.DB) *Store

New wraps an open *sql.DB as a Store. The caller still owns the connection and is responsible for closing it.

func (*Store) AppendEvent

func (s *Store) AppendEvent(ctx context.Context, e paste.Event) error

AppendEvent appends a new event row to the share's append-only log. Events are only ever inserted — never updated or deleted — so the entire history is reproducible by replay.

func (*Store) CreateShare

func (s *Store) CreateShare(ctx context.Context, share paste.Share, editToken string) error

CreateShare inserts a new share row plus its edit token. The token is stored in the same row so the table is the source of truth for both the public ID and the bearer credential needed to mutate it later.

func (*Store) DeleteShare

func (s *Store) DeleteShare(ctx context.Context, id, editToken string) error

DeleteShare removes the share (and, via cascade, its event log) after verifying the edit token.

func (*Store) GetShare

func (s *Store) GetShare(ctx context.Context, id string) (*paste.Share, error)

GetShare returns the share row by ID. The edit_token column is intentionally excluded from the SELECT — only VerifyEditToken consults it, so untrusted reads can't accidentally leak the token via an error or log.

func (*Store) ListEvents

func (s *Store) ListEvents(ctx context.Context, shareID string) ([]paste.Event, error)

ListEvents returns every event for the share, ordered by created_at then id so callers can replay state deterministically (Go map iteration is randomized, so the deterministic order has to come from the SQL side).

func (*Store) UpdateSharePlan

func (s *Store) UpdateSharePlan(ctx context.Context, id string, planBlob, iv []byte, editToken string) error

UpdateSharePlan replaces the encrypted plan blob & nonce after verifying the edit token. updated_at is bumped so clients can detect changes.

func (*Store) VerifyEditToken

func (s *Store) VerifyEditToken(ctx context.Context, id, token string) (bool, error)

VerifyEditToken checks token against the stored edit_token for share id. Returns (false, ErrShareNotFound) when the share doesn't exist; (false, nil) when the share exists but the token doesn't match; (true, nil) on success.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL