object

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Config holds the config of the object.ID generation.

Functions

func IDField

func IDField(name string) *fieldBuilder

IDField returns a new ent.Field with type object.ID.

func IDHook

func IDHook() ent.Hook

IDHook returns a new ent.Hook for generating the object.ID.

Types

type ID

type ID string

ID shows the primary key in string but stores in big integer, also be good at catching composited primary keys.

func NewID

func NewID(id uint64) ID

NewID creates an ID with the given integer.

func (*ID) Scan

func (i *ID) Scan(src any) error

Scan implements sql.Scanner.

func (ID) String

func (i ID) String() string

String implements fmt.Stringer.

func (ID) Valid

func (i ID) Valid() bool

Valid returns true if the given ID is a naive numeric value at least 18 digits, e.g. 440601964878987871.

func (ID) Value

func (i ID) Value() (driver.Value, error)

Value implements driver.Valuer.

type Refer

type Refer string

func (Refer) Extract

func (i Refer) Extract(idx int) ReferSegment

Extract extracts the index segment of the composited key with default separator into an array, it should be called after IsNumeric == false or IsComposited == true.

func (Refer) ID

func (i Refer) ID() ID

func (Refer) Int

func (i Refer) Int() int

func (Refer) Int64

func (i Refer) Int64() int64

func (Refer) IsComposited

func (i Refer) IsComposited(keyLength int) bool

IsComposited returns true if the given Refer is a composited value, combines with several fields of the object. E.g. X:y:z.

func (Refer) IsID

func (i Refer) IsID() bool

IsID returns true if the given Refer is an ID value.

func (Refer) IsNumeric

func (i Refer) IsNumeric() bool

IsNumeric returns true if the given Refer is a numeric value.

func (Refer) IsString

func (i Refer) IsString() bool

IsString returns true if the given Refer is a string value.

func (Refer) Split

func (i Refer) Split(length int) ReferSegments

Split splits the composited key with default separator into an array, it should be called after IsNumeric == false or IsComposited == true.

func (Refer) String

func (i Refer) String() string

type ReferSegment

type ReferSegment string

func (ReferSegment) Bool

func (i ReferSegment) Bool() bool

func (ReferSegment) ID

func (i ReferSegment) ID() ID

func (ReferSegment) Int

func (i ReferSegment) Int() int

func (ReferSegment) Int64

func (i ReferSegment) Int64() int64

func (ReferSegment) String

func (i ReferSegment) String() string

type ReferSegments

type ReferSegments []ReferSegment

func (ReferSegments) Index

func (i ReferSegments) Index(idx int) ReferSegment

Index gets the segment with the given order.

Jump to

Keyboard shortcuts

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