postgres

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package postgres provides the PostgreSQL data layer for the CMS core.

Index

Constants

This section is empty.

Variables

View Source
var Migrations embed.FS

Migrations holds the core schema migration files applied by goose.

Functions

func Migrate

func Migrate(ctx context.Context, databaseURL string) error

Migrate applies the core schema migrations to the database at databaseURL.

Types

type PostStore

type PostStore struct {
	// contains filtered or unexported fields
}

PostStore persists posts in the core schema.

func NewPostStore

func NewPostStore(pool *pgxpool.Pool) *PostStore

NewPostStore returns a PostStore backed by pool.

func (*PostStore) Autosave

func (s *PostStore) Autosave(ctx context.Context, postID, authorID uuid.UUID) (post.Revision, error)

Autosave returns the author's autosave of the post, or post.ErrRevisionNotFound.

func (*PostStore) ByID

func (s *PostStore) ByID(ctx context.Context, id uuid.UUID) (post.Post, error)

ByID returns the post with the given id, or post.ErrNotFound.

func (*PostStore) Counts

func (s *PostStore) Counts(ctx context.Context, postType string) (map[post.Status]int, error)

Counts returns the number of posts of the type in each status.

func (*PostStore) Create

func (s *PostStore) Create(ctx context.Context, p post.Post) (post.Post, error)

Create stores a new post, suffixing its slug until the type accepts it.

func (*PostStore) Delete

func (s *PostStore) Delete(ctx context.Context, id uuid.UUID) error

Delete removes the post, or reports post.ErrNotFound.

func (*PostStore) DeleteAutosave

func (s *PostStore) DeleteAutosave(ctx context.Context, postID, authorID uuid.UUID) error

DeleteAutosave removes the author's autosave of the post.

func (*PostStore) DeleteRevision

func (s *PostStore) DeleteRevision(ctx context.Context, postID, revisionID uuid.UUID) error

DeleteRevision removes the post's revision, or reports post.ErrRevisionNotFound.

func (*PostStore) List

func (s *PostStore) List(ctx context.Context, f post.Filter) ([]post.Post, int, error)

List returns the posts matching the filter without their content, and the total number matching it.

func (*PostStore) PublishedBySlug

func (s *PostStore) PublishedBySlug(ctx context.Context, postType, slug string) (post.Post, error)

PublishedBySlug returns the published post of the given type and slug, or post.ErrNotFound.

func (*PostStore) Restore

func (s *PostStore) Restore(ctx context.Context, id uuid.UUID, updatedAt time.Time) (post.Post, error)

Restore returns a trashed post to draft. It recovers the original slug, or leaves the trashed one in place when the original is taken.

func (*PostStore) RevisionByID

func (s *PostStore) RevisionByID(ctx context.Context, postID, revisionID uuid.UUID) (post.Revision, error)

RevisionByID returns the post's revision, or post.ErrRevisionNotFound.

func (*PostStore) Revisions

func (s *PostStore) Revisions(ctx context.Context, postID uuid.UUID) ([]post.Revision, error)

Revisions returns the post's revisions newest first, without their content.

func (*PostStore) SaveAutosave

func (s *PostStore) SaveAutosave(ctx context.Context, autosave post.Revision) (post.Revision, error)

SaveAutosave stores the author's autosave of the post, replacing any earlier one.

func (*PostStore) Trash

func (s *PostStore) Trash(ctx context.Context, id uuid.UUID, updatedAt time.Time) (post.Post, error)

Trash marks the post trashed and frees its slug for reuse.

func (*PostStore) Update

func (s *PostStore) Update(
	ctx context.Context, p post.Post, expectedUpdatedAt time.Time, snapshot *post.Revision, revisionCap int,
) (post.Post, error)

Update stores the post's editable fields and any snapshot, suffixing its slug until the type accepts it.

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

func (s *SettingStore) Lookup(ctx context.Context, key string) (string, bool, error)

Lookup returns the value stored under key and whether the key is set at all.

func (*SettingStore) Save added in v0.2.0

func (s *SettingStore) Save(ctx context.Context, values map[string]string) error

Save stores every given value, or stores none of them.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL