schema

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidConstrainType = errors.New("invalid ConstrainType type")
View Source
var InvalidDatatype = errors.New("invalid Datatype type")
View Source
var InvalidDefType = errors.New("invalid DefType type")
View Source
var PkgTypes = "github.com/machinefi/w3bstream/pkg/depends/base/types"

Functions

This section is empty.

Types

type Col

type Col struct {
	Name        string      `json:"name"`
	Type        Datatype    `json:"type"`
	Constraints []Constrain `json:"constraints"`
	Comment     string      `json:"comment"`
}

func (*Col) ColumnName

func (c *Col) ColumnName() string

func (*Col) FieldName

func (c *Col) FieldName() string

func (*Col) Tag

func (c *Col) Tag() string

type Constrain

type Constrain struct {
	Type  ConstrainType `json:"type"`
	Value interface{}   `json:"value"`
}

func (*Constrain) Tag

func (c *Constrain) Tag() string

type ConstrainType

type ConstrainType int8
const (
	CONSTRAIN_TYPE_UNKNOWN ConstrainType = iota
	CONSTRAIN_TYPE__AUTOINCREMENT
	CONSTRAIN_TYPE__NOT_NULL
	CONSTRAIN_TYPE__DEFAULT
)

func ParseConstrainTypeFromLabel

func ParseConstrainTypeFromLabel(s string) (ConstrainType, error)

func ParseConstrainTypeFromString

func ParseConstrainTypeFromString(s string) (ConstrainType, error)

func (ConstrainType) ConstValues

func (v ConstrainType) ConstValues() []enum.IntStringerEnum

func (ConstrainType) Int

func (v ConstrainType) Int() int

func (ConstrainType) Label

func (v ConstrainType) Label() string

func (ConstrainType) MarshalText

func (v ConstrainType) MarshalText() ([]byte, error)

func (*ConstrainType) Scan

func (v *ConstrainType) Scan(src interface{}) error

func (ConstrainType) String

func (v ConstrainType) String() string

func (ConstrainType) Tag

func (v ConstrainType) Tag(driver string, value interface{}) string

func (ConstrainType) TypeName

func (v ConstrainType) TypeName() string

func (*ConstrainType) UnmarshalText

func (v *ConstrainType) UnmarshalText(data []byte) error

func (ConstrainType) Value

func (v ConstrainType) Value() (driver.Value, error)

type Datatype

type Datatype uint8
const (
	DATATYPE_UNKNOWN Datatype = iota
	DATATYPE__INT
	DATATYPE__INT8
	DATATYPE__INT16
	DATATYPE__INT32
	DATATYPE__INT64
	DATATYPE__UINT
	DATATYPE__UINT8
	DATATYPE__UINT16
	DATATYPE__UINT32
	DATATYPE__UINT64
	DATATYPE__STRING
	DATATYPE__BOOL
	DATATYPE__TIMESTAMP
)

func ParseDatatypeFromLabel

func ParseDatatypeFromLabel(s string) (Datatype, error)

func ParseDatatypeFromString

func ParseDatatypeFromString(s string) (Datatype, error)

func (*Datatype) CodeGenType

func (d *Datatype) CodeGenType(f *codegen.File) codegen.SnippetType

func (Datatype) ConstValues

func (v Datatype) ConstValues() []enum.IntStringerEnum

func (Datatype) Int

func (v Datatype) Int() int

func (Datatype) Label

func (v Datatype) Label() string

func (Datatype) MarshalText

func (v Datatype) MarshalText() ([]byte, error)

func (*Datatype) Scan

func (v *Datatype) Scan(src interface{}) error

func (Datatype) String

func (v Datatype) String() string

func (Datatype) TypeName

func (v Datatype) TypeName() string

func (*Datatype) UnmarshalText

func (v *Datatype) UnmarshalText(data []byte) error

func (Datatype) Value

func (v Datatype) Value() (driver.Value, error)

type Def

type Def struct {
	Type DefType  `json:"type"`
	Name string   `json:"name"`
	Cols []string `json:"cols"`
}

type DefType

type DefType int8
const (
	DEF_TYPE_UNKNOWN DefType = iota
	DEF_TYPE__PRIMARY
	DEF_TYPE__INDEX
	DEF_TYPE__UNIQUE_INDEX
)

func ParseDefTypeFromLabel

func ParseDefTypeFromLabel(s string) (DefType, error)

func ParseDefTypeFromString

func ParseDefTypeFromString(s string) (DefType, error)

func (DefType) ConstValues

func (v DefType) ConstValues() []enum.IntStringerEnum

func (DefType) Int

func (v DefType) Int() int

func (DefType) Label

func (v DefType) Label() string

func (DefType) MarshalText

func (v DefType) MarshalText() ([]byte, error)

func (*DefType) Scan

func (v *DefType) Scan(src interface{}) error

func (DefType) String

func (v DefType) String() string

func (DefType) TypeName

func (v DefType) TypeName() string

func (*DefType) UnmarshalText

func (v *DefType) UnmarshalText(data []byte) error

func (DefType) Value

func (v DefType) Value() (driver.Value, error)

type Schema

type Schema struct {
	Project string
	Version string
	Tables  []Table
	// contains filtered or unexported fields
}

func Load

func Load(content []byte, root, project, version string) (*Schema, error)

func LoadConfigFrom

func LoadConfigFrom(path, root, project, version string) (*Schema, error)

func (*Schema) Comments

func (c *Schema) Comments() map[string][]string

func (*Schema) File

func (c *Schema) File(name string) *g.File

func (*Schema) SchemaName

func (c *Schema) SchemaName() string

func (*Schema) SnippetSchema

func (c *Schema) SnippetSchema(f *g.File) g.Snippet

func (*Schema) SnippetStruct

func (c *Schema) SnippetStruct(comments map[string][]string) map[string]g.Snippet

func (*Schema) WriteSchema

func (c *Schema) WriteSchema(root string) error

func (*Schema) WriteTables

func (c *Schema) WriteTables(root string) error

type Table

type Table struct {
	Name    string `json:"name"`
	Comment string `json:"comment"`
	Defs    []Def  `json:"defs"`
	Cols    []Col  `json:"cols"`
	// contains filtered or unexported fields
}

func (*Table) TableName

func (t *Table) TableName() string

func (*Table) TypeName

func (t *Table) TypeName() string

Directories

Path Synopsis
demo

Jump to

Keyboard shortcuts

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