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) List(ctx context.Context, f content.Filter) ([]content.Content, int, error)
- func (s *ContentStore) PublishedByPath(ctx context.Context, path string) (content.Content, 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) 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 MediaStore
- func (s *MediaStore) ByID(ctx context.Context, id 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.Media, int, error)
- func (s *MediaStore) Update(ctx context.Context, m media.Media, expectedUpdatedAt time.Time) (media.Media, error)
- type SettingStore
- type TypeStore
- func (s *TypeStore) ByKey(ctx context.Context, key string) (content.Type, error)
- func (s *TypeStore) Create(ctx context.Context, t content.Type) (content.Type, error)
- func (s *TypeStore) Delete(ctx context.Context, key string) error
- func (s *TypeStore) List(ctx context.Context) ([]content.Type, error)
- func (s *TypeStore) Update(ctx context.Context, t content.Type) (content.Type, error)
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, or reports content.ErrRevisionNotFound.
func (*ContentStore) Depth ¶ added in v0.4.0
Depth returns how many levels of content nest below the item.
func (*ContentStore) List ¶ added in v0.4.0
List returns the items matching the filter without their content, and the total number matching it.
func (*ContentStore) PublishedByPath ¶ added in v0.4.0
PublishedByPath returns the published item at the address, or content.ErrNotFound.
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 content item to draft. It recovers the original slug, or leaves the trashed one in place when the original is taken.
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.
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 and frees its address for reuse.
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 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) 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.
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 TypeStore ¶ added in v0.4.0
type TypeStore struct {
// contains filtered or unexported fields
}
TypeStore persists the content type registry in the core schema.
func NewTypeStore ¶ added in v0.4.0
NewTypeStore returns a TypeStore backed by pool.
func (*TypeStore) ByKey ¶ added in v0.4.0
ByKey returns the type carrying the key, or content.ErrTypeNotFound.
func (*TypeStore) Create ¶ added in v0.4.0
Create stores a new content type, or reports the key or route word already in use.
func (*TypeStore) Delete ¶ added in v0.4.0
Delete removes the type, or reports it missing or still in use.