Documentation ¶
Index ¶
- Constants
- Variables
- func NewErrPrimaryIndexNotExist() error
- func NewValueForSchema(schema Schema, name string, av any) (any, error)
- func NewValueForType(et ElementType, av any) (any, error)
- type Coder
- type Collection
- type Decoder
- type Element
- type ElementType
- type Elements
- type Encoder
- type Index
- type IndexType
- type Indexes
- type Key
- type KeyCoder
- type KeyDecoder
- type KeyEncoder
- type MapObject
- type Object
- type Schema
Constants ¶
const (
// SchemaVersion specifies a latest schema version.
SchemaVersion = 1
)
Variables ¶
Functions ¶
func NewErrPrimaryIndexNotExist ¶ added in v1.0.3
func NewErrPrimaryIndexNotExist() error
NewErrPrimaryIndexNotExist returns a new error that the primary index is not exist.
func NewValueForSchema ¶ added in v1.0.1
NewValueForSchema returns a value for the specified schema.
func NewValueForType ¶ added in v1.0.1
func NewValueForType(et ElementType, av any) (any, error)
NewValueForType returns a value for the specified element type.
Types ¶
type Collection ¶ added in v0.9.0
type Collection interface { Schema }
Collection represents a collection.
func NewCollection ¶ added in v0.9.0
func NewCollection() Collection
NewCollection returns a blank collection.
func NewCollectionWith ¶ added in v0.9.0
func NewCollectionWith(obj any) (Collection, error)
NewCollectionWith returns a new collection with the specified object.
type Decoder ¶
type Decoder interface { // DecodeDocument returns the decorded object from the specified reader if available, otherwise returns an error. DecodeDocument(r io.Reader) (Object, error) }
An Decoder reads encorded objects from the specified input stream.
type Element ¶
type Element interface { // Name returns the unique name. Name() string // Type returns the index type. Type() ElementType // Data returns the raw representation data in memory. Data() any // SetName sets the specified name to the element. SetName(name string) Element // SetType sets the specified type to the element. SetType(t ElementType) Element }
type ElementType ¶
type ElementType int8
const ( // 0x0x (Reserved). // 0x1x (Reserved - Collection). ArrayType ElementType = 0x10 MapType ElementType = 0x11 // 0x20 Integer. Int8Type ElementType = 0x20 Int16Type ElementType = 0x21 Int32Type ElementType = 0x22 Int64Type ElementType = 0x23 // 0x30 StringType. StringType ElementType = 0x30 BinaryType ElementType = 0x31 // 0x40 Floating-point. Float32Type ElementType = 0x40 Float64Type ElementType = 0x41 // 0x70 Special. TimestampType ElementType = 0x70 BoolType ElementType = 0x71 )
func NewElementTypeWith ¶
func NewElementTypeWith(v any) (ElementType, error)
NewElementTypeWith returns an element type from the specified parameters.
func (ElementType) String ¶
func (et ElementType) String() string
String represents the string representation.
type Elements ¶ added in v1.0.0
type Elements []Element
Elements represents a list of Element.
type Encoder ¶
type Encoder interface { // EncodeDocument writes the specified object to the specified writer. EncodeDocument(w io.Writer, obj Object) error }
An Encoder writes the specified object to the specified output stream.
type Index ¶
type Index interface { // Name returns the unique name. Name() string // Type returns the index type. Type() IndexType // Elements returns the schema elements. Elements() []Element // SetName sets the specified name to the index. SetName(name string) Index // SetType sets the specified type to the element. SetType(t IndexType) Index // AddElement returns the schema elements. AddElement(elem Element) Index // Data returns the raw representation data in memory. Data() any }
type Key ¶
type Key []any
Key represents an unique key for a document object.
func NewKeyWith ¶
NewKeyWith returns a new key from the specified key elements.
func (Key) Collection ¶ added in v1.0.0
Collection returns the collection name of the key.
type KeyCoder ¶ added in v0.9.0
type KeyCoder interface { KeyDecoder KeyEncoder }
A KeyCoder includes key decoder and encoder interfaces.
type KeyDecoder ¶ added in v0.9.0
type KeyDecoder interface { // DecodeKey returns the decoded key from the specified bytes if available, otherwise returns an error. DecodeKey([]byte) (Key, error) }
An KeyDecoder decodes the specified bytes.
type KeyEncoder ¶ added in v0.9.0
type KeyEncoder interface { // EncodeKey returns the encoded bytes from the specified key if available, otherwise returns an error. EncodeKey(Key) ([]byte, error) }
An KeyEncoder encodes the specified key.
type MapObject ¶ added in v1.0.0
MapObject represents a map object.
func NewMapObjectFrom ¶ added in v1.0.0
NewMapObjectFrom returns a new map object from the specified object.
type Schema ¶
type Schema interface { // Version returns the schema version. Version() int // SetName sets the specified name to the schema. SetName(name string) // Name returns the schema name. Name() string // AddElement adds the specified element to the schema. AddElement(elem Element) error // DropElement drops the specified element from the schema. DropElement(name string) error // Elements returns the schema elements. Elements() Elements // FindElement returns the schema elements by the specified name. FindElement(name string) (Element, error) // AddIndex adds the specified index to the schema. AddIndex(idx Index) error // DropIndex drops the specified index from the schema. DropIndex(name string) error // Indexes returns the schema indexes. Indexes() Indexes // FindIndex returns the schema index by the spacified name. FindIndex(name string) (Index, error) // PrimaryIndex returns the schema primary index. PrimaryIndex() (Index, error) // SecondaryIndexes returns the schema secondary indexes. SecondaryIndexes() (Indexes, error) // Data returns the raw representation data in memory. Data() any }
Schema represents a schema.
func NewSchemaWith ¶
NewSchemaWith creates a schema from the specified object.