db

package
v0.0.0-...-b80aede Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPageNotFound = &Error{"page not found", nil}
	ErrNoPageName   = &Error{"no page name", nil}
)

Errors

View Source
var (
	ErrUserNotFound   = &Error{"user not found", nil}
	ErrNoUserName     = &Error{"no user name", nil}
	ErrUserNameExists = &Error{"user name already exist", nil}
	ErrWrongPassword  = &Error{"wrong password", nil}
)

Errors

Functions

This section is empty.

Types

type DB

type DB struct {
	*bolt.DB
}

DB represents a Bolt-backed data store.

func (*DB) Open

func (db *DB) Open(path string, mode os.FileMode) error

Open initializes and opens the database.

func (*DB) Update

func (db *DB) Update(fn func(*Tx) error) error

Update executes a function in the context of a writable transaction.

func (*DB) View

func (db *DB) View(fn func(*Tx) error) error

View executes a function in the context of a read-only transaction.

type Error

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

Error represents an error condition within the database.

func (*Error) Error

func (e *Error) Error() string

Error returns a string representation of the error.

type Note

type Note struct {
	Name    string
	Preview string
}

type Notes

type Notes struct {
	Tx    *Tx
	User  []byte
	Notes []Note
}

Notes represents a user's note list

func (*Notes) LoadNotes

func (n *Notes) LoadNotes() error

LoadNotes retrieves all note of a user from the database.

type Page

type Page struct {
	Tx   *Tx
	User []byte
	Name []byte
	Text []byte
}

Page represents a page

func (*Page) Load

func (p *Page) Load() error

Load retrieves a page from the database.

func (*Page) Save

func (p *Page) Save() error

Save commits the Page to the database.

type Tx

type Tx struct {
	*bolt.Tx
}

Tx represents a BoltDB transaction

func (*Tx) Notes

func (tx *Tx) Notes(userName []byte) (*Notes, error)

Notes list a user's notes from the database.

func (*Tx) Page

func (tx *Tx) Page(userName, pageName []byte) (*Page, error)

Page retrieves a Page from the database with the given user and page name.

func (*Tx) User

func (tx *Tx) User(userName []byte) (*User, error)

User retrieves a User from the database with the given user name.

type User

type User struct {
	Tx       *Tx
	Name     []byte
	Password []byte
}

User represents a user

func (*User) GetPassword

func (u *User) GetPassword() ([]byte, error)

func (*User) Load

func (u *User) Load() error

Load retrieves a user from the database.

func (*User) Save

func (u *User) Save() error

Save commits the User to the database.

Jump to

Keyboard shortcuts

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