Documentation
¶
Overview ¶
Package postgres provides the PostgreSQL data layer for the CMS core.
Index ¶
- Variables
- func Migrate(ctx context.Context, databaseURL string) error
- type ContentStore
- func (s *ContentStore) Autosave(ctx context.Context, contentID, authorID uuid.UUID) (content.Revision, error)
- func (s *ContentStore) ByID(ctx context.Context, id uuid.UUID) (content.Content, error)
- func (s *ContentStore) Children(ctx context.Context, id uuid.UUID) (int, error)
- func (s *ContentStore) Counts(ctx context.Context, contentType string) (map[content.Status]int, error)
- func (s *ContentStore) Create(ctx context.Context, c content.Content) (content.Content, error)
- func (s *ContentStore) Delete(ctx context.Context, id uuid.UUID) error
- func (s *ContentStore) DeleteAutosave(ctx context.Context, contentID, authorID uuid.UUID) error
- func (s *ContentStore) DeleteRevision(ctx context.Context, contentID, revisionID uuid.UUID) error
- func (s *ContentStore) Depth(ctx context.Context, id uuid.UUID) (int, error)
- func (s *ContentStore) EmptyTrash(ctx context.Context, contentType string, author *uuid.UUID) (int, int, error)
- func (s *ContentStore) List(ctx context.Context, f content.Filter) ([]content.ListedItem, int, error)
- func (s *ContentStore) PointingAt(ctx context.Context, target uuid.UUID, field, page, perPage int) ([]content.Pointer, int, error)
- func (s *ContentStore) PublishedByPath(ctx context.Context, path string) (content.Content, error)
- func (s *ContentStore) RelatedTo(ctx context.Context, target uuid.UUID, page, perPage int) ([]content.Content, int, error)
- func (s *ContentStore) Restore(ctx context.Context, id uuid.UUID, updatedAt time.Time) (content.Content, error)
- func (s *ContentStore) RevisionByID(ctx context.Context, contentID, revisionID uuid.UUID) (content.Revision, error)
- func (s *ContentStore) Revisions(ctx context.Context, contentID uuid.UUID) ([]content.Revision, error)
- func (s *ContentStore) SaveAutosave(ctx context.Context, autosave content.Revision) (content.Revision, error)
- func (s *ContentStore) TargetsByIDs(ctx context.Context, ids []uuid.UUID) ([]content.Target, error)
- func (s *ContentStore) Trash(ctx context.Context, id uuid.UUID, updatedAt time.Time) (content.Content, error)
- func (s *ContentStore) Update(ctx context.Context, c content.Content, expectedUpdatedAt time.Time, ...) (content.Content, 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 SettingStore
- type TypeStore
- type UserSettingStore
Constants ¶
This section is empty.
Variables ¶
var Migrations embed.FS
Migrations holds the core schema migration files applied by goose.
Functions ¶
Types ¶
type ContentStore ¶ added in v0.4.0
type ContentStore struct {
// contains filtered or unexported fields
}
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.
func (*ContentStore) Autosave ¶ added in v0.4.0
func (s *ContentStore) Autosave(ctx context.Context, contentID, authorID uuid.UUID) (content.Revision, error)
Autosave returns the author's autosave of the item, or content.ErrRevisionNotFound.
func (*ContentStore) ByID ¶ added in v0.4.0
ByID returns the content item with the given id, or content.ErrNotFound.
func (*ContentStore) Children ¶ added in v0.4.0
Children returns how many items nest directly under the item.
func (*ContentStore) Counts ¶ added in v0.4.0
func (s *ContentStore) Counts(ctx context.Context, contentType string) (map[content.Status]int, error)
Counts returns the number of items of the type in each status.
func (*ContentStore) Create ¶ added in v0.4.0
Create stores a new content item, suffixing its slug until its address is free.
func (*ContentStore) Delete ¶ added in v0.4.0
Delete removes the content item, or reports content.ErrNotFound.
func (*ContentStore) DeleteAutosave ¶ added in v0.4.0
DeleteAutosave removes the author's autosave of the item.
func (*ContentStore) DeleteRevision ¶ added in v0.4.0
DeleteRevision removes the item's revision, reporting content.ErrRevisionNotFound or content.ErrTrashed.
func (*ContentStore) Depth ¶ added in v0.4.0
Depth returns how many levels of content nest below the item.
func (*ContentStore) EmptyTrash ¶ added in v0.19.0
func (s *ContentStore) EmptyTrash(ctx context.Context, contentType string, author *uuid.UUID) (int, int, error)
EmptyTrash deletes the type's trash, only the author's when one is named, and counts what it deleted and left.
func (*ContentStore) List ¶ added in v0.4.0
func (s *ContentStore) List(ctx context.Context, f content.Filter) ([]content.ListedItem, int, error)
List returns the items matching the filter without content, with author names and parent titles, and their total.
func (*ContentStore) PointingAt ¶ added in v0.12.0
func (s *ContentStore) PointingAt( ctx context.Context, target uuid.UUID, field, page, perPage int, ) ([]content.Pointer, int, error)
PointingAt returns the published items pointing at the target through the field, and how many there are.
func (*ContentStore) PublishedByPath ¶ added in v0.4.0
PublishedByPath returns the published item at the address, or content.ErrNotFound.
func (*ContentStore) RelatedTo ¶ added in v0.5.0
func (s *ContentStore) RelatedTo( ctx context.Context, target uuid.UUID, page, perPage int, ) ([]content.Content, int, error)
RelatedTo returns the published content of active types pointing at the target, newest first.
func (*ContentStore) Restore ¶ added in v0.4.0
func (s *ContentStore) Restore(ctx context.Context, id uuid.UUID, updatedAt time.Time) (content.Content, error)
Restore returns a trashed item to draft under its original slug when free, and refuses one out of the trash.
func (*ContentStore) RevisionByID ¶ added in v0.4.0
func (s *ContentStore) RevisionByID(ctx context.Context, contentID, revisionID uuid.UUID) (content.Revision, error)
RevisionByID returns the item's revision, or content.ErrRevisionNotFound.
func (*ContentStore) Revisions ¶ added in v0.4.0
func (s *ContentStore) Revisions(ctx context.Context, contentID uuid.UUID) ([]content.Revision, error)
Revisions returns the item's revisions newest first, without their content.
func (*ContentStore) SaveAutosave ¶ added in v0.4.0
func (s *ContentStore) SaveAutosave(ctx context.Context, autosave content.Revision) (content.Revision, error)
SaveAutosave stores the author's autosave of the item, replacing any earlier one, unless the item is in the trash.
func (*ContentStore) TargetsByIDs ¶ added in v0.13.0
TargetsByIDs returns the published items of active types the identities name.
func (*ContentStore) Trash ¶ added in v0.4.0
func (s *ContentStore) Trash(ctx context.Context, id uuid.UUID, updatedAt time.Time) (content.Content, error)
Trash marks the content item trashed, frees its address for reuse and drops its parked words.
func (*ContentStore) Update ¶ added in v0.4.0
func (s *ContentStore) Update( ctx context.Context, c content.Content, expectedUpdatedAt time.Time, snapshot *content.Revision, revisionCap int, ) (content.Content, error)
Update stores the item's editable fields and any snapshot, settling its address among its siblings.
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.
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.