field

package
v0.0.35-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EmailPkgPath is the package path for the built-in email datatype
	EmailPkgPath = "github.com/lolopinto/ent/ent/field/email"

	// PasswordPkgPath is the package path for the built-in password datatype
	PasswordPkgPath = "github.com/lolopinto/ent/ent/field/password"
)

Variables

This section is empty.

Functions

func GetNilableGoType

func GetNilableGoType(f *Field) string

func GetNonNilableGoType

func GetNonNilableGoType(f *Field) string

func NormalizedField

func NormalizedField(s string) string

Types

type EmailPasswordCombo

type EmailPasswordCombo struct {
	Email    *Field
	Password *Field
}

EmailPasswordCombo holds a Pair of EmailPassword field used for validation

type Field

type Field struct {
	// todo: abstract out these 2 also...
	FieldName string
	// contains filtered or unexported fields
}

func (*Field) AddFieldEdgeToEdgeInfo

func (f *Field) AddFieldEdgeToEdgeInfo(edgeInfo *edge.EdgeInfo) error

func (*Field) AddForeignKeyEdgeToInverseEdgeInfo

func (f *Field) AddForeignKeyEdgeToInverseEdgeInfo(edgeInfo *edge.EdgeInfo, nodeName string) error

func (*Field) AddForeignKeyFieldEdgeToEdgeInfo

func (f *Field) AddForeignKeyFieldEdgeToEdgeInfo(edgeInfo *edge.EdgeInfo) error

We're going from field -> edge to be consistent and not have circular dependencies

func (*Field) AddInverseEdge

func (f *Field) AddInverseEdge(edge *edge.AssociationEdge) error

func (*Field) CamelCaseName

func (f *Field) CamelCaseName() string

func (*Field) Clone

func (f *Field) Clone(opts ...Option) (*Field, error)

func (*Field) CreateDBColumn

func (f *Field) CreateDBColumn() bool

func (*Field) DefaultValue

func (f *Field) DefaultValue() interface{}

func (*Field) EditableField

func (f *Field) EditableField() bool

func (*Field) EmbeddableInParentAction

func (f *Field) EmbeddableInParentAction() bool

func (*Field) EvolvedIDField

func (f *Field) EvolvedIDField() bool

func (*Field) ExposeToActionsByDefault

func (f *Field) ExposeToActionsByDefault() bool

func (*Field) ExposeToGraphQL

func (f *Field) ExposeToGraphQL() bool

func (*Field) FieldEdgeInfo

func (f *Field) FieldEdgeInfo() *base.FieldEdgeInfo

func (*Field) ForceOptionalInAction

func (f *Field) ForceOptionalInAction() bool

func (*Field) ForceRequiredInAction

func (f *Field) ForceRequiredInAction() bool

func (*Field) ForeignImports

func (f *Field) ForeignImports() []string

func (*Field) ForeignKeyInfo

func (f *Field) ForeignKeyInfo() *ForeignKeyInfo

func (*Field) GetCastToMethod

func (f *Field) GetCastToMethod() string

func (*Field) GetDbColName

func (f *Field) GetDbColName() string

func (*Field) GetDbTypeForField

func (f *Field) GetDbTypeForField() string

func (*Field) GetFieldNameInStruct

func (f *Field) GetFieldNameInStruct() string

GetFieldNameInStruct returns the name of the field in the struct definition with capital letter for public fields. lowercase letter for package-private

func (*Field) GetFieldTag

func (f *Field) GetFieldTag() string

func (*Field) GetFieldType

func (f *Field) GetFieldType() enttype.EntType

func (*Field) GetGraphQLName

func (f *Field) GetGraphQLName() string

func (*Field) GetGraphQLTypeForField

func (f *Field) GetGraphQLTypeForField() string

func (*Field) GetInverseEdge

func (f *Field) GetInverseEdge() *edge.AssociationEdge

func (*Field) GetNotNullableTsType

func (f *Field) GetNotNullableTsType() string

func (*Field) GetQuotedDBColName

func (f *Field) GetQuotedDBColName() string

func (*Field) GetTSGraphQLTypeForFieldImports

func (f *Field) GetTSGraphQLTypeForFieldImports(forceOptional bool) []enttype.FileImport

for non-required fields in actions, we want to make it optional if it's not a required field in the action

func (*Field) GetZeroValue

func (f *Field) GetZeroValue() string

func (*Field) HasDefaultValueOnCreate

func (f *Field) HasDefaultValueOnCreate() bool

func (*Field) HasDefaultValueOnEdit

func (f *Field) HasDefaultValueOnEdit() bool

func (*Field) IDField

func (f *Field) IDField() bool

func (*Field) IDType added in v0.0.30

func (f *Field) IDType() bool

func (*Field) Index

func (f *Field) Index() bool

func (*Field) InstanceFieldName

func (f *Field) InstanceFieldName() string

func (*Field) IsEditableIDField

func (f *Field) IsEditableIDField() bool

func (*Field) Nullable

func (f *Field) Nullable() bool

func (*Field) PkgPath

func (f *Field) PkgPath() string

func (*Field) Private

func (f *Field) Private() bool

func (*Field) QueryFrom

func (f *Field) QueryFrom() bool

TODO probably gonna collapse into above

func (*Field) QueryFromEnt added in v0.0.32

func (f *Field) QueryFromEnt() bool

func (*Field) QueryFromEntName added in v0.0.32

func (f *Field) QueryFromEntName() string

func (*Field) SingleFieldPrimaryKey

func (f *Field) SingleFieldPrimaryKey() bool

func (*Field) TopLevelStructField

func (f *Field) TopLevelStructField() bool

func (*Field) TsBuilderImports

func (f *Field) TsBuilderImports() []string

func (*Field) TsBuilderType

func (f *Field) TsBuilderType() string

func (*Field) TsFieldName

func (f *Field) TsFieldName() string

TODO add GoFieldName and kill FieldName as public...

func (*Field) TsType

func (f *Field) TsType() string

func (*Field) Unique

func (f *Field) Unique() bool

type FieldInfo

type FieldInfo struct {
	Fields []*Field

	// really only used in tests
	NonEntFields []*NonEntField
	// contains filtered or unexported fields
}

func GetFieldInfoForStruct

func GetFieldInfoForStruct(s *ast.StructType, info *types.Info) (*FieldInfo, error)

func NewFieldInfoFromInputs

func NewFieldInfoFromInputs(fields []*input.Field, options *Options) (*FieldInfo, error)

NewFieldInfoFromInputs generates Fields based on FieldInputs Decouples the parsing of fields from the logic associated with it Means this can be called by multiple languages using this or different formats/sources in each language e.g. golang supporting fields in a struct or the stronger API (ent.FieldMap)

func ParseFieldsFunc

func ParseFieldsFunc(pkg *packages.Package, fn *ast.FuncDecl) (*FieldInfo, error)

func (*FieldInfo) GetEditableFields

func (fieldInfo *FieldInfo) GetEditableFields() []*Field

func (*FieldInfo) GetEmailPasswordCombo

func (fieldInfo *FieldInfo) GetEmailPasswordCombo() *EmailPasswordCombo

GetEmailPasswordCombo returns an instance of EmailPasswordCombo if we should have the ValidateEmailPassword method for email/password validation

func (*FieldInfo) GetFieldByColName

func (fieldInfo *FieldInfo) GetFieldByColName(col string) *Field

func (*FieldInfo) GetFieldByName

func (fieldInfo *FieldInfo) GetFieldByName(fieldName string) *Field

func (*FieldInfo) GetFieldsFn

func (fieldInfo *FieldInfo) GetFieldsFn() bool

GetFieldsFn returns a boolean which when returns true indicates that the Node used the GetFields() API in the config to define fields as opposed to fields in a struct

func (*FieldInfo) GraphQLFields

func (fieldInfo *FieldInfo) GraphQLFields() []*Field

func (*FieldInfo) InvalidateFieldForGraphQL

func (fieldInfo *FieldInfo) InvalidateFieldForGraphQL(f *Field) error

func (*FieldInfo) TopLevelFields

func (fieldInfo *FieldInfo) TopLevelFields() []*Field

type ForeignKeyInfo

type ForeignKeyInfo struct {
	Schema       string
	Field        string
	Name         string
	DisableIndex bool
}

ForeignKeyInfo stores config and field name of the foreign key object

type NonEntField

type NonEntField struct {
	FieldName string
	FieldType enttype.Type
}

func (*NonEntField) GetGraphQLName

func (f *NonEntField) GetGraphQLName() string

type Option

type Option func(*Field)

func Optional

func Optional() Option

func Required

func Required() Option

type Options

type Options struct {
	SortFields    bool
	AddBaseFields bool
}

Jump to

Keyboard shortcuts

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