models

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitBadgerDB added in v1.0.2

func InitBadgerDB(dataDir string) error

InitBadgerDB returns a new initialized BadgerDB database implementing the DB interface. If the database cannot be initialized, an error will be returned.

Types

type BadgerDB added in v1.0.2

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

BadgerDB is a wrapper around a BadgerDB backend database that implements the DB interface.

func (*BadgerDB) Close added in v1.0.2

func (bdb *BadgerDB) Close() error

Close implements the DB interface. It closes the connection to the underlying BadgerDB database as well as invoking the context's cancel function.

func (*BadgerDB) Get added in v1.0.2

func (bdb *BadgerDB) Get(namespace, key []byte) (value []byte, err error)

Get implements the DB interface. It attempts to get a value for a given key and namespace. If the key does not exist in the provided namespace, an error is returned, otherwise the retrieved value.

func (*BadgerDB) Has added in v1.0.2

func (bdb *BadgerDB) Has(namespace, key []byte) (ok bool, err error)

Has implements the DB interface. It returns a boolean reflecting if the datbase has a given key for a namespace or not. An error is only returned if an error to Get would be returned that is not of type badger.ErrKeyNotFound.

func (*BadgerDB) Set added in v1.0.2

func (bdb *BadgerDB) Set(namespace, key, value []byte) error

Set implements the DB interface. It attempts to store a value for a given key and namespace. If the key/value pair cannot be saved, an error is returned.

type DB added in v1.0.2

type DB interface {
	Get(namespace, key []byte) (value []byte, err error)
	Set(namespace, key, value []byte) error
	Has(namespace, key []byte) (bool, error)
	Close() error
}

DB defines an embedded key/value store database interface.

var (
	// BadgerAlertNamespace defines the alerts BadgerDB namespace.
	BadgerAlertNamespace = []byte("alerts")

	// Storage is
	Storage DB
)

type Page

type Page struct {
	Id        int
	Title     string `sql:"size:255"`
	Body      string `sql:"size:16777215"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

Structure with page information

func (*Page) Validate

func (page *Page) Validate(v *revel.Validation)

type Revision

type Revision struct {
	Id           int
	PageId       int
	Title        string `sql:"size:255"`
	Body         string `sql:"size:16777215"`
	AddedLines   int
	DeletedLines int
	CreatedAt    time.Time
	DeletedAt    time.Time
}

Structure containing page revision information

Jump to

Keyboard shortcuts

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