db

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = errors.New("db: record not found")
	ErrPKAlreadyExists = errors.New("db: primary key already exists")
)
View Source
var ErrTagNameExists = errors.New("db: a tag with that name already exists")

Functions

This section is empty.

Types

type DB

type DB struct {
	ContextTimeout time.Duration
	// contains filtered or unexported fields
}

func New

func New() (*DB, error)

func (*DB) AssignPageToTag

func (db *DB) AssignPageToTag(pageID, tagID string) error

func (*DB) CreatePage

func (db *DB) CreatePage(page *Page) error

func (*DB) CreateTag

func (db *DB) CreateTag(tag *Tag) error

func (*DB) CreateUser

func (db *DB) CreateUser(u *User) error

func (*DB) GetAllPages

func (db *DB) GetAllPages() ([]*Page, error)

func (*DB) GetAllTags

func (db *DB) GetAllTags() ([]*Tag, error)

func (*DB) GetPageByID

func (db *DB) GetPageByID(id string) (*Page, error)

func (*DB) GetPagesWithTag

func (db *DB) GetPagesWithTag(tagID string) ([]*Page, error)

func (*DB) GetSessionKey

func (db *DB) GetSessionKey() (string, error)

func (*DB) GetTagByID

func (db *DB) GetTagByID(id string) (*Tag, error)

func (*DB) GetTagByName

func (db *DB) GetTagByName(name string) (*Tag, error)

func (*DB) GetTagFrequencies

func (db *DB) GetTagFrequencies(tags []*Tag) (map[*Tag]int, error)

func (*DB) GetTagFrequency

func (db *DB) GetTagFrequency(tag *Tag) (int, error)

func (*DB) GetTagsByPageID

func (db *DB) GetTagsByPageID(pageID string) ([]*Tag, error)

func (*DB) GetUserByExternalID

func (db *DB) GetUserByExternalID(externalID string) (*User, error)

func (*DB) GetUserByID

func (db *DB) GetUserByID(id string) (*User, error)

func (*DB) Migrate

func (db *DB) Migrate() error

func (*DB) StoreSessionKey

func (db *DB) StoreSessionKey(key string) error

func (*DB) UpdatePage

func (db *DB) UpdatePage(page *Page) error

func (*DB) UpdateTag

func (db *DB) UpdateTag(tag *Tag) error

type Page

type Page struct {
	ID        string    `db:"id"`
	Title     string    `db:"title"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
	Content   string    `db:"content"`
}

type Tag

type Tag struct {
	ID   string `db:"id"`
	Name string `db:"name"`
}

type User

type User struct {
	ID         string         `db:"id"`
	ExternalID string         `db:"external_id"`
	Name       sql.NullString `db:"name"`
	Email      string         `db:"email"`
}

Jump to

Keyboard shortcuts

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