schema

package
v0.62.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: BSD-2-Clause Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Node
	SqlName string
	Encode  SqlEncode `json:",omitempty" yaml:",omitempty"`
	Tags    *Tag      `json:",omitempty" yaml:",omitempty"`
}

func (*Field) AutoIncrement added in v0.13.0

func (f *Field) AutoIncrement() bool

func (*Field) GetTags added in v0.12.0

func (f *Field) GetTags() Tag

func (*Field) IsExported

func (f *Field) IsExported() bool

func (*Field) NaturalKey added in v0.13.0

func (f *Field) NaturalKey() bool

func (*Field) PrimaryKey added in v0.13.0

func (f *Field) PrimaryKey() bool

func (*Field) Skip added in v0.13.0

func (f *Field) Skip() bool

type FieldList

type FieldList []*Field

func (FieldList) BasicType added in v0.17.0

func (list FieldList) BasicType() FieldList

BasicType returns all the fields that have basic (primitive) types.

func (FieldList) DerivedType added in v0.17.0

func (list FieldList) DerivedType() FieldList

DerivedType returns all the fields that have have derived types.

func (FieldList) DistinctTypes

func (list FieldList) DistinctTypes() []Type

func (FieldList) Filter added in v0.12.0

func (list FieldList) Filter(predicate func(*Field) bool) FieldList

func (FieldList) FormalParams

func (list FieldList) FormalParams() Identifiers

func (FieldList) IsEmpty added in v0.42.0

func (list FieldList) IsEmpty() bool

func (FieldList) Names

func (list FieldList) Names() Identifiers

func (FieldList) NoAuto added in v0.12.0

func (list FieldList) NoAuto() FieldList

NoPrimary returns all the fields except any marked auto-increment.

func (FieldList) NoPointers added in v0.12.0

func (list FieldList) NoPointers() FieldList

Pointers returns only the fields that have non-pointer types.

func (FieldList) NoPrimary added in v0.12.0

func (list FieldList) NoPrimary() FieldList

NoPrimary returns all the fields except any marked primary.

func (FieldList) NoSkips

func (list FieldList) NoSkips() FieldList

NoSkips returns only the fields without the skip flag set.

func (FieldList) NonEmpty added in v0.42.0

func (list FieldList) NonEmpty() bool

func (FieldList) Pointers

func (list FieldList) Pointers() FieldList

Pointers returns only the fields that have pointer types.

func (FieldList) SqlNames

func (list FieldList) SqlNames() Identifiers

func (FieldList) WhereClauses

func (list FieldList) WhereClauses() Identifiers

type Identifiers

type Identifiers []string

func (Identifiers) MkString

func (ids Identifiers) MkString(sep string) string

func (Identifiers) MkString3

func (ids Identifiers) MkString3(before, separator, after string) string

func (Identifiers) MkString3W

func (ids Identifiers) MkString3W(w io.Writer, before, separator, after string)

func (Identifiers) Quoted

func (ids Identifiers) Quoted(w io.Writer, quoter func(string) string)

type Index

type Index struct {
	Name   string
	Unique bool
	Fields FieldList
}

func (*Index) Columns

func (i *Index) Columns() string

func (*Index) JoinedNames

func (i *Index) JoinedNames(sep string) string

func (*Index) Single

func (i *Index) Single() bool

func (*Index) UniqueStr

func (i *Index) UniqueStr() string

type Node

type Node struct {
	Name   string
	Type   Type
	Parent *Node `json:",omitempty" yaml:",omitempty"`
}

func (*Node) JoinParts

func (node *Node) JoinParts(delta int, sep string) string

func (*Node) Parts

func (node *Node) Parts() []string

Parts gets the node containment chain as a sequence of names of parts.

type SqlEncode

type SqlEncode int
const (
	ENCNONE   SqlEncode = iota
	ENCJSON             // For JSON-encoded fields
	ENCTEXT             // For generic text-encoded fields
	ENCDRIVER           // SQL driver uses Scan() & Value() to encode & decode
)

type TableDescription

type TableDescription struct {
	Type string
	Name string

	Fields  FieldList
	Index   []*Index `json:",omitempty" yaml:",omitempty"`
	Primary *Field   `json:",omitempty" yaml:",omitempty"` // compound primaries are not supported
}

func (*TableDescription) ColumnNames

func (table *TableDescription) ColumnNames(withAuto bool) Identifiers

func (*TableDescription) HasIntegerPrimaryKey added in v0.43.0

func (t *TableDescription) HasIntegerPrimaryKey() bool

func (*TableDescription) HasPrimaryKey

func (t *TableDescription) HasPrimaryKey() bool

func (*TableDescription) NumColumnNames

func (t *TableDescription) NumColumnNames(withAuto bool) int

func (*TableDescription) SafePrimary

func (t *TableDescription) SafePrimary() Field

func (*TableDescription) SimpleFields

func (t *TableDescription) SimpleFields() FieldList

type Type

type Type struct {
	Name      string // name of source code type.
	PkgPath   string `json:",omitempty" yaml:",omitempty"` // package name (full path)
	PkgName   string `json:",omitempty" yaml:",omitempty"` // package name (short name)
	IsPtr     bool   `json:",omitempty" yaml:",omitempty"`
	IsScanner bool   `json:",omitempty" yaml:",omitempty"`
	IsValuer  bool   `json:",omitempty" yaml:",omitempty"`
	Base      Kind   // underlying source code kind.
}

func (Type) IsBasicType added in v0.17.0

func (t Type) IsBasicType() bool

func (Type) NullableValue

func (t Type) NullableValue() string

func (Type) Star

func (t Type) Star() string

func (Type) String

func (t Type) String() string

func (Type) Tag

func (t Type) Tag() string

func (Type) Type

func (t Type) Type() string

type TypeSet

type TypeSet map[Type]struct{}

TypeSet is the primary type that represents a set

func BuildTypeSetFromChan

func BuildTypeSetFromChan(source <-chan Type) TypeSet

BuildTypeSetFromChan constructs a new TypeSet from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertTypeSet

func ConvertTypeSet(values ...interface{}) (TypeSet, bool)

ConvertTypeSet constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly.

func NewTypeSet

func NewTypeSet(values ...Type) TypeSet

NewTypeSet creates and returns a reference to an empty set.

func (TypeSet) Add

func (set TypeSet) Add(i ...Type) TypeSet

Add adds items to the current set, returning the modified set.

func (TypeSet) Append

func (set TypeSet) Append(more ...Type) TypeSet

Union returns a new set with all items in both sets.

func (TypeSet) Cardinality

func (set TypeSet) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*TypeSet) Clear

func (set *TypeSet) Clear()

Clear clears the entire set to be the empty set.

func (TypeSet) Clone

func (set TypeSet) Clone() TypeSet

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (TypeSet) Contains

func (set TypeSet) Contains(i Type) bool

Contains determines if a given item is already in the set.

func (TypeSet) ContainsAll

func (set TypeSet) ContainsAll(i ...Type) bool

ContainsAll determines if the given items are all in the set

func (TypeSet) CountBy

func (set TypeSet) CountBy(predicate func(Type) bool) (result int)

CountBy gives the number elements of TypeSet that return true for the passed predicate.

func (TypeSet) Difference

func (set TypeSet) Difference(other TypeSet) TypeSet

Difference returns a new set with items in the current set but not in the other set

func (TypeSet) Equals

func (set TypeSet) Equals(other TypeSet) bool

Equals determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (TypeSet) Exists

func (set TypeSet) Exists(fn func(Type) bool) bool

Exists applies a predicate function to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (TypeSet) Filter

func (set TypeSet) Filter(fn func(Type) bool) TypeSet

Filter returns a new TypeSet whose elements return true for func. The original set is not modified

func (TypeSet) FlatMap

func (set TypeSet) FlatMap(fn func(Type) []Type) TypeSet

FlatMap returns a new TypeSet by transforming every element with a function fn that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (TypeSet) Forall

func (set TypeSet) Forall(fn func(Type) bool) bool

Forall applies a predicate function to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (TypeSet) Foreach

func (set TypeSet) Foreach(fn func(Type))

Foreach iterates over TypeSet and executes the passed func against each element.

func (TypeSet) Intersect

func (set TypeSet) Intersect(other TypeSet) TypeSet

Intersect returns a new set with items that exist only in both sets.

func (TypeSet) IsEmpty

func (set TypeSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (TypeSet) IsSequence

func (set TypeSet) IsSequence() bool

IsSequence returns true for lists.

func (TypeSet) IsSet

func (set TypeSet) IsSet() bool

IsSet returns false for lists.

func (TypeSet) IsSubset

func (set TypeSet) IsSubset(other TypeSet) bool

IsSubset determines if every item in the other set is in this set.

func (TypeSet) IsSuperset

func (set TypeSet) IsSuperset(other TypeSet) bool

IsSuperset determines if every item of this set is in the other set.

func (TypeSet) Map

func (set TypeSet) Map(fn func(Type) Type) TypeSet

Map returns a new TypeSet by transforming every element with a function fn. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (TypeSet) MaxBy

func (set TypeSet) MaxBy(less func(Type, Type) bool) Type

MaxBy returns an element of TypeSet containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (TypeSet) MinBy

func (set TypeSet) MinBy(less func(Type, Type) bool) Type

MinBy returns an element of TypeSet containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (TypeSet) NonEmpty

func (set TypeSet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (TypeSet) Partition

func (set TypeSet) Partition(p func(Type) bool) (TypeSet, TypeSet)

Partition returns two new TypeSets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list. The original set is not modified

func (TypeSet) Remove

func (set TypeSet) Remove(i Type)

Remove allows the removal of a single item from the set.

func (TypeSet) Send

func (set TypeSet) Send() <-chan Type

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (TypeSet) Size

func (set TypeSet) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (TypeSet) SymmetricDifference

func (set TypeSet) SymmetricDifference(other TypeSet) TypeSet

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (TypeSet) ToInterfaceSlice

func (set TypeSet) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (TypeSet) ToSlice

func (set TypeSet) ToSlice() []Type

ToSlice returns the elements of the current set as a slice.

func (TypeSet) Union

func (set TypeSet) Union(other TypeSet) TypeSet

Union returns a new set with all items in both sets.

Jump to

Keyboard shortcuts

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