Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlite

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package sqlite provides the SQLite data layer for the CMS core.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAccounts = errors.New("sqlite: the core tables need the account tables, so migrate the accounts first")

ErrNoAccounts reports that the core tables were to be migrated before the account tables they point at.

View Source
var ErrNoFile = errors.New("sqlite: the database file does not exist")

ErrNoFile reports that the database file a sqlite: address names does not exist.

Functions

func Migrate

func Migrate(ctx context.Context, db *sql.DB, opts MigrateOptions) error

Migrate applies the core table migrations to db under the migration lock of its file, after the account tables.

func Open

func Open(address string, s Settings) (*sql.DB, error)

Open returns a handle on the site's SQLite file at address under s with every rule on, and connects to nothing.

Types

type MediaStore

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

MediaStore persists the media library in the core tables of the site's SQLite file.

func NewMediaStore

func NewMediaStore(handle *sql.DB) *MediaStore

NewMediaStore returns a MediaStore on the site's one SQLite handle.

func (*MediaStore) ByID

func (s *MediaStore) ByID(ctx context.Context, id int64) (media.Media, error)

ByID returns the media item with the given id, or media.ErrNotFound.

func (*MediaStore) ByIDs

func (s *MediaStore) ByIDs(ctx context.Context, ids []int64) ([]media.Media, error)

ByIDs returns the media items stored under the identities, leaving out any that are gone.

func (*MediaStore) Create

func (s *MediaStore) Create(ctx context.Context, m media.Media) (media.Media, error)

Create stores a new media item and returns it with its assigned identifier.

func (*MediaStore) Delete

func (s *MediaStore) Delete(ctx context.Context, id int64) (media.Media, error)

Delete removes the media item and returns it, or reports media.ErrNotFound.

func (*MediaStore) List

func (s *MediaStore) List(ctx context.Context, f media.Filter) ([]media.Listed, int, error)

List returns the media items the filter matches, sorted as it names, beside their authors' names, with their total.

func (*MediaStore) Saved

func (s *MediaStore) Saved(ctx context.Context, files []string) (map[string]bool, error)

Saved reports which of the files a stored item holds as its own file.

func (*MediaStore) Update

func (s *MediaStore) Update(ctx context.Context, m media.Media, expectedUpdatedAt time.Time) (media.Media, error)

Update stores the media item's descriptions, or reports a missing item or a stale edit.

type MigrateOptions

type MigrateOptions struct {
	LockWait time.Duration
	LockPoll time.Duration
}

MigrateOptions sets how a run of Migrate waits for the migration lock of the database file.

func MigrateOptionsFrom

func MigrateOptionsFrom(env gonsole.Env) (MigrateOptions, error)

MigrateOptionsFrom reads the migration lock settings from env, each one left unset taking its documented default.

type SettingStore

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

SettingStore persists the values a site chooses for itself in the core tables of its SQLite file.

func NewSettingStore

func NewSettingStore(handle *sql.DB) *SettingStore

NewSettingStore returns a SettingStore on the site's one SQLite handle.

func (*SettingStore) Lookup

func (s *SettingStore) Lookup(ctx context.Context, key string) (string, bool, error)

Lookup returns the value stored under key and whether the key is set at all.

func (*SettingStore) Save

func (s *SettingStore) Save(ctx context.Context, values map[string]string) error

Save stores every given value, or stores none of them, and writes nothing when given no value.

type Settings

type Settings struct {
	BusyTimeout      time.Duration
	CacheSize        int
	MaxConns         int
	Synchronous      dbsqlite.Synchronous
	JournalSizeLimit *int64
}

Settings are the values every connection of the site's SQLite handle runs with.

func SettingsFrom

func SettingsFrom(env gonsole.Env) (Settings, error)

SettingsFrom reads the SQLite settings from env, each one left unset taking its documented default.

func (Settings) Options

func (s Settings) Options() dbsqlite.Options

Options returns the dbkit options of s with every Go function of the site registered.

type UserSettingStore

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

UserSettingStore persists one reader's own preferences in the core tables of the site's SQLite file.

func NewUserSettingStore

func NewUserSettingStore(handle *sql.DB) *UserSettingStore

NewUserSettingStore returns a UserSettingStore on the site's one SQLite handle.

func (*UserSettingStore) Lookup

func (s *UserSettingStore) Lookup(
	ctx context.Context, userID uuid.UUID, key string,
) (string, bool, error)

Lookup returns the value the reader stored under key, and whether it is set at all.

func (*UserSettingStore) Save

func (s *UserSettingStore) Save(ctx context.Context, userID uuid.UUID, key, value string) error

Save stores the value under the reader's key.

Directories

Path Synopsis
Package columns holds the Go types SQLite columns read into and write from.
Package columns holds the Go types SQLite columns read into and write from.

Jump to

Keyboard shortcuts

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