schemer

package module
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 10 Imported by: 3

README

schemer

Data serialization library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValueTypes = map[string]ValueType{
	"string": TYPE_STRING,
	"binary": TYPE_BINARY,
	"int":    TYPE_INT64,
	"uint":   TYPE_UINT64,
	"float":  TYPE_FLOAT64,
	"bool":   TYPE_BOOLEAN,
	"time":   TYPE_TIME,
	"array":  TYPE_ARRAY,
	"map":    TYPE_MAP,
	"any":    TYPE_ANY,
}

Functions

func Unmarshal added in v0.0.4

func Unmarshal(data map[string]interface{}, s *Schema) error

func UnmarshalDefinition

func UnmarshalDefinition(data interface{}, d *Definition) error

func UnmarshalJSON added in v0.0.4

func UnmarshalJSON(source []byte, s *Schema) error

Types

type Context

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

func NewContext

func NewContext() *Context

func (*Context) IsReady

func (ctx *Context) IsReady() bool

func (*Context) PreloadScript

func (ctx *Context) PreloadScript(p *goja.Program) error

type Definition

type Definition struct {
	Definition *Schema
	Type       ValueType
	Subtype    ValueType
	Info       interface{}
	NotNull    bool
}

func NewDefinition

func NewDefinition(t ValueType) *Definition

type RawDefinition

type RawDefinition struct {
	Type    string                 `mapstructure:"type"`
	Subtype string                 `mapstructure:"subtype"`
	Fields  map[string]interface{} `mapstructure:"fields"`
	NotNull bool                   `mapstructure:"notNull"`
}

type Record

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

func NewRecord

func NewRecord(schema *Schema, raw map[string]interface{}) *Record

func (*Record) GetValue

func (r *Record) GetValue(valuePath string) *Value

type Schema

type Schema struct {
	Fields map[string]*Definition
	Mutex  sync.RWMutex
}

func NewSchema

func NewSchema() *Schema

func (*Schema) GetDefinition

func (s *Schema) GetDefinition(valuePath string) *Definition

func (*Schema) Normalize

func (s *Schema) Normalize(data map[string]interface{}) map[string]interface{}

func (*Schema) Scan

func (s *Schema) Scan(data map[string]interface{}) *Record

type Schemer

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

func NewSchemer

func NewSchemer() *Schemer

type Transformer

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

func NewTransformer

func NewTransformer(source *Schema, dest *Schema) *Transformer

func (*Transformer) GetDestinationSchema added in v0.0.10

func (t *Transformer) GetDestinationSchema() *Schema

func (*Transformer) GetSourceSchema added in v0.0.10

func (t *Transformer) GetSourceSchema() *Schema

func (*Transformer) SetDestinationSchema added in v0.0.4

func (t *Transformer) SetDestinationSchema(schema *Schema)

func (*Transformer) SetScript

func (t *Transformer) SetScript(script string) error

func (*Transformer) SetSourceSchema added in v0.0.4

func (t *Transformer) SetSourceSchema(schema *Schema)

func (*Transformer) Transform

func (t *Transformer) Transform(env map[string]interface{}, input map[string]interface{}) ([]map[string]interface{}, error)

type Value

type Value struct {
	Definition *Definition
	Data       interface{}
}

func NewValue

func NewValue(def *Definition) *Value

type ValueType

type ValueType int32
const (
	TYPE_BOOLEAN ValueType = 0
	TYPE_BINARY  ValueType = 1
	TYPE_STRING  ValueType = 2
	TYPE_UINT64  ValueType = 3
	TYPE_INT64   ValueType = 4
	TYPE_FLOAT64 ValueType = 5
	TYPE_ARRAY   ValueType = 6
	TYPE_MAP     ValueType = 7
	TYPE_TIME    ValueType = 8
	TYPE_NULL    ValueType = 9
	TYPE_ANY     ValueType = 10
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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