schema

package
v0.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name  string
	Child Exp
}

Action -

type Child

type Child Exp

Child -

type ChildKind

type ChildKind string
const (
	LeafKind    ChildKind = "leaf"
	RewriteKind ChildKind = "rewrite"
)

func (ChildKind) String

func (o ChildKind) String() string

type Entity

type Entity struct {
	Name      string
	Relations []Relation
	Actions   []Action

	// option
	EntityOption EntityOption
}

Entity -

func (Entity) GetAction

func (e Entity) GetAction(name string) Action

GetAction -

type EntityOption

type EntityOption struct {
	Table      string
	Identifier string
}

EntityOption -

type Exp

type Exp interface {
	GetType() string
	GetKind() string
}

type Leaf

type Leaf struct {
	Type  LeafType // tupleToUserSet or computedUserSet
	Value string
}

Leaf -

func (Leaf) GetKind

func (Leaf) GetKind() string

GetKind -

func (Leaf) GetType

func (l Leaf) GetType() string

GetType -

type LeafType

type LeafType string

LeafType -

const (
	ComputedUserSetType LeafType = "computed_user_set"
	TupleToUserSetType  LeafType = "tuple_to_user_set"
)

func (LeafType) String

func (o LeafType) String() string

type OPType

type OPType string

OPType -

const (
	Union        OPType = "union"
	Intersection OPType = "intersection"
)

func (OPType) String

func (o OPType) String() string

type Relation

type Relation struct {
	Name string
	Type string

	// option
	RelationOption RelationOption
}

Relation -

type RelationOption

type RelationOption struct {
	Table string
	Rel   RelationType
	Cols  []string
}

RelationOption -

type RelationType

type RelationType string

RelationType -

const (
	BelongsTo  RelationType = "belongs-to"
	ManyToMany RelationType = "many-to-many"
	Custom     RelationType = "custom"
)

type Relations

type Relations []Relation

func (Relations) Filter

func (r Relations) Filter(relationTypes ...RelationType) (relations Relations)

Filter -

func (Relations) GetRelationByName

func (r Relations) GetRelationByName(name string) (relation Relation)

GetRelationByName -

type Rewrite

type Rewrite struct {
	Type     OPType // union or intersection
	Children []Child
}

Rewrite -

func (Rewrite) GetKind

func (Rewrite) GetKind() string

GetKind -

func (Rewrite) GetType

func (r Rewrite) GetType() string

GetType -

type Schema

type Schema struct {
	// all entities
	Entities map[string]Entity

	// all tables
	Tables map[string]TableType

	// table name to entities
	TableToEntity map[string]Entity

	// pivot name to entities
	PivotToEntity map[string]Entity

	// pivot name to relation
	PivotToRelation map[string]Relation
}

func NewSchema

func NewSchema(entities ...Entity) (schema Schema)

NewSchema -

func (Schema) GetEntityByName

func (s Schema) GetEntityByName(name string) Entity

GetEntityByName -

func (Schema) GetEntityByTableName

func (s Schema) GetEntityByTableName(table string) Entity

GetEntityByTableName -

func (Schema) GetTableType

func (s Schema) GetTableType(table string) TableType

GetTableType -

type TableType

type TableType string

TableType -

const (
	Main  TableType = "main"
	Pivot TableType = "pivot"
)

Jump to

Keyboard shortcuts

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