Documentation
¶
Overview ¶
Package sqlite provides the SQLite data layer for the CMS core.
Index ¶
- Variables
- func Migrate(ctx context.Context, db *sql.DB, opts MigrateOptions) error
- func Open(address string, s Settings) (*sql.DB, error)
- func RaiseMinimumVersion(ctx context.Context, db *sql.DB, minimum string) error
- func StoredMinimumVersion(ctx context.Context, db *sql.DB) (string, error)
- type CronStore
- type MediaStore
- func (s *MediaStore) ByID(ctx context.Context, id int64) (media.Media, error)
- func (s *MediaStore) ByIDs(ctx context.Context, ids []int64) ([]media.Media, error)
- func (s *MediaStore) Create(ctx context.Context, m media.Media) (media.Media, error)
- func (s *MediaStore) Delete(ctx context.Context, id int64) (media.Media, error)
- func (s *MediaStore) List(ctx context.Context, f media.Filter) ([]media.Listed, int, error)
- func (s *MediaStore) Saved(ctx context.Context, files []string) (map[string]bool, error)
- func (s *MediaStore) Update(ctx context.Context, m media.Media, expectedUpdatedAt time.Time) (media.Media, error)
- type MigrateOptions
- type SettingStore
- type Settings
- type UserSettingStore
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
Migrate applies the core table migrations to db under the migration lock of its file, after the account tables.
func Open ¶
Open returns a handle on the site's SQLite file at address under s with every rule on, and connects to nothing.
func RaiseMinimumVersion ¶ added in v0.20.0
RaiseMinimumVersion stores minimum on db when the stored one comes before it, reading again after a lost race.
Types ¶
type CronStore ¶ added in v0.20.0
type CronStore struct {
// contains filtered or unexported fields
}
CronStore keeps the site's cron jobs and their leases in the core tables of its SQLite file.
func NewCronStore ¶ added in v0.20.0
NewCronStore returns a CronStore on the site's one SQLite handle.
func (*CronStore) Settle ¶ added in v0.20.0
Settle frees the job and records how its run ended, refusing a lease another run took over.
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 ¶
ByID returns the media item with the given id, or media.ErrNotFound.
func (*MediaStore) ByIDs ¶
ByIDs returns the media items stored under the identities, leaving out any that are gone.
func (*MediaStore) Create ¶
Create stores a new media item and returns it with its assigned identifier.
func (*MediaStore) Delete ¶
Delete removes the media item and returns it, or reports media.ErrNotFound.
func (*MediaStore) List ¶
List returns the media items the filter matches, sorted as it names, beside their authors' names, with their total.
type MigrateOptions ¶
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 ¶
Lookup returns the value stored under key and whether the key is set at all.
type Settings ¶
type Settings struct {
BusyTimeout time.Duration
BusyPoll 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 ¶
SettingsFrom reads the SQLite settings from env, each one left unset taking its documented default.
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.