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)
- 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 ¶
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 ¶
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.
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 ¶
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.