model

package
v0.0.0-...-9c44629 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateTp    = "date-time"
	BooleanTp = "boolean"
	StringTp  = "string"
	IntegerTp = "integer"
	FloatTp   = "number"

	SchemeDefault = "default"
	SchemeMinimum = "minimum"
	SchemeMaximum = "maximum"
	TimeRFC3339   = "2006-01-02T15:04:05.999999999Z"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BooleanType

type BooleanType proto.BooleanType

func (*BooleanType) Bind

func (b *BooleanType) Bind(p *DTOStruct) error

func (*BooleanType) ToProtoStruct

func (b *BooleanType) ToProtoStruct() *structpb.Struct

type Column

type Column struct {
	Key       string
	Type      string
	MinLength int32
	MaxLength int32
	Minimum   int64
	Maximum   int64
}

type Columns

type Columns map[string]*structpb.Struct

type DTOStruct

type DTOStruct structpb.Struct

func (*DTOStruct) GetField

func (d *DTOStruct) GetField(field string) *structpb.Value

type DateTimeType

type DateTimeType proto.DateTimeType

func (*DateTimeType) Bind

func (b *DateTimeType) Bind(p *DTOStruct) error

func (*DateTimeType) Load

func (b *DateTimeType) Load()

func (*DateTimeType) ToProtoStruct

func (b *DateTimeType) ToProtoStruct() *structpb.Struct

type Fields

type Fields struct {
	Columns map[string]interface{}
}

func (*Fields) Scan

func (c *Fields) Scan(v interface{}) error

func (Fields) Value

func (c Fields) Value() (driver.Value, error)

type FloatType

type FloatType proto.FloatType

func (*FloatType) Bind

func (fl *FloatType) Bind(p *DTOStruct) error

func (*FloatType) ToProtoStruct

func (fl *FloatType) ToProtoStruct() *structpb.Struct

type IntegerType

type IntegerType proto.IntegerType

func (*IntegerType) Bind

func (i *IntegerType) Bind(p *DTOStruct) error

func (*IntegerType) ToProtoStruct

func (i *IntegerType) ToProtoStruct() *structpb.Struct

type JsonSchemaValidator

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

func NewValidator

func NewValidator() *JsonSchemaValidator

func (*JsonSchemaValidator) Validate

func (v *JsonSchemaValidator) Validate(schema Schema, record *structpb.Struct, opts ...JsonValidatorOption) []errors.FieldError

type JsonValidatorOption

type JsonValidatorOption func(*processContext)

func WithFieldErrorPrefix

func WithFieldErrorPrefix(prefix string) JsonValidatorOption

type PostLoad

type PostLoad interface {
	Load()
}

type Properties

type Properties struct {
	Columns map[string]PropertyType
}

func (*Properties) Scan

func (c *Properties) Scan(v interface{}) error

func (Properties) Value

func (c Properties) Value() (driver.Value, error)

type PropertyType

type PropertyType interface {
	Bind(p *DTOStruct) error
	ToProtoStruct() *structpb.Struct
}

func CreateProperty

func CreateProperty(p *DTOStruct) (PropertyType, error)

type Record

type Record struct {
	ID        uuid.UUID `gorm:"column:id;primary_key"`
	ProjectID uuid.UUID `gorm:"column:project_id"`
	SchemaID  uuid.UUID `gorm:"column:schema_id"`
	Fields    Fields    `gorm:"column:fields;type:bytea"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func NewRecord

func NewRecord(pid uuid.UUID, sid uuid.UUID, fields *structpb.Struct) *Record

func (*Record) BeforeCreate

func (r *Record) BeforeCreate(scope *gorm.Scope) error

type Required

type Required []string

func (*Required) Scan

func (c *Required) Scan(v interface{}) error

func (Required) Value

func (c Required) Value() (driver.Value, error)

type Schema

type Schema struct {
	ID         uuid.UUID  `gorm:"column:id;primary_key"`
	Name       string     `gorm:"column:name"`
	Properties Properties `gorm:"column:properties;type:bytea"`
	Required   Required   `gorm:"column:required;type:bytea"`
	ProjectID  uuid.UUID  `gorm:"column:project_id"`

	Version   string `gorm:"column:version;unique_index"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func NewSchema

func NewSchema(name string, projectID uuid.UUID, columns map[string]*structpb.Struct, required ...string) (*Schema, error)

func (*Schema) BeforeCreate

func (s *Schema) BeforeCreate(scope *gorm.Scope) error

func (Schema) GetProp

func (s Schema) GetProp(k string) PropertyType

func (Schema) JSONSchema

func (s Schema) JSONSchema() string

type StringType

type StringType proto.StringType

func (*StringType) Bind

func (s *StringType) Bind(p *DTOStruct) error

func (*StringType) ToProtoStruct

func (s *StringType) ToProtoStruct() *structpb.Struct

Jump to

Keyboard shortcuts

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