epistles

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIDRequired        = errors.New("cannot execute query without an id stored on the model")
	ErrLinkRequired      = errors.New("cannot fetch epistle information without a link")
	ErrMissingPageSize   = errors.New("missing page size in paginated query")
	ErrAlreadyExists     = errors.New("reading already exists")
	ErrEpistleIDMismatch = errors.New("cannot update a reading with the wrong epistle id")
)

Functions

func Update added in v1.0.0

func Update(ctx context.Context, r *Reading, e *Epistle) (err error)

Types

type Epistle

type Epistle struct {
	ID          int64
	Link        string
	Title       sql.NullString
	Description sql.NullString
	Favicon     sql.NullString
	Created     time.Time
	Modified    time.Time
}

Database model for an Epistle object

func (*Epistle) IsSynced added in v0.2.0

func (e *Epistle) IsSynced() bool

func (*Epistle) Save added in v0.2.0

func (e *Epistle) Save(ctx context.Context) (err error)

func (*Epistle) Sync added in v0.2.0

func (e *Epistle) Sync(ctx context.Context) (err error)

type Reading

type Reading struct {
	EpistleID int64
	UserID    int64
	Status    Status
	Started   sql.NullTime
	Finished  sql.NullTime
	Archived  sql.NullTime
	Created   time.Time
	Modified  time.Time
	// contains filtered or unexported fields
}

Database model for a reading object.

func Create

func Create(ctx context.Context, userID int64, link string) (r *Reading, err error)

Create a reading for a user with a link.

func Fetch

func Fetch(ctx context.Context, epistleID, userID int64) (reading *Reading, err error)

func List

func List(ctx context.Context, userID int64, prevPage *pagination.Cursor) (r []*Reading, cursor *pagination.Cursor, err error)

List readings for the specified user.

func (*Reading) Epistle

func (r *Reading) Epistle(ctx context.Context, reset bool) (_ *Epistle, err error)

Epistle returns the epistle associated with the reading. If the epistle is not cached on the struct then a database query is performed and an error may be returned. Use the reset bool to force a database query even if the epistle is cached on the struct.

func (*Reading) User

func (r *Reading) User(ctx context.Context, reset bool) (_ *users.User, err error)

User returns the user associated with the reading. If the user is not cached on the struct then a database query is performed and an error may be returned. Use the reset bool to force a database query even if the user is cached on the struct.

type Status

type Status string

Status constants

const (
	StatusQueued   Status = "queued"
	StatusStarted  Status = "started"
	StatusFinished Status = "finished"
	StatusArchived Status = "archived"
)

Jump to

Keyboard shortcuts

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