db

package
v0.0.0-...-254d0ff Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFoundError = errors.New("not found")

Functions

This section is empty.

Types

type DB

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

func NewDB

func NewDB(connStr string) (*DB, error)

func (*DB) CreateItem

func (db *DB) CreateItem(item Item) (Item, error)

func (*DB) DeleteExpiredItems

func (db *DB) DeleteExpiredItems() (int, error)

func (*DB) DeleteItem

func (db *DB) DeleteItem(id uint) error

func (*DB) GetItemByPublicID

func (db *DB) GetItemByPublicID(publicID string) (Item, error)

type Item

type Item struct {
	ID        uint      `gorm:"primaryKey" json:"-"`
	PublicID  string    `gorm:"uniqueIndex" json:"public_id"`
	Fields    string    `json:"fields"`
	ViewOnce  bool      `json:"view_once"` // auto delete after it was retrieved once
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
	ExpiresAt time.Time `json:"expires_at"`
}

func (*Item) IsExpired

func (item *Item) IsExpired() bool

Jump to

Keyboard shortcuts

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