database

package
v0.0.0-...-cb29121 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID    int64
	Owner int64

	// LastUpdated is the last time this channel was updated.
	// Note that the value of this field is not respected.
	LastUpdated time.Time

	fetcher.Channel
}

type Driver

type Driver interface {
	Close() error

	User(ctx context.Context, id int64) (User, error)
	Username(ctx context.Context, username string) (User, error)
	SaveUser(ctx context.Context, u *User) error
	DeleteUser(ctx context.Context, id int64) error
	SetPassword(ctx context.Context, id int64, password string) error
	CheckPassword(ctx context.Context, id int64, password string) (bool, error)

	Channels(ctx context.Context, user int64, limit int) ([]Channel, error)
	Channel(ctx context.Context, user, ch int64) (Channel, error)
	NeedsUpdate(ctx context.Context) ([]Channel, error)
	SaveChannel(ctx context.Context, c *Channel) error
	DeleteChannel(ctx context.Context, ch int64) error

	Recent(ctx context.Context, user int64, offset, limit int) ([]Item, error)
	Today(ctx context.Context, user int64, offset, limit int) ([]Item, error)
	Items(ctx context.Context, ch int64, offset, limit int) ([]Item, error)
	Item(ctx context.Context, id int64) (Item, error)
	SaveItem(ctx context.Context, i *Item) error

	Search(ctx context.Context, user int64, query string, offset, limit int) ([]Item, error)

	// Favicon returns info about the favicon, such as the URL it was
	// fetched from and the date it was last updated.
	//
	// If includeData is true, the data of the favicon is returned.
	Favicon(ctx context.Context, url string, includeData bool) (Favicon, error)

	// SaveFavicon saves a favicon into the database.
	SaveFavicon(ctx context.Context, url string, f Favicon) error
}

func Open

func Open(driver, source string) (Driver, error)

type Favicon

type Favicon struct {
	OriginUrl  string
	LastUpdate time.Time
	Data       []byte
}

type Item

type Item struct {
	ID        int64
	ChannelID int64

	// Ch is a pointer to a channel.
	// It is used by the frontend.
	Ch *Channel

	fetcher.Item
}

type User

type User struct {
	ID       int64
	Username string
}

Jump to

Keyboard shortcuts

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