Documentation
¶
Overview ¶
Package filedb provides simple low-performance file-based storage amd querying.
Index ¶
- Constants
- Variables
- type C
- func (c *C) DB() *DB
- func (c *C) Drop() error
- func (c *C) ForEach(fn func(int, []byte) bool) error
- func (c *C) Insert(o []byte) error
- func (c *C) InsertJSON(obj interface{}) error
- func (c *C) Path() string
- func (c *C) RemoveEach(fn func(int, []byte) (bool, bool)) error
- func (c *C) SelectEach(fn func(int, []byte) (include bool, data []byte, stop bool)) error
- type DB
Constants ¶
const Ext string = ".filedb"
Ext is the extension for filedb files.
Variables ¶
var ( // CNameFormat represents the collection name format. CNameFormat = "%s" + Ext )
var ( // ErrDBNotFound occurs when a database could not be found. ErrDBNotFound = errors.New("database not found; expected existing directory") )
Functions ¶
This section is empty.
Types ¶
type C ¶
type C struct {
// contains filtered or unexported fields
}
C represents a collection of JSON objects.
func (*C) ForEach ¶
ForEach iterates over every item in the collection calling the function for each row. The function should return true if ForEach is to break (stop iterating) at any time.
func (*C) InsertJSON ¶
InsertJSON inserts a JSON encoded version of the specified object.
func (*C) RemoveEach ¶
RemoveEach calls fn for each record in the collection, removing any for which fn returns true. If stop is returned, processing ceases after the current record has been processed.
func (*C) SelectEach ¶
SelectEach calls fn for each item in the collection replacing the data if include is true.
c.SelectEach(func(i int, data []byte) { include := true stop := false return include, data, stop })
If include is false, the record will be omitted. If stop is true, processing will cease after the current record has been processed.