db

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package db implements simple method of treatment to bbolt db.

Index

Constants

View Source
const DELETE = "DELETE"

Variables

This section is empty.

Functions

func SaveModel

func SaveModel(bucket *Bucket, model Model) Error

SaveModel saving bucket in db

Types

type Bucket

type Bucket struct {
	Objects Manager
	// contains filtered or unexported fields
}

Bucket implements interface simple access to read/write in bbolt db.

func (*Bucket) Count

func (bucket *Bucket) Count() uint

func (*Bucket) DB

func (bucket *Bucket) DB() *DB

DB returns pointer to DB.

func (*Bucket) Delete

func (bucket *Bucket) Delete(key uint) Error

Delete implements Deleting value of key in bucket.

func (*Bucket) DeleteAll added in v0.8.0

func (bucket *Bucket) DeleteAll() Error

DeleteAll implements Deleting all values in bucket.

func (*Bucket) Get

func (bucket *Bucket) Get(key uint) (Model, Error)

Get implements getting value of key in bucket.

func (*Bucket) Model

func (bucket *Bucket) Model() Model

Model returns string, name of Bucket.

func (*Bucket) Name

func (bucket *Bucket) Name() string

Name returns string, name of Bucket.

type DB

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

DB implements interface access to bbolt db.

func Open

func Open(path string) (*DB, error)

Open return pointer to DB, If DB does not exist then error.

func (*DB) BoltDB

func (db *DB) BoltDB() *bolt.DB

func (*DB) Bucket

func (db *DB) Bucket(name string, model Model) (*Bucket, error)

Bucket returns pointer to Bucket in db, Returns error if name is blank, or name is too long.

func (*DB) Close

func (db *DB) Close() error

Close implements access to close DB.

func (*DB) ExistsBucket

func (db *DB) ExistsBucket(name string) bool

ExistsBucket returns true if bucket exists.

type Manager

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

func (*Manager) All

func (manager *Manager) All() []Model

func (*Manager) Bucket

func (manager *Manager) Bucket() *Bucket

func (*Manager) CheckModel added in v0.8.0

func (manager *Manager) CheckModel(model Model, include Params, exclude ...Params) bool

func (*Manager) Copy

func (manager *Manager) Copy() *Manager

func (*Manager) Count

func (manager *Manager) Count() uint

func (*Manager) Delete added in v0.8.0

func (manager *Manager) Delete(id uint)

func (*Manager) Filter

func (manager *Manager) Filter(include Params, exclude ...Params) *Manager

func (*Manager) First

func (manager *Manager) First() Model

func (*Manager) Get

func (manager *Manager) Get(id uint) Model

func (*Manager) IsInstance

func (manager *Manager) IsInstance() bool

func (*Manager) Last

func (manager *Manager) Last() Model

type Model

type Model interface {
	Create(*DB, string) Model
	Id() uint
}

type Params

type Params map[string]any

Directories

Path Synopsis
buckets
user
Package user implements model of bucket.
Package user implements model of bucket.
package errors provide errors
package errors provide errors

Jump to

Keyboard shortcuts

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