store

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashToken

func HashToken(token string) string

HashToken returns SHA-256 hex of a token string.

Types

type Document

type Document struct {
	ID        string
	Content   string
	TokenHash string
	CreatedAt int64
	ExpiresAt *int64
}

Document represents a stored Markdown document.

type DocumentSummary added in v0.3.0

type DocumentSummary struct {
	ID        string
	Content   string
	CreatedAt int64
}

DocumentSummary represents the dashboard list view of a document.

type Store

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

Store wraps the SQLite database.

func New

func New(path string) (*Store, error)

New opens (or creates) the SQLite database at path.

func (*Store) Create

func (s *Store) Create(content, tokenHash, ipHash string) (string, error)

Create inserts a new document and returns its ID.

func (*Store) Delete

func (s *Store) Delete(id, tokenHash string) (bool, error)

Delete removes a document if the tokenHash matches. Returns true if a row was deleted, false if not found or token mismatch.

func (*Store) GenerateID

func (s *Store) GenerateID(length int) (string, error)

GenerateID returns a unique Base62 ID of the given length. It retries on collision (extremely rare with 4+ chars).

func (*Store) GetByID

func (s *Store) GetByID(id string) (*Document, error)

GetByID returns a document by ID, or nil if not found / expired.

func (*Store) ListByTokenHash added in v0.3.0

func (s *Store) ListByTokenHash(tokenHash string) ([]DocumentSummary, error)

ListByTokenHash returns all documents owned by the token hash, newest first.

Jump to

Keyboard shortcuts

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