Documentation
¶
Overview ¶
Package postgres provides the PostgreSQL data layer for the CMS core.
Index ¶
- Constants
- Variables
- func CheckMajor(ctx context.Context, db *sql.DB) error
- func Migrate(ctx context.Context, db *sql.DB) error
- func RaiseMinimumVersion(ctx context.Context, db *sql.DB, minimum string) error
- func ServerMajor(ctx context.Context, db *sql.DB) (int, error)
- func StoredMinimumVersion(ctx context.Context, db *sql.DB) (string, error)
- type ContentStore
- 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 SettingStore
- type TypeStore
- type UserSettingStore
Constants ¶
const OldestMajor = 15
OldestMajor is the oldest PostgreSQL major version this release supports.
Variables ¶
var Migrations embed.FS
Migrations holds the core schema migration files applied by goose.
Functions ¶
func CheckMajor ¶ added in v0.20.0
CheckMajor returns an error naming the server's version when it runs a PostgreSQL major older than OldestMajor.
func Migrate ¶
Migrate applies the core schema migrations on db under goose's advisory lock, opening nothing itself.
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.
func ServerMajor ¶ added in v0.20.0
ServerMajor returns the PostgreSQL major the server db connects to runs.
Types ¶
type ContentStore ¶ added in v0.4.0
type ContentStore struct {
*contentstore.Store
}
ContentStore persists content items in the core schema.
func NewContentStore ¶ added in v0.4.0
func NewContentStore(pool *pgxpool.Pool) *ContentStore
NewContentStore returns a ContentStore backed by pool.
type CronStore ¶ added in v0.19.0
type CronStore struct {
// contains filtered or unexported fields
}
CronStore keeps the site's cron jobs and their leases in the core schema.
func NewCronStore ¶ added in v0.19.0
NewCronStore returns a CronStore backed by pool.
func (*CronStore) Settle ¶ added in v0.19.0
Settle frees the job and records how its run ended, refusing a lease another run took over.
type MediaStore ¶ added in v0.3.0
type MediaStore struct {
// contains filtered or unexported fields
}
MediaStore persists the media library in the core schema.
func NewMediaStore ¶ added in v0.3.0
func NewMediaStore(pool *pgxpool.Pool) *MediaStore
NewMediaStore returns a MediaStore backed by pool.
func (*MediaStore) ByID ¶ added in v0.3.0
ByID returns the media item with the given id, or media.ErrNotFound.
func (*MediaStore) ByIDs ¶ added in v0.11.0
ByIDs returns the media items stored under the identities, leaving out any that are gone.
func (*MediaStore) Create ¶ added in v0.3.0
Create stores a new media item and returns it with its assigned identifier.
func (*MediaStore) Delete ¶ added in v0.3.0
Delete removes the media item and returns it, or reports media.ErrNotFound.
func (*MediaStore) List ¶ added in v0.3.0
List returns the media items the filter matches, sorted as it names, beside their authors' names, with their total.
type SettingStore ¶ added in v0.2.0
type SettingStore struct {
// contains filtered or unexported fields
}
SettingStore persists named values in the core schema.
func NewSettingStore ¶ added in v0.2.0
func NewSettingStore(pool *pgxpool.Pool) *SettingStore
NewSettingStore returns a SettingStore backed by pool.
func (*SettingStore) Lookup ¶ added in v0.2.0
Lookup returns the value stored under key and whether the key is set at all.
type UserSettingStore ¶ added in v0.6.0
type UserSettingStore struct {
// contains filtered or unexported fields
}
UserSettingStore persists one reader's own preferences in the core schema.
func NewUserSettingStore ¶ added in v0.6.0
func NewUserSettingStore(pool *pgxpool.Pool) *UserSettingStore
NewUserSettingStore returns a UserSettingStore backed by pool.