Documentation ¶
Index ¶
- Constants
- Variables
- func Asc(fields ...string) func(*sql.Selector)
- func Desc(fields ...string) func(*sql.Selector)
- func IsConstraintError(err error) bool
- func IsNotFound(err error) bool
- func IsNotLoaded(err error) bool
- func IsNotSingular(err error) bool
- func IsValidationError(err error) bool
- func MaskNotFound(err error) error
- func NewContext(parent context.Context, c *Client) context.Context
- func NewTxContext(parent context.Context, tx *Tx) context.Context
- type AggregateFunc
- type Client
- func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (c *Client) Close() error
- func (c *Client) Debug() *Client
- func (c *Client) Intercept(interceptors ...Interceptor)
- func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error)
- func (c *Client) Tx(ctx context.Context) (*Tx, error)
- func (c *Client) Use(hooks ...Hook)
- type CommitFunc
- type CommitHook
- type Committer
- type ConstraintError
- type Hook
- type Human
- type HumanClient
- func (c *HumanClient) Create() *HumanCreate
- func (c *HumanClient) CreateBulk(builders ...*HumanCreate) *HumanCreateBulk
- func (c *HumanClient) Delete() *HumanDelete
- func (c *HumanClient) DeleteOne(h *Human) *HumanDeleteOne
- func (c *HumanClient) DeleteOneID(id uuid.UUID) *HumanDeleteOne
- func (c *HumanClient) Get(ctx context.Context, id uuid.UUID) (*Human, error)
- func (c *HumanClient) GetX(ctx context.Context, id uuid.UUID) *Human
- func (c *HumanClient) Hooks() []Hook
- func (c *HumanClient) Intercept(interceptors ...Interceptor)
- func (c *HumanClient) Interceptors() []Interceptor
- func (c *HumanClient) MapCreateBulk(slice any, setFunc func(*HumanCreate, int)) *HumanCreateBulk
- func (c *HumanClient) Query() *HumanQuery
- func (c *HumanClient) Update() *HumanUpdate
- func (c *HumanClient) UpdateOne(h *Human) *HumanUpdateOne
- func (c *HumanClient) UpdateOneID(id uuid.UUID) *HumanUpdateOne
- func (c *HumanClient) Use(hooks ...Hook)
- type HumanCreate
- func (hc *HumanCreate) Exec(ctx context.Context) error
- func (hc *HumanCreate) ExecX(ctx context.Context)
- func (hc *HumanCreate) Mutation() *HumanMutation
- func (hc *HumanCreate) Save(ctx context.Context) (*Human, error)
- func (hc *HumanCreate) SaveX(ctx context.Context) *Human
- func (hc *HumanCreate) SetID(u uuid.UUID) *HumanCreate
- func (hc *HumanCreate) SetName(s string) *HumanCreate
- type HumanCreateBulk
- type HumanDelete
- type HumanDeleteOne
- type HumanGroupBy
- func (hgb *HumanGroupBy) Aggregate(fns ...AggregateFunc) *HumanGroupBy
- func (s *HumanGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *HumanGroupBy) BoolX(ctx context.Context) bool
- func (s *HumanGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *HumanGroupBy) BoolsX(ctx context.Context) []bool
- func (s *HumanGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *HumanGroupBy) Float64X(ctx context.Context) float64
- func (s *HumanGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *HumanGroupBy) Float64sX(ctx context.Context) []float64
- func (s *HumanGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *HumanGroupBy) IntX(ctx context.Context) int
- func (s *HumanGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *HumanGroupBy) IntsX(ctx context.Context) []int
- func (hgb *HumanGroupBy) Scan(ctx context.Context, v any) error
- func (s *HumanGroupBy) ScanX(ctx context.Context, v any)
- func (s *HumanGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *HumanGroupBy) StringX(ctx context.Context) string
- func (s *HumanGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *HumanGroupBy) StringsX(ctx context.Context) []string
- type HumanMutation
- func (m *HumanMutation) AddField(name string, value ent.Value) error
- func (m *HumanMutation) AddedEdges() []string
- func (m *HumanMutation) AddedField(name string) (ent.Value, bool)
- func (m *HumanMutation) AddedFields() []string
- func (m *HumanMutation) AddedIDs(name string) []ent.Value
- func (m *HumanMutation) ClearEdge(name string) error
- func (m *HumanMutation) ClearField(name string) error
- func (m *HumanMutation) ClearedEdges() []string
- func (m *HumanMutation) ClearedFields() []string
- func (m HumanMutation) Client() *Client
- func (m *HumanMutation) EdgeCleared(name string) bool
- func (m *HumanMutation) Field(name string) (ent.Value, bool)
- func (m *HumanMutation) FieldCleared(name string) bool
- func (m *HumanMutation) Fields() []string
- func (m *HumanMutation) ID() (id uuid.UUID, exists bool)
- func (m *HumanMutation) IDs(ctx context.Context) ([]uuid.UUID, error)
- func (m *HumanMutation) Name() (r string, exists bool)
- func (m *HumanMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *HumanMutation) OldName(ctx context.Context) (v string, err error)
- func (m *HumanMutation) Op() Op
- func (m *HumanMutation) RemovedEdges() []string
- func (m *HumanMutation) RemovedIDs(name string) []ent.Value
- func (m *HumanMutation) ResetEdge(name string) error
- func (m *HumanMutation) ResetField(name string) error
- func (m *HumanMutation) ResetName()
- func (m *HumanMutation) SetField(name string, value ent.Value) error
- func (m *HumanMutation) SetID(id uuid.UUID)
- func (m *HumanMutation) SetName(s string)
- func (m *HumanMutation) SetOp(op Op)
- func (m HumanMutation) Tx() (*Tx, error)
- func (m *HumanMutation) Type() string
- func (m *HumanMutation) Where(ps ...predicate.Human)
- func (m *HumanMutation) WhereP(ps ...func(*sql.Selector))
- type HumanQuery
- func (hq *HumanQuery) Aggregate(fns ...AggregateFunc) *HumanSelect
- func (hq *HumanQuery) All(ctx context.Context) ([]*Human, error)
- func (hq *HumanQuery) AllX(ctx context.Context) []*Human
- func (hq *HumanQuery) Clone() *HumanQuery
- func (hq *HumanQuery) Count(ctx context.Context) (int, error)
- func (hq *HumanQuery) CountX(ctx context.Context) int
- func (hq *HumanQuery) Exist(ctx context.Context) (bool, error)
- func (hq *HumanQuery) ExistX(ctx context.Context) bool
- func (hq *HumanQuery) First(ctx context.Context) (*Human, error)
- func (hq *HumanQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)
- func (hq *HumanQuery) FirstIDX(ctx context.Context) uuid.UUID
- func (hq *HumanQuery) FirstX(ctx context.Context) *Human
- func (hq *HumanQuery) GroupBy(field string, fields ...string) *HumanGroupBy
- func (hq *HumanQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error)
- func (hq *HumanQuery) IDsX(ctx context.Context) []uuid.UUID
- func (hq *HumanQuery) Limit(limit int) *HumanQuery
- func (hq *HumanQuery) Offset(offset int) *HumanQuery
- func (hq *HumanQuery) Only(ctx context.Context) (*Human, error)
- func (hq *HumanQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)
- func (hq *HumanQuery) OnlyIDX(ctx context.Context) uuid.UUID
- func (hq *HumanQuery) OnlyX(ctx context.Context) *Human
- func (hq *HumanQuery) Order(o ...human.OrderOption) *HumanQuery
- func (hq *HumanQuery) Select(fields ...string) *HumanSelect
- func (hq *HumanQuery) Unique(unique bool) *HumanQuery
- func (hq *HumanQuery) Where(ps ...predicate.Human) *HumanQuery
- type HumanSelect
- func (hs *HumanSelect) Aggregate(fns ...AggregateFunc) *HumanSelect
- func (s *HumanSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *HumanSelect) BoolX(ctx context.Context) bool
- func (s *HumanSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *HumanSelect) BoolsX(ctx context.Context) []bool
- func (s *HumanSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *HumanSelect) Float64X(ctx context.Context) float64
- func (s *HumanSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *HumanSelect) Float64sX(ctx context.Context) []float64
- func (s *HumanSelect) Int(ctx context.Context) (_ int, err error)
- func (s *HumanSelect) IntX(ctx context.Context) int
- func (s *HumanSelect) Ints(ctx context.Context) ([]int, error)
- func (s *HumanSelect) IntsX(ctx context.Context) []int
- func (hs *HumanSelect) Scan(ctx context.Context, v any) error
- func (s *HumanSelect) ScanX(ctx context.Context, v any)
- func (s *HumanSelect) String(ctx context.Context) (_ string, err error)
- func (s *HumanSelect) StringX(ctx context.Context) string
- func (s *HumanSelect) Strings(ctx context.Context) ([]string, error)
- func (s *HumanSelect) StringsX(ctx context.Context) []string
- type HumanUpdate
- func (hu *HumanUpdate) Exec(ctx context.Context) error
- func (hu *HumanUpdate) ExecX(ctx context.Context)
- func (hu *HumanUpdate) Mutation() *HumanMutation
- func (hu *HumanUpdate) Save(ctx context.Context) (int, error)
- func (hu *HumanUpdate) SaveX(ctx context.Context) int
- func (hu *HumanUpdate) SetName(s string) *HumanUpdate
- func (hu *HumanUpdate) SetNillableName(s *string) *HumanUpdate
- func (hu *HumanUpdate) Where(ps ...predicate.Human) *HumanUpdate
- type HumanUpdateOne
- func (huo *HumanUpdateOne) Exec(ctx context.Context) error
- func (huo *HumanUpdateOne) ExecX(ctx context.Context)
- func (huo *HumanUpdateOne) Mutation() *HumanMutation
- func (huo *HumanUpdateOne) Save(ctx context.Context) (*Human, error)
- func (huo *HumanUpdateOne) SaveX(ctx context.Context) *Human
- func (huo *HumanUpdateOne) Select(field string, fields ...string) *HumanUpdateOne
- func (huo *HumanUpdateOne) SetName(s string) *HumanUpdateOne
- func (huo *HumanUpdateOne) SetNillableName(s *string) *HumanUpdateOne
- func (huo *HumanUpdateOne) Where(ps ...predicate.Human) *HumanUpdateOne
- type Humen
- type InterceptFunc
- type Interceptor
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- type Policy
- type Querier
- type QuerierFunc
- type Query
- type QueryContext
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- type TraverseFunc
- type Traverser
- type Tx
- type ValidationError
- type Value
Constants ¶
const ( // Operation types. OpCreate = ent.OpCreate OpDelete = ent.OpDelete OpDeleteOne = ent.OpDeleteOne OpUpdate = ent.OpUpdate OpUpdateOne = ent.OpUpdateOne // Node types. TypeHuman = "Human" )
Variables ¶
var ErrTxStarted = errors.New("gen: cannot start a transaction within a transaction")
ErrTxStarted is returned when trying to start a new transaction from a transactional client.
Functions ¶
func IsConstraintError ¶
IsConstraintError returns a boolean indicating whether the error is a constraint failure.
func IsNotFound ¶
IsNotFound returns a boolean indicating whether the error is a not found error.
func IsNotLoaded ¶
IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
func IsNotSingular ¶
IsNotSingular returns a boolean indicating whether the error is a not singular error.
func IsValidationError ¶
IsValidationError returns a boolean indicating whether the error is a validation error.
func NewContext ¶
NewContext returns a new context with the given Client attached.
Types ¶
type AggregateFunc ¶
AggregateFunc applies an aggregation step on the group-by traversal/selector.
func As ¶
func As(fn AggregateFunc, end string) AggregateFunc
As is a pseudo aggregation function for renaming another other functions with custom names. For example:
GroupBy(field1, field2). Aggregate(gen.As(gen.Sum(field1), "sum_field1"), (gen.As(gen.Sum(field2), "sum_field2")). Scan(ctx, &v)
func Count ¶
func Count() AggregateFunc
Count applies the "count" aggregation function on each group.
func Max ¶
func Max(field string) AggregateFunc
Max applies the "max" aggregation function on the given field of each group.
func Mean ¶
func Mean(field string) AggregateFunc
Mean applies the "mean" aggregation function on the given field of each group.
func Min ¶
func Min(field string) AggregateFunc
Min applies the "min" aggregation function on the given field of each group.
func Sum ¶
func Sum(field string) AggregateFunc
Sum applies the "sum" aggregation function on the given field of each group.
type Client ¶
type Client struct { // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema // Human is the client for interacting with the Human builders. Human *HumanClient // contains filtered or unexported fields }
Client is the client that holds all ent builders.
func FromContext ¶
FromContext returns a Client stored inside a context, or nil if there isn't one.
func Open ¶
Open opens a database/sql.DB specified by the driver name and the data source name, and returns a new client attached to it. Optional parameters can be added for configuring the client.
func (*Client) Debug ¶
Debug returns a new debug-client. It's used to get verbose logging on specific operations.
client.Debug(). Human. Query(). Count(ctx)
func (*Client) Intercept ¶
func (c *Client) Intercept(interceptors ...Interceptor)
Intercept adds the query interceptors to all the entity clients. In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
type CommitFunc ¶
The CommitFunc type is an adapter to allow the use of ordinary function as a Committer. If f is a function with the appropriate signature, CommitFunc(f) is a Committer that calls f.
type CommitHook ¶
CommitHook defines the "commit middleware". A function that gets a Committer and returns a Committer. For example:
hook := func(next ent.Committer) ent.Committer { return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { // Do some stuff before. if err := next.Commit(ctx, tx); err != nil { return err } // Do some stuff after. return nil }) }
type ConstraintError ¶
type ConstraintError struct {
// contains filtered or unexported fields
}
ConstraintError returns when trying to create/update one or more entities and one or more of their constraints failed. For example, violation of edge or field uniqueness.
func (ConstraintError) Error ¶
func (e ConstraintError) Error() string
Error implements the error interface.
func (*ConstraintError) Unwrap ¶
func (e *ConstraintError) Unwrap() error
Unwrap implements the errors.Wrapper interface.
type Human ¶
type Human struct { // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // contains filtered or unexported fields }
Human is the model entity for the Human schema.
func (*Human) Unwrap ¶
Unwrap unwraps the Human entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.
func (*Human) Update ¶
func (h *Human) Update() *HumanUpdateOne
Update returns a builder for updating this Human. Note that you need to call Human.Unwrap() before calling this method if this Human was returned from a transaction, and the transaction was committed or rolled back.
type HumanClient ¶
type HumanClient struct {
// contains filtered or unexported fields
}
HumanClient is a client for the Human schema.
func NewHumanClient ¶
func NewHumanClient(c config) *HumanClient
NewHumanClient returns a client for the Human from the given config.
func (*HumanClient) Create ¶
func (c *HumanClient) Create() *HumanCreate
Create returns a builder for creating a Human entity.
func (*HumanClient) CreateBulk ¶
func (c *HumanClient) CreateBulk(builders ...*HumanCreate) *HumanCreateBulk
CreateBulk returns a builder for creating a bulk of Human entities.
func (*HumanClient) Delete ¶
func (c *HumanClient) Delete() *HumanDelete
Delete returns a delete builder for Human.
func (*HumanClient) DeleteOne ¶
func (c *HumanClient) DeleteOne(h *Human) *HumanDeleteOne
DeleteOne returns a builder for deleting the given entity.
func (*HumanClient) DeleteOneID ¶
func (c *HumanClient) DeleteOneID(id uuid.UUID) *HumanDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
func (*HumanClient) Intercept ¶
func (c *HumanClient) Intercept(interceptors ...Interceptor)
Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `human.Intercept(f(g(h())))`.
func (*HumanClient) Interceptors ¶
func (c *HumanClient) Interceptors() []Interceptor
Interceptors returns the client interceptors.
func (*HumanClient) MapCreateBulk ¶
func (c *HumanClient) MapCreateBulk(slice any, setFunc func(*HumanCreate, int)) *HumanCreateBulk
MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.
func (*HumanClient) Query ¶
func (c *HumanClient) Query() *HumanQuery
Query returns a query builder for Human.
func (*HumanClient) Update ¶
func (c *HumanClient) Update() *HumanUpdate
Update returns an update builder for Human.
func (*HumanClient) UpdateOne ¶
func (c *HumanClient) UpdateOne(h *Human) *HumanUpdateOne
UpdateOne returns an update builder for the given entity.
func (*HumanClient) UpdateOneID ¶
func (c *HumanClient) UpdateOneID(id uuid.UUID) *HumanUpdateOne
UpdateOneID returns an update builder for the given id.
func (*HumanClient) Use ¶
func (c *HumanClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `human.Hooks(f(g(h())))`.
type HumanCreate ¶
type HumanCreate struct {
// contains filtered or unexported fields
}
HumanCreate is the builder for creating a Human entity.
func (*HumanCreate) Exec ¶
func (hc *HumanCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*HumanCreate) ExecX ¶
func (hc *HumanCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*HumanCreate) Mutation ¶
func (hc *HumanCreate) Mutation() *HumanMutation
Mutation returns the HumanMutation object of the builder.
func (*HumanCreate) Save ¶
func (hc *HumanCreate) Save(ctx context.Context) (*Human, error)
Save creates the Human in the database.
func (*HumanCreate) SaveX ¶
func (hc *HumanCreate) SaveX(ctx context.Context) *Human
SaveX calls Save and panics if Save returns an error.
func (*HumanCreate) SetID ¶
func (hc *HumanCreate) SetID(u uuid.UUID) *HumanCreate
SetID sets the "id" field.
func (*HumanCreate) SetName ¶
func (hc *HumanCreate) SetName(s string) *HumanCreate
SetName sets the "name" field.
type HumanCreateBulk ¶
type HumanCreateBulk struct {
// contains filtered or unexported fields
}
HumanCreateBulk is the builder for creating many Human entities in bulk.
func (*HumanCreateBulk) Exec ¶
func (hcb *HumanCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*HumanCreateBulk) ExecX ¶
func (hcb *HumanCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type HumanDelete ¶
type HumanDelete struct {
// contains filtered or unexported fields
}
HumanDelete is the builder for deleting a Human entity.
func (*HumanDelete) Exec ¶
func (hd *HumanDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*HumanDelete) ExecX ¶
func (hd *HumanDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*HumanDelete) Where ¶
func (hd *HumanDelete) Where(ps ...predicate.Human) *HumanDelete
Where appends a list predicates to the HumanDelete builder.
type HumanDeleteOne ¶
type HumanDeleteOne struct {
// contains filtered or unexported fields
}
HumanDeleteOne is the builder for deleting a single Human entity.
func (*HumanDeleteOne) Exec ¶
func (hdo *HumanDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*HumanDeleteOne) ExecX ¶
func (hdo *HumanDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*HumanDeleteOne) Where ¶
func (hdo *HumanDeleteOne) Where(ps ...predicate.Human) *HumanDeleteOne
Where appends a list predicates to the HumanDelete builder.
type HumanGroupBy ¶
type HumanGroupBy struct {
// contains filtered or unexported fields
}
HumanGroupBy is the group-by builder for Human entities.
func (*HumanGroupBy) Aggregate ¶
func (hgb *HumanGroupBy) Aggregate(fns ...AggregateFunc) *HumanGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*HumanGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*HumanGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*HumanGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*HumanGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*HumanGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*HumanGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*HumanGroupBy) Scan ¶
func (hgb *HumanGroupBy) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*HumanGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type HumanMutation ¶
type HumanMutation struct {
// contains filtered or unexported fields
}
HumanMutation represents an operation that mutates the Human nodes in the graph.
func (*HumanMutation) AddField ¶
func (m *HumanMutation) AddField(name string, value ent.Value) error
AddField adds the value to the field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.
func (*HumanMutation) AddedEdges ¶
func (m *HumanMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*HumanMutation) AddedField ¶
func (m *HumanMutation) AddedField(name string) (ent.Value, bool)
AddedField returns the numeric value that was incremented/decremented on a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.
func (*HumanMutation) AddedFields ¶
func (m *HumanMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*HumanMutation) AddedIDs ¶
func (m *HumanMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*HumanMutation) ClearEdge ¶
func (m *HumanMutation) ClearEdge(name string) error
ClearEdge clears the value of the edge with the given name. It returns an error if that edge is not defined in the schema.
func (*HumanMutation) ClearField ¶
func (m *HumanMutation) ClearField(name string) error
ClearField clears the value of the field with the given name. It returns an error if the field is not defined in the schema.
func (*HumanMutation) ClearedEdges ¶
func (m *HumanMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*HumanMutation) ClearedFields ¶
func (m *HumanMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (HumanMutation) Client ¶
func (m HumanMutation) Client() *Client
Client returns a new `ent.Client` from the mutation. If the mutation was executed in a transaction (ent.Tx), a transactional client is returned.
func (*HumanMutation) EdgeCleared ¶
func (m *HumanMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*HumanMutation) Field ¶
func (m *HumanMutation) Field(name string) (ent.Value, bool)
Field returns the value of a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.
func (*HumanMutation) FieldCleared ¶
func (m *HumanMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*HumanMutation) Fields ¶
func (m *HumanMutation) Fields() []string
Fields returns all fields that were changed during this mutation. Note that in order to get all numeric fields that were incremented/decremented, call AddedFields().
func (*HumanMutation) ID ¶
func (m *HumanMutation) ID() (id uuid.UUID, exists bool)
ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.
func (*HumanMutation) IDs ¶
IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.
func (*HumanMutation) Name ¶
func (m *HumanMutation) Name() (r string, exists bool)
Name returns the value of the "name" field in the mutation.
func (*HumanMutation) OldField ¶
OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database failed.
func (*HumanMutation) OldName ¶
func (m *HumanMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old "name" field's value of the Human entity. If the Human object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (*HumanMutation) RemovedEdges ¶
func (m *HumanMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*HumanMutation) RemovedIDs ¶
func (m *HumanMutation) RemovedIDs(name string) []ent.Value
RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.
func (*HumanMutation) ResetEdge ¶
func (m *HumanMutation) ResetEdge(name string) error
ResetEdge resets all changes to the edge with the given name in this mutation. It returns an error if the edge is not defined in the schema.
func (*HumanMutation) ResetField ¶
func (m *HumanMutation) ResetField(name string) error
ResetField resets all changes in the mutation for the field with the given name. It returns an error if the field is not defined in the schema.
func (*HumanMutation) ResetName ¶
func (m *HumanMutation) ResetName()
ResetName resets all changes to the "name" field.
func (*HumanMutation) SetField ¶
func (m *HumanMutation) SetField(name string, value ent.Value) error
SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.
func (*HumanMutation) SetID ¶
func (m *HumanMutation) SetID(id uuid.UUID)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Human entities.
func (*HumanMutation) SetName ¶
func (m *HumanMutation) SetName(s string)
SetName sets the "name" field.
func (*HumanMutation) SetOp ¶
func (m *HumanMutation) SetOp(op Op)
SetOp allows setting the mutation operation.
func (HumanMutation) Tx ¶
func (m HumanMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*HumanMutation) Type ¶
func (m *HumanMutation) Type() string
Type returns the node type of this mutation (Human).
func (*HumanMutation) Where ¶
func (m *HumanMutation) Where(ps ...predicate.Human)
Where appends a list predicates to the HumanMutation builder.
func (*HumanMutation) WhereP ¶
func (m *HumanMutation) WhereP(ps ...func(*sql.Selector))
WhereP appends storage-level predicates to the HumanMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.
type HumanQuery ¶
type HumanQuery struct {
// contains filtered or unexported fields
}
HumanQuery is the builder for querying Human entities.
func (*HumanQuery) Aggregate ¶
func (hq *HumanQuery) Aggregate(fns ...AggregateFunc) *HumanSelect
Aggregate returns a HumanSelect configured with the given aggregations.
func (*HumanQuery) All ¶
func (hq *HumanQuery) All(ctx context.Context) ([]*Human, error)
All executes the query and returns a list of Humen.
func (*HumanQuery) AllX ¶
func (hq *HumanQuery) AllX(ctx context.Context) []*Human
AllX is like All, but panics if an error occurs.
func (*HumanQuery) Clone ¶
func (hq *HumanQuery) Clone() *HumanQuery
Clone returns a duplicate of the HumanQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*HumanQuery) Count ¶
func (hq *HumanQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*HumanQuery) CountX ¶
func (hq *HumanQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*HumanQuery) Exist ¶
func (hq *HumanQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*HumanQuery) ExistX ¶
func (hq *HumanQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*HumanQuery) First ¶
func (hq *HumanQuery) First(ctx context.Context) (*Human, error)
First returns the first Human entity from the query. Returns a *NotFoundError when no Human was found.
func (*HumanQuery) FirstID ¶
FirstID returns the first Human ID from the query. Returns a *NotFoundError when no Human ID was found.
func (*HumanQuery) FirstIDX ¶
func (hq *HumanQuery) FirstIDX(ctx context.Context) uuid.UUID
FirstIDX is like FirstID, but panics if an error occurs.
func (*HumanQuery) FirstX ¶
func (hq *HumanQuery) FirstX(ctx context.Context) *Human
FirstX is like First, but panics if an error occurs.
func (*HumanQuery) GroupBy ¶
func (hq *HumanQuery) GroupBy(field string, fields ...string) *HumanGroupBy
GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.
Example:
var v []struct { Name string `json:"name,omitempty"` Count int `json:"count,omitempty"` } client.Human.Query(). GroupBy(human.FieldName). Aggregate(gen.Count()). Scan(ctx, &v)
func (*HumanQuery) IDsX ¶
func (hq *HumanQuery) IDsX(ctx context.Context) []uuid.UUID
IDsX is like IDs, but panics if an error occurs.
func (*HumanQuery) Limit ¶
func (hq *HumanQuery) Limit(limit int) *HumanQuery
Limit the number of records to be returned by this query.
func (*HumanQuery) Offset ¶
func (hq *HumanQuery) Offset(offset int) *HumanQuery
Offset to start from.
func (*HumanQuery) Only ¶
func (hq *HumanQuery) Only(ctx context.Context) (*Human, error)
Only returns a single Human entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Human entity is found. Returns a *NotFoundError when no Human entities are found.
func (*HumanQuery) OnlyID ¶
OnlyID is like Only, but returns the only Human ID in the query. Returns a *NotSingularError when more than one Human ID is found. Returns a *NotFoundError when no entities are found.
func (*HumanQuery) OnlyIDX ¶
func (hq *HumanQuery) OnlyIDX(ctx context.Context) uuid.UUID
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*HumanQuery) OnlyX ¶
func (hq *HumanQuery) OnlyX(ctx context.Context) *Human
OnlyX is like Only, but panics if an error occurs.
func (*HumanQuery) Order ¶
func (hq *HumanQuery) Order(o ...human.OrderOption) *HumanQuery
Order specifies how the records should be ordered.
func (*HumanQuery) Select ¶
func (hq *HumanQuery) Select(fields ...string) *HumanSelect
Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.
Example:
var v []struct { Name string `json:"name,omitempty"` } client.Human.Query(). Select(human.FieldName). Scan(ctx, &v)
func (*HumanQuery) Unique ¶
func (hq *HumanQuery) Unique(unique bool) *HumanQuery
Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.
func (*HumanQuery) Where ¶
func (hq *HumanQuery) Where(ps ...predicate.Human) *HumanQuery
Where adds a new predicate for the HumanQuery builder.
type HumanSelect ¶
type HumanSelect struct { *HumanQuery // contains filtered or unexported fields }
HumanSelect is the builder for selecting fields of Human entities.
func (*HumanSelect) Aggregate ¶
func (hs *HumanSelect) Aggregate(fns ...AggregateFunc) *HumanSelect
Aggregate adds the given aggregation functions to the selector query.
func (*HumanSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*HumanSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*HumanSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*HumanSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*HumanSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*HumanSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*HumanSelect) Scan ¶
func (hs *HumanSelect) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*HumanSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type HumanUpdate ¶
type HumanUpdate struct {
// contains filtered or unexported fields
}
HumanUpdate is the builder for updating Human entities.
func (*HumanUpdate) Exec ¶
func (hu *HumanUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*HumanUpdate) ExecX ¶
func (hu *HumanUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*HumanUpdate) Mutation ¶
func (hu *HumanUpdate) Mutation() *HumanMutation
Mutation returns the HumanMutation object of the builder.
func (*HumanUpdate) Save ¶
func (hu *HumanUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*HumanUpdate) SaveX ¶
func (hu *HumanUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*HumanUpdate) SetName ¶
func (hu *HumanUpdate) SetName(s string) *HumanUpdate
SetName sets the "name" field.
func (*HumanUpdate) SetNillableName ¶
func (hu *HumanUpdate) SetNillableName(s *string) *HumanUpdate
SetNillableName sets the "name" field if the given value is not nil.
func (*HumanUpdate) Where ¶
func (hu *HumanUpdate) Where(ps ...predicate.Human) *HumanUpdate
Where appends a list predicates to the HumanUpdate builder.
type HumanUpdateOne ¶
type HumanUpdateOne struct {
// contains filtered or unexported fields
}
HumanUpdateOne is the builder for updating a single Human entity.
func (*HumanUpdateOne) Exec ¶
func (huo *HumanUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*HumanUpdateOne) ExecX ¶
func (huo *HumanUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*HumanUpdateOne) Mutation ¶
func (huo *HumanUpdateOne) Mutation() *HumanMutation
Mutation returns the HumanMutation object of the builder.
func (*HumanUpdateOne) Save ¶
func (huo *HumanUpdateOne) Save(ctx context.Context) (*Human, error)
Save executes the query and returns the updated Human entity.
func (*HumanUpdateOne) SaveX ¶
func (huo *HumanUpdateOne) SaveX(ctx context.Context) *Human
SaveX is like Save, but panics if an error occurs.
func (*HumanUpdateOne) Select ¶
func (huo *HumanUpdateOne) Select(field string, fields ...string) *HumanUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*HumanUpdateOne) SetName ¶
func (huo *HumanUpdateOne) SetName(s string) *HumanUpdateOne
SetName sets the "name" field.
func (*HumanUpdateOne) SetNillableName ¶
func (huo *HumanUpdateOne) SetNillableName(s *string) *HumanUpdateOne
SetNillableName sets the "name" field if the given value is not nil.
func (*HumanUpdateOne) Where ¶
func (huo *HumanUpdateOne) Where(ps ...predicate.Human) *HumanUpdateOne
Where appends a list predicates to the HumanUpdate builder.
type InterceptFunc ¶
type InterceptFunc = ent.InterceptFunc
ent aliases to avoid import conflicts in user's code.
type Interceptor ¶
type Interceptor = ent.Interceptor
ent aliases to avoid import conflicts in user's code.
type MutateFunc ¶
type MutateFunc = ent.MutateFunc
ent aliases to avoid import conflicts in user's code.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
Error implements the error interface.
type NotLoadedError ¶
type NotLoadedError struct {
// contains filtered or unexported fields
}
NotLoadedError returns when trying to get a node that was not loaded by the query.
func (*NotLoadedError) Error ¶
func (e *NotLoadedError) Error() string
Error implements the error interface.
type NotSingularError ¶
type NotSingularError struct {
// contains filtered or unexported fields
}
NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
func (*NotSingularError) Error ¶
func (e *NotSingularError) Error() string
Error implements the error interface.
type OrderFunc ¶
OrderFunc applies an ordering on the sql selector. Deprecated: Use Asc/Desc functions or the package builders instead.
type QuerierFunc ¶
type QuerierFunc = ent.QuerierFunc
ent aliases to avoid import conflicts in user's code.
type QueryContext ¶
type QueryContext = ent.QueryContext
ent aliases to avoid import conflicts in user's code.
type RollbackFunc ¶
The RollbackFunc type is an adapter to allow the use of ordinary function as a Rollbacker. If f is a function with the appropriate signature, RollbackFunc(f) is a Rollbacker that calls f.
type RollbackHook ¶
type RollbackHook func(Rollbacker) Rollbacker
RollbackHook defines the "rollback middleware". A function that gets a Rollbacker and returns a Rollbacker. For example:
hook := func(next ent.Rollbacker) ent.Rollbacker { return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { // Do some stuff before. if err := next.Rollback(ctx, tx); err != nil { return err } // Do some stuff after. return nil }) }
type Rollbacker ¶
Rollbacker is the interface that wraps the Rollback method.
type TraverseFunc ¶
type TraverseFunc = ent.TraverseFunc
ent aliases to avoid import conflicts in user's code.
type Tx ¶
type Tx struct { // Human is the client for interacting with the Human builders. Human *HumanClient // contains filtered or unexported fields }
Tx is a transactional client that is created by calling Client.Tx().
func TxFromContext ¶
TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
func (*Tx) OnRollback ¶
func (tx *Tx) OnRollback(f RollbackHook)
OnRollback adds a hook to call on rollback.
type ValidationError ¶
type ValidationError struct { Name string // Field or edge name. // contains filtered or unexported fields }
ValidationError returns when validating a field or edge fails.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap implements the errors.Wrapper interface.