Documentation ¶
Index ¶
- Variables
- type Coder
- type Condition
- type DB
- func (d *DB) Close() error
- func (d *DB) Count(obj Storable, filters ...*Filter) (int, error)
- func (d *DB) Delete(obj Storable, conditions ...*Condition) error
- func (d *DB) DeleteAllBucket() error
- func (d *DB) DeleteBucket(hasBuckets ...HasBucket) error
- func (d *DB) Exist(obj Storable) (bool, error)
- func (d *DB) First(obj Storable, filters ...*Filter) error
- func (d *DB) Get(obj Storable, conditions ...*Condition) error
- func (d *DB) MDelete(objs ...Storable) error
- func (d *DB) MGet(objs ...Storable) error
- func (d *DB) MPut(objs ...Storable) error
- func (d *DB) Put(obj Storable, conditions ...*Condition) error
- func (d *DB) Scan(result any, filters ...*Filter) error
- func (d *DB) Unwrap() *bbolt.DB
- type Filter
- type GobCoder
- type HasBeforePut
- type HasBucket
- type HasCoder
- type JsonCoder
- type Option
- func WithDefaultCoder(defaultCoder Coder) Option
- func WithFileMode(fileMode os.FileMode) Option
- func WithFreelistType(freelistType bbolt.FreelistType) Option
- func WithInitialMmapSize(initialMmapSize int) Option
- func WithMmapFlags(mmapFlags int) Option
- func WithNoFreelistSync(noFreelistSync bool) Option
- func WithNoGrowSync(noGrowSync bool) Option
- func WithNoSync(noSync bool) Option
- func WithOpenFile(openFile func(string, int, os.FileMode) (*os.File, error)) Option
- func WithPageSize(pageSize int) Option
- func WithReadOnly(readOnly bool) Option
- func WithTimeout(timeout time.Duration) Option
- type Storable
- type XmlCoder
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotExist = errors.New("not exist") ErrAlreadyExist = errors.New("already exist") )
Functions ¶
This section is empty.
Types ¶
type Coder ¶
type Coder interface { Encode(writer io.Writer, v any) error Decode(reader io.Reader, v any) error }
Coder is the interface that can encode and decode data.
type Condition ¶ added in v0.2.0
type Condition struct {
// contains filtered or unexported fields
}
func NewCondition ¶ added in v0.2.0
func NewCondition() *Condition
func (*Condition) FailIfExist ¶ added in v0.2.0
func (*Condition) FailIfNotExist ¶ added in v0.2.0
func (*Condition) IgnoreIfExist ¶ added in v0.2.0
func (*Condition) IgnoreIfNotExist ¶ added in v0.2.0
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) DeleteAllBucket ¶
DeleteAllBucket remove all buckets
func (*DB) DeleteBucket ¶
DeleteBucket remove the specified buckets
func (*DB) MPut ¶ added in v0.2.0
MPut store storables into database, create bucket if it does not exist.
type Filter ¶ added in v0.2.0
type Filter struct {
// contains filtered or unexported fields
}
func (*Filter) AddCondition ¶ added in v0.2.0
func (*Filter) AddStorableCondition ¶ added in v0.2.0
type HasBeforePut ¶ added in v0.2.0
type HasBeforePut interface {
BeforePut(id uint64) // will be called before put, id is an auto incrementing integer for the bucket
}
HasBeforePut is the interface that indicates the BeforePut method
type HasBucket ¶
type HasBucket interface {
BoltBucket() []byte
}
HasBucket is the interface that indicates the bound bucket
type HasCoder ¶
type HasCoder interface {
BoltCoder() Coder
}
HasCoder is the interface that indicates the Coder of the type
type Option ¶
type Option func(options *innerOption)
Option represents the options that can be set when opening a database.
func WithDefaultCoder ¶
WithDefaultCoder return Option with specified DefaultCoder
func WithFileMode ¶
WithFileMode return Option with specified FileMode
func WithFreelistType ¶
func WithFreelistType(freelistType bbolt.FreelistType) Option
WithFreelistType return Option with specified FreelistType
func WithInitialMmapSize ¶
WithInitialMmapSize return Option with specified InitialMmapSize
func WithMmapFlags ¶
WithMmapFlags return Option with specified MmapFlags
func WithNoFreelistSync ¶
WithNoFreelistSync return Option with specified NoFreelistSync
func WithNoGrowSync ¶
WithNoGrowSync return Option with specified NoGrowSync
func WithNoSync ¶
WithNoSync return Option with specified NoSync
func WithOpenFile ¶
WithOpenFile return Option with specified OpenFile,
func WithPageSize ¶
WithPageSize return Option with specified PageSize
func WithReadOnly ¶
WithReadOnly return Option with specified ReadOnly
func WithTimeout ¶
WithTimeout return Option with specified Timeout