jidoco

package module
v0.0.0-...-da21e5c Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 5 Imported by: 0

README

jidoco

Json Indexable DOcument Collection

Documentation

Index

Constants

View Source
const PathSeparator = "/"

PathSeparator is used to separate parts of paths to buckets.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayCursor

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

ArrayCursor implements the cursor interface using a backing array. The keys are little-endian binary encoded uint64 values of the array index. This type is probably most useful fot testing and simulating a key/value store.

func NewArrayCursor

func NewArrayCursor(values [][]byte) *ArrayCursor

func (*ArrayCursor) First

func (c *ArrayCursor) First() (key []byte, value []byte)

func (*ArrayCursor) Next

func (c *ArrayCursor) Next() (key []byte, value []byte)

func (*ArrayCursor) Prev

func (c *ArrayCursor) Prev() (key []byte, value []byte)

func (*ArrayCursor) Seek

func (c *ArrayCursor) Seek(seek []byte) (key []byte, value []byte)

func (ArrayCursor) This

func (c ArrayCursor) This() (key []byte, value []byte)

type Attachment

type Attachment struct {
	Collection `json:"collection"`
}

type Bucket

type Bucket struct {
	*driver.Bucket
}

Bucket is a wrapper around the driver's bucket.

type Codec

type Codec interface {
	Encode(decoded interface{}, options ...interface{}) ([]string, error)
	Decode(decoded interface{}, encoded []byte) error
}

Codec is used to encode and decode data stored in and loaded from a collection

type Collection

type Collection struct {
	// Path to the bucket this collection is stored in.
	Path string `json:"path"`
	// Name of codec to use to store and retrieve the data.
	CodecName string `json:"codec_name"`
	// Indexes on this collection.
	Indexes map[string]Index `json:"indexes"`
	// Attachment sub-collection for this collection.
	*Attachment `json:"attachment,omitempty"`
	// Permission sub-collection for this collection.
	*Permission `json:"permission,omitempty"`
}

Collections is a group of similar documents stored together. Normally these are stored as JSON documents, but the data may also be encrypted, or binary for attachments.

All normal collections use a ULID as their key and a JSON document as their value. ULID makes creation timestamps redundant. All normal collection documents should have.

Attachments use a ULID for their key and the binary data prefixed with name and mime string as their value.

Permissions are keyed by ozner

Indexes use the indexed value of one or more documents as their key, and the binary ulids of the documents that match that index value as their value. Since binary ULID is fixed length this simplifies index lookup.

type Cond

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

func (*Cond) Float

func (c *Cond) Float(f float64) *Cond

func (*Cond) Int

func (c *Cond) Int(i int64) *Cond

func (*Cond) Op

func (c *Cond) Op(op Op) *Cond

func (*Cond) Path

func (c *Cond) Path(p Path) *Cond

func (*Cond) Str

func (c *Cond) Str(s string) *Cond

type Cursor

type Cursor = cursor.Cursor

type Database

type Database struct {
	Storage     `json:"-"`
	Collections map[string]Collection `json:"collections"`
}

func Open

func Open(driver Driver, storageName string) (*Database, error)

type Driver

type Driver interface {
	Open(storageName string) (Storage, error)
}

type Expr

type Expr struct {
	Path   *Path
	String *string
	Int    *int64
	Float  *float64
}

type Index

type Index struct {
	Collection `json:"collection"`
	Unique     bool `json:unique`
	Fulltext   bool `json:fulltext`
}

An index is a sub-collection of a collection where indices are stored to speed up looking up data in a collection.

type Iterator

type Iterator struct {
	*driver.Cursor
}

Iterator is a wrapper around the driver's cursor

type MapCursor

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

MapCursor implements the cursor infterface using a backing map. The keys are strings, the values binary. This type is probably most useful for testing and simulating a key/value store.

func NewMapCursor

func NewMapCursor(values map[string][]byte) *MapCursor

func (*MapCursor) First

func (c *MapCursor) First() (key []byte, value []byte)

func (MapCursor) Get

func (c MapCursor) Get(key []byte) []byte

func (*MapCursor) Next

func (c *MapCursor) Next() (key []byte, value []byte)

func (*MapCursor) Prev

func (c *MapCursor) Prev() (key []byte, value []byte)

func (*MapCursor) Put

func (c *MapCursor) Put(key, value []byte)

func (*MapCursor) Seek

func (c *MapCursor) Seek(seek []byte) (key []byte, value []byte)

func (MapCursor) This

func (c MapCursor) This() ([]byte, []byte)

type MatchCursor

type MatchCursor struct {
	MatchFunc
	// contains filtered or unexported fields
}

MatchCursor applies a boolean match function on an underlying cursor and only iterates over or seeks values that match.

func NewMatchCursor

func NewMatchCursor(underlying Cursor, f MatchFunc) *MatchCursor

func (*MatchCursor) Next

func (c *MatchCursor) Next() ([]byte, []byte)

func (*MatchCursor) Prev

func (c *MatchCursor) Prev() (key []byte, value []byte)

func (*MatchCursor) Seek

func (c *MatchCursor) Seek(seek []byte) (key []byte, value []byte)

type MatchFunc

type MatchFunc func(key, value []byte) bool

MatchFunc returns true if the key and value "match" and should be kept, or false if they are not needed.

type Op

type Op rune
const (
	OpEq  Op = '='
	OpGt  Op = '<'
	OpLt  Op = '>'
	OpAnd Op = '&'
	OpOr  Op = '|'
)

type Path

type Path string

Path is the path of a bucket.

func (Path) Parts

func (p Path) Parts() []string

type Permission

type Permission struct {
	Collection `json:"collection"`
}

type Query

type Query struct {
	Collection
	// contains filtered or unexported fields
}

func Select

func Select(c Collection) *Query

func (*Query) Where

func (q *Query) Where() *Where

type Storage

type Storage struct {
	*driver.DB
}

Storage is a wrapper around the driver's database or storage engine

type SubstituteCursor

type SubstituteCursor struct {
	SubstituteFunc
	// contains filtered or unexported fields
}

SubstituteCursor applies a substitution filter on an underlying cursor and iterates over or seeks values with that substitution applied. This could be useful for instance for only returning a part of the document.

func (*SubstituteCursor) Next

func (c *SubstituteCursor) Next() (key []byte, value []byte)

func (*SubstituteCursor) Prev

func (c *SubstituteCursor) Prev() (key []byte, value []byte)

func (*SubstituteCursor) Seek

func (c *SubstituteCursor) Seek(seek []byte) (key []byte, value []byte)

type SubstituteFunc

type SubstituteFunc func(key, value []byte) []byte

SubstituteFunc returns the value that should be used in stead of the original value. This may also be nil. The key is not subsituted. This may be useful, for instamcem for decrypting encrypted documents.

type Tx

type Tx struct {
	*driver.Tx
}

Tx is a wrapper around the driver's transactions.

type Where

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

func (*Where) And

func (w *Where) And() *Where

func (*Where) Cond

func (w *Where) Cond() *Cond

func (*Where) Op

func (w *Where) Op(op Op) *Where

func (*Where) Or

func (w *Where) Or() *Where

Directories

Path Synopsis
driver
bbolt-driver
Package bbolt-driver implements a bbolt driver for jidoco
Package bbolt-driver implements a bbolt driver for jidoco
interface

Jump to

Keyboard shortcuts

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