database

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	Close()

	Remove(id string)
	Add(...*entry.Entry) error

	GetTags() ([]string, error)
	GetEmojis() ([]string, error)
	Search(opt *QueryOptions, query string) ([]string, error)

	GetDeleted(opts *PaginationOptions) ([]string, error)
	GetDrafts(opts *PaginationOptions) ([]string, error)
	GetUnlisted(opts *PaginationOptions) ([]string, error)
	GetPrivate(opts *PaginationOptions, audience string) ([]string, error)

	GetAll(opts *QueryOptions) ([]string, error)

	ByTag(opt *QueryOptions, tag string) ([]string, error)
	ByEmoji(opt *QueryOptions, emoji string) ([]string, error)
	BySection(opt *QueryOptions, sections ...string) ([]string, error)
	ByDate(opts *QueryOptions, year, month, day int) ([]string, error)
	ByProperty(opts *QueryOptions, property, value string) ([]string, error)

	ReadsSummary() (*entry.ReadsSummary, error)
	WatchesSummary() (*entry.WatchesSummary, error)
	Been() ([]string, error)
	SectionsCount() (map[string]int, error)
}

func NewDatabase

func NewDatabase(cfg *config.PostgreSQL) (Database, error)

type PaginationOptions

type PaginationOptions struct {
	Page  int
	Limit int
}

type Postgres

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

func (*Postgres) Add

func (d *Postgres) Add(entries ...*entry.Entry) error

func (*Postgres) Been

func (d *Postgres) Been() ([]string, error)

func (*Postgres) ByDate

func (d *Postgres) ByDate(opts *QueryOptions, year, month, day int) ([]string, error)

func (*Postgres) ByEmoji

func (d *Postgres) ByEmoji(opts *QueryOptions, emoji string) ([]string, error)

func (*Postgres) ByProperty

func (d *Postgres) ByProperty(opts *QueryOptions, property, value string) ([]string, error)

func (*Postgres) BySection

func (d *Postgres) BySection(opts *QueryOptions, sections ...string) ([]string, error)

func (*Postgres) ByTag

func (d *Postgres) ByTag(opts *QueryOptions, tag string) ([]string, error)

func (*Postgres) Close

func (d *Postgres) Close()

func (*Postgres) GetAll

func (d *Postgres) GetAll(opts *QueryOptions) ([]string, error)

func (*Postgres) GetDeleted

func (d *Postgres) GetDeleted(opts *PaginationOptions) ([]string, error)

func (*Postgres) GetDrafts

func (d *Postgres) GetDrafts(opts *PaginationOptions) ([]string, error)

func (*Postgres) GetEmojis

func (d *Postgres) GetEmojis() ([]string, error)

func (*Postgres) GetPrivate

func (d *Postgres) GetPrivate(opts *PaginationOptions, audience string) ([]string, error)

func (*Postgres) GetTags

func (d *Postgres) GetTags() ([]string, error)

func (*Postgres) GetUnlisted

func (d *Postgres) GetUnlisted(opts *PaginationOptions) ([]string, error)

func (*Postgres) ReadsSummary

func (d *Postgres) ReadsSummary() (*entry.ReadsSummary, error)

func (*Postgres) Remove

func (d *Postgres) Remove(id string)

func (*Postgres) Search

func (d *Postgres) Search(opts *QueryOptions, query string) ([]string, error)

func (*Postgres) SectionsCount

func (d *Postgres) SectionsCount() (map[string]int, error)

func (*Postgres) WatchesSummary

func (d *Postgres) WatchesSummary() (*entry.WatchesSummary, error)

type QueryOptions

type QueryOptions struct {
	PaginationOptions
	WithDrafts  bool
	WithDeleted bool

	// Empty matches all visibilities.
	Visibility []entry.Visibility

	// Empty matches all audiences.
	Audience string
}

Jump to

Keyboard shortcuts

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