Documentation ¶
Index ¶
- func Bool(name string) *boolBuilder
- func Bytes(name string) *bytesBuilder
- func Enum(name string) *enumBuilder
- func Float(name string) *float64Builder
- func Float32(name string) *float32Builder
- func Floats(name string) *jsonBuilder
- func Int(name string) *intBuilder
- func Int16(name string) *int16Builder
- func Int32(name string) *int32Builder
- func Int64(name string) *int64Builder
- func Int8(name string) *int8Builder
- func Ints(name string) *jsonBuilder
- func JSON(name string, typ interface{}) *jsonBuilder
- func Other(name string, typ driver.Valuer) *otherBuilder
- func String(name string) *stringBuilder
- func Strings(name string) *jsonBuilder
- func Text(name string) *stringBuilder
- func Time(name string) *timeBuilder
- func UUID(name string, typ driver.Valuer) *uuidBuilder
- func Uint(name string) *uintBuilder
- func Uint16(name string) *uint16Builder
- func Uint32(name string) *uint32Builder
- func Uint64(name string) *uint64Builder
- func Uint8(name string) *uint8Builder
- type Annotation
- type Descriptor
- type EnumValues
- type RType
- type Type
- type TypeInfo
- type ValueScanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
func Bytes(name string) *bytesBuilder
Bytes returns a new Field with type bytes/buffer. In MySQL and SQLite, it is the "BLOB" type, and it does not support for Gremlin.
func Enum ¶
func Enum(name string) *enumBuilder
Enum returns a new Field with type enum. An example for defining enum is as follows:
field.Enum("state"). Values( "on", "off", ). Default("on")
func Float32 ¶
func Float32(name string) *float32Builder
Float32 returns a new Field with type float32.
func Floats ¶
func Floats(name string) *jsonBuilder
Floats returns a new JSON Field with type []float.
func JSON ¶
func JSON(name string, typ interface{}) *jsonBuilder
JSON returns a new Field with type json that is serialized to the given object. For example:
field.JSON("dirs", []http.Dir{}). Optional() field.JSON("info", &Info{}). Optional()
func Other ¶
Other represents a field that is not a good fit for any of the standard field types.
The second argument defines the GoType and must implement the ValueScanner interface. The SchemaType option must be set because the field type cannot be inferred. An example for defining Other field is as follows:
field.Other("link", &Link{}). SchemaType(map[string]string{ dialect.MySQL: "text", dialect.Postgres: "varchar", })
func Strings ¶
func Strings(name string) *jsonBuilder
Strings returns a new JSON Field with type []string.
func Text ¶
func Text(name string) *stringBuilder
Text returns a new string field without limitation on the size. In MySQL, it is the "longtext" type, but in SQLite and Gremlin it has not effect.
Types ¶
type Annotation ¶
type Annotation struct { // The StructTag option allows overriding the struct-tag // of the fields in the generated entity. For example: // // field.Annotation{ // StructTag: map[string]string{ // "id": `json:"id,omitempty" yaml:"-"` // } // } // StructTag map[string]string }
Annotation is a builtin schema annotation for configuring the schema fields in codegen.
func (Annotation) Merge ¶
func (a Annotation) Merge(other schema.Annotation) schema.Annotation
Merge implements the schema.Merger interface.
type Descriptor ¶
type Descriptor struct { Tag string // struct tag. Size int // varchar size. Name string // field name. Info *TypeInfo // field type info. Unique bool // unique index of field. Nillable bool // nillable struct field. Optional bool // nullable field in database. Immutable bool // create-only field. Default interface{} // default value on create. UpdateDefault interface{} // default value on update. Validators []interface{} // validator functions. StorageKey string // sql column or gremlin property. Enums []struct{ N, V string } // enum values. Sensitive bool // sensitive info string field. SchemaType map[string]string // override the schema type. Annotations []schema.Annotation // field annotations. Comment string // field comment. Err error }
A Descriptor for field configuration.
type EnumValues ¶
type EnumValues interface {
Values() []string
}
EnumValues defines the interface for getting the enum values.
type RType ¶
type RType struct { Name string // reflect.Type.Name Ident string // reflect.Type.String Kind reflect.Kind PkgPath string Methods map[string]struct{ In, Out []*RType } // contains filtered or unexported fields }
RType holds a serializable reflect.Type information of Go object. Used by the entc package.
type Type ¶
type Type uint8
A Type represents a field type.
const ( TypeInvalid Type = iota TypeBool TypeTime TypeJSON TypeUUID TypeBytes TypeEnum TypeString TypeOther TypeInt8 TypeInt16 TypeInt32 TypeInt TypeInt64 TypeUint8 TypeUint16 TypeUint32 TypeUint TypeUint64 TypeFloat32 TypeFloat64 )
List of field types.
func (Type) ConstName ¶
ConstName returns the constant name of a info type. It's used by entc for printing the constant name in templates.
type TypeInfo ¶
type TypeInfo struct { Type Type Ident string PkgPath string Nillable bool // slices or pointers. RType *RType }
TypeInfo holds the information regarding field type. Used by complex types like JSON and Bytes.
func (TypeInfo) Comparable ¶
Comparable reports whether values of this type are comparable.
func (TypeInfo) ValueScanner ¶
ValueScanner indicates if this type implements the ValueScanner interface.