collection

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Rows []*Row

	Indexes map[string]Index
	// contains filtered or unexported fields
}

func OpenCollection

func OpenCollection(filename string) (*Collection, error)

func (*Collection) Close

func (c *Collection) Close() error

func (*Collection) DeleteBy

func (c *Collection) DeleteBy(field string, value string) error

func (*Collection) Drop

func (c *Collection) Drop() error

func (*Collection) FindBy

func (c *Collection) FindBy(field string, value string, data interface{}) error

func (*Collection) FindOne

func (c *Collection) FindOne(data interface{})

func (*Collection) Index

func (c *Collection) Index(options *IndexOptions) error

Index create a unique index with a name Constraints: values can be only scalar strings or array of strings

func (*Collection) Insert

func (c *Collection) Insert(item interface{}) error

TODO: test concurrency

func (*Collection) PatchBy

func (c *Collection) PatchBy(field string, value string, patch map[string]interface{}) error

func (*Collection) Traverse

func (c *Collection) Traverse(f func(data []byte))

func (*Collection) TraverseRange

func (c *Collection) TraverseRange(from, to int, f func(row *Row))

type Command

type Command struct {
	Name      string          `json:"name"`
	Uuid      string          `json:"uuid"`
	Timestamp int64           `json:"timestamp"`
	StartByte int64           `json:"start_byte"`
	Payload   json.RawMessage `json:"payload"`
}

type Index

type Index struct {
	Entries map[string]*Row
	RWmutex *sync.RWMutex
	Sparse  bool
}

Index should be an interface to allow multiple kinds and implementations

type IndexOptions

type IndexOptions struct {
	Field  string `json:"field"`
	Sparse bool   `json:"sparse"`
}

IndexOptions should have attributes like unique, sparse, multikey, sorted, background, etc... Index should be an interface to have multiple indexes implementations, key value, B-Tree, bitmap, geo, cache...

type Row

type Row struct {
	I       int // position in Rows
	Payload json.RawMessage
}

Jump to

Keyboard shortcuts

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