bbolt

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a BBolt DB

func New

func New(path string, idLength int) (*DB, error)

New returns a new *BBoltDB with the given path and id length or an error if one occurred

func (*DB) Delete

func (d *DB) Delete(id string) error

Delete deletes the *URL with the given id or returns an error if one occurred

func (*DB) Get

func (d *DB) Get(id string) (url *db.URL, err error)

Get returns the *URL with the given id, or an error if one occurred. If a *URL with the given id doesn't exist, url will be nil

func (*DB) Put

func (d *DB) Put(url *db.URL, user string) (id string, err error)

Put saves the given url in the database for the given user, returning the id, or an error if one occurred.

func (*DB) URLs

func (d *DB) URLs(user string) ([]*db.URL, error)

URLs returns the URLs for the given user or all URLs if user is empty or an error if one occurred

func (*DB) Update

func (d *DB) Update(id string, url *db.URL) error

Update updates the *URL with the given id or returns an error if one occurred

func (*DB) View

func (d *DB) View(id string) (url string, err error)

View returns the url with the given id, or an error if one occurred. If a URL with the given id doesn't exist, url will be empty. View increments the view counter for the URL and should be used by clients wanting to resolve the shortened URL.

Jump to

Keyboard shortcuts

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