Documentation ¶
Index ¶
- Constants
- 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
- type CommitFunc
- type CommitHook
- type Committer
- type ConstraintError
- type Customer
- type CustomerClient
- func (c *CustomerClient) Create() *CustomerCreate
- func (c *CustomerClient) CreateBulk(builders ...*CustomerCreate) *CustomerCreateBulk
- func (c *CustomerClient) Delete() *CustomerDelete
- func (c *CustomerClient) DeleteOne(cu *Customer) *CustomerDeleteOne
- func (c *CustomerClient) DeleteOneID(id int) *CustomerDeleteOne
- func (c *CustomerClient) Get(ctx context.Context, id int) (*Customer, error)
- func (c *CustomerClient) GetX(ctx context.Context, id int) *Customer
- func (c *CustomerClient) Hooks() []Hook
- func (c *CustomerClient) Query() *CustomerQuery
- func (c *CustomerClient) Update() *CustomerUpdate
- func (c *CustomerClient) UpdateOne(cu *Customer) *CustomerUpdateOne
- func (c *CustomerClient) UpdateOneID(id int) *CustomerUpdateOne
- func (c *CustomerClient) Use(hooks ...Hook)
- type CustomerCreate
- func (cc *CustomerCreate) Exec(ctx context.Context) error
- func (cc *CustomerCreate) ExecX(ctx context.Context)
- func (cc *CustomerCreate) Mutation() *CustomerMutation
- func (cc *CustomerCreate) Save(ctx context.Context) (*Customer, error)
- func (cc *CustomerCreate) SaveX(ctx context.Context) *Customer
- func (cc *CustomerCreate) SetAddr(s string) *CustomerCreate
- func (cc *CustomerCreate) SetAge(i int32) *CustomerCreate
- func (cc *CustomerCreate) SetCreatedAt(t time.Time) *CustomerCreate
- func (cc *CustomerCreate) SetID(i int) *CustomerCreate
- func (cc *CustomerCreate) SetName(s string) *CustomerCreate
- func (cc *CustomerCreate) SetUpdatedAt(t time.Time) *CustomerCreate
- type CustomerCreateBulk
- type CustomerDelete
- type CustomerDeleteOne
- type CustomerGroupBy
- func (cgb *CustomerGroupBy) Aggregate(fns ...AggregateFunc) *CustomerGroupBy
- func (s *CustomerGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *CustomerGroupBy) BoolX(ctx context.Context) bool
- func (s *CustomerGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *CustomerGroupBy) BoolsX(ctx context.Context) []bool
- func (s *CustomerGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *CustomerGroupBy) Float64X(ctx context.Context) float64
- func (s *CustomerGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *CustomerGroupBy) Float64sX(ctx context.Context) []float64
- func (s *CustomerGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *CustomerGroupBy) IntX(ctx context.Context) int
- func (s *CustomerGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *CustomerGroupBy) IntsX(ctx context.Context) []int
- func (cgb *CustomerGroupBy) Scan(ctx context.Context, v interface{}) error
- func (s *CustomerGroupBy) ScanX(ctx context.Context, v interface{})
- func (s *CustomerGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *CustomerGroupBy) StringX(ctx context.Context) string
- func (s *CustomerGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *CustomerGroupBy) StringsX(ctx context.Context) []string
- type CustomerMutation
- func (m *CustomerMutation) AddAge(i int32)
- func (m *CustomerMutation) AddField(name string, value ent.Value) error
- func (m *CustomerMutation) AddedAge() (r int32, exists bool)
- func (m *CustomerMutation) AddedEdges() []string
- func (m *CustomerMutation) AddedField(name string) (ent.Value, bool)
- func (m *CustomerMutation) AddedFields() []string
- func (m *CustomerMutation) AddedIDs(name string) []ent.Value
- func (m *CustomerMutation) Addr() (r string, exists bool)
- func (m *CustomerMutation) Age() (r int32, exists bool)
- func (m *CustomerMutation) ClearEdge(name string) error
- func (m *CustomerMutation) ClearField(name string) error
- func (m *CustomerMutation) ClearedEdges() []string
- func (m *CustomerMutation) ClearedFields() []string
- func (m CustomerMutation) Client() *Client
- func (m *CustomerMutation) CreatedAt() (r time.Time, exists bool)
- func (m *CustomerMutation) EdgeCleared(name string) bool
- func (m *CustomerMutation) Field(name string) (ent.Value, bool)
- func (m *CustomerMutation) FieldCleared(name string) bool
- func (m *CustomerMutation) Fields() []string
- func (m *CustomerMutation) ID() (id int, exists bool)
- func (m *CustomerMutation) IDs(ctx context.Context) ([]int, error)
- func (m *CustomerMutation) Name() (r string, exists bool)
- func (m *CustomerMutation) OldAddr(ctx context.Context) (v string, err error)
- func (m *CustomerMutation) OldAge(ctx context.Context) (v int32, err error)
- func (m *CustomerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)
- func (m *CustomerMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *CustomerMutation) OldName(ctx context.Context) (v string, err error)
- func (m *CustomerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)
- func (m *CustomerMutation) Op() Op
- func (m *CustomerMutation) RemovedEdges() []string
- func (m *CustomerMutation) RemovedIDs(name string) []ent.Value
- func (m *CustomerMutation) ResetAddr()
- func (m *CustomerMutation) ResetAge()
- func (m *CustomerMutation) ResetCreatedAt()
- func (m *CustomerMutation) ResetEdge(name string) error
- func (m *CustomerMutation) ResetField(name string) error
- func (m *CustomerMutation) ResetName()
- func (m *CustomerMutation) ResetUpdatedAt()
- func (m *CustomerMutation) SetAddr(s string)
- func (m *CustomerMutation) SetAge(i int32)
- func (m *CustomerMutation) SetCreatedAt(t time.Time)
- func (m *CustomerMutation) SetField(name string, value ent.Value) error
- func (m *CustomerMutation) SetID(id int)
- func (m *CustomerMutation) SetName(s string)
- func (m *CustomerMutation) SetUpdatedAt(t time.Time)
- func (m CustomerMutation) Tx() (*Tx, error)
- func (m *CustomerMutation) Type() string
- func (m *CustomerMutation) UpdatedAt() (r time.Time, exists bool)
- func (m *CustomerMutation) Where(ps ...predicate.Customer)
- type CustomerQuery
- func (cq *CustomerQuery) All(ctx context.Context) ([]*Customer, error)
- func (cq *CustomerQuery) AllX(ctx context.Context) []*Customer
- func (cq *CustomerQuery) Clone() *CustomerQuery
- func (cq *CustomerQuery) Count(ctx context.Context) (int, error)
- func (cq *CustomerQuery) CountX(ctx context.Context) int
- func (cq *CustomerQuery) Exist(ctx context.Context) (bool, error)
- func (cq *CustomerQuery) ExistX(ctx context.Context) bool
- func (cq *CustomerQuery) First(ctx context.Context) (*Customer, error)
- func (cq *CustomerQuery) FirstID(ctx context.Context) (id int, err error)
- func (cq *CustomerQuery) FirstIDX(ctx context.Context) int
- func (cq *CustomerQuery) FirstX(ctx context.Context) *Customer
- func (cq *CustomerQuery) GroupBy(field string, fields ...string) *CustomerGroupBy
- func (cq *CustomerQuery) IDs(ctx context.Context) ([]int, error)
- func (cq *CustomerQuery) IDsX(ctx context.Context) []int
- func (cq *CustomerQuery) Limit(limit int) *CustomerQuery
- func (cq *CustomerQuery) Offset(offset int) *CustomerQuery
- func (cq *CustomerQuery) Only(ctx context.Context) (*Customer, error)
- func (cq *CustomerQuery) OnlyID(ctx context.Context) (id int, err error)
- func (cq *CustomerQuery) OnlyIDX(ctx context.Context) int
- func (cq *CustomerQuery) OnlyX(ctx context.Context) *Customer
- func (cq *CustomerQuery) Order(o ...OrderFunc) *CustomerQuery
- func (cq *CustomerQuery) Select(fields ...string) *CustomerSelect
- func (cq *CustomerQuery) Unique(unique bool) *CustomerQuery
- func (cq *CustomerQuery) Where(ps ...predicate.Customer) *CustomerQuery
- type CustomerSelect
- func (s *CustomerSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *CustomerSelect) BoolX(ctx context.Context) bool
- func (s *CustomerSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *CustomerSelect) BoolsX(ctx context.Context) []bool
- func (s *CustomerSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *CustomerSelect) Float64X(ctx context.Context) float64
- func (s *CustomerSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *CustomerSelect) Float64sX(ctx context.Context) []float64
- func (s *CustomerSelect) Int(ctx context.Context) (_ int, err error)
- func (s *CustomerSelect) IntX(ctx context.Context) int
- func (s *CustomerSelect) Ints(ctx context.Context) ([]int, error)
- func (s *CustomerSelect) IntsX(ctx context.Context) []int
- func (cs *CustomerSelect) Scan(ctx context.Context, v interface{}) error
- func (s *CustomerSelect) ScanX(ctx context.Context, v interface{})
- func (s *CustomerSelect) String(ctx context.Context) (_ string, err error)
- func (s *CustomerSelect) StringX(ctx context.Context) string
- func (s *CustomerSelect) Strings(ctx context.Context) ([]string, error)
- func (s *CustomerSelect) StringsX(ctx context.Context) []string
- type CustomerUpdate
- func (cu *CustomerUpdate) AddAge(i int32) *CustomerUpdate
- func (cu *CustomerUpdate) Exec(ctx context.Context) error
- func (cu *CustomerUpdate) ExecX(ctx context.Context)
- func (cu *CustomerUpdate) Mutation() *CustomerMutation
- func (cu *CustomerUpdate) Save(ctx context.Context) (int, error)
- func (cu *CustomerUpdate) SaveX(ctx context.Context) int
- func (cu *CustomerUpdate) SetAddr(s string) *CustomerUpdate
- func (cu *CustomerUpdate) SetAge(i int32) *CustomerUpdate
- func (cu *CustomerUpdate) SetCreatedAt(t time.Time) *CustomerUpdate
- func (cu *CustomerUpdate) SetName(s string) *CustomerUpdate
- func (cu *CustomerUpdate) SetUpdatedAt(t time.Time) *CustomerUpdate
- func (cu *CustomerUpdate) Where(ps ...predicate.Customer) *CustomerUpdate
- type CustomerUpdateOne
- func (cuo *CustomerUpdateOne) AddAge(i int32) *CustomerUpdateOne
- func (cuo *CustomerUpdateOne) Exec(ctx context.Context) error
- func (cuo *CustomerUpdateOne) ExecX(ctx context.Context)
- func (cuo *CustomerUpdateOne) Mutation() *CustomerMutation
- func (cuo *CustomerUpdateOne) Save(ctx context.Context) (*Customer, error)
- func (cuo *CustomerUpdateOne) SaveX(ctx context.Context) *Customer
- func (cuo *CustomerUpdateOne) Select(field string, fields ...string) *CustomerUpdateOne
- func (cuo *CustomerUpdateOne) SetAddr(s string) *CustomerUpdateOne
- func (cuo *CustomerUpdateOne) SetAge(i int32) *CustomerUpdateOne
- func (cuo *CustomerUpdateOne) SetCreatedAt(t time.Time) *CustomerUpdateOne
- func (cuo *CustomerUpdateOne) SetName(s string) *CustomerUpdateOne
- func (cuo *CustomerUpdateOne) SetUpdatedAt(t time.Time) *CustomerUpdateOne
- type Customers
- type Hook
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type Order
- type OrderClient
- func (c *OrderClient) Create() *OrderCreate
- func (c *OrderClient) CreateBulk(builders ...*OrderCreate) *OrderCreateBulk
- func (c *OrderClient) Delete() *OrderDelete
- func (c *OrderClient) DeleteOne(o *Order) *OrderDeleteOne
- func (c *OrderClient) DeleteOneID(id int) *OrderDeleteOne
- func (c *OrderClient) Get(ctx context.Context, id int) (*Order, error)
- func (c *OrderClient) GetX(ctx context.Context, id int) *Order
- func (c *OrderClient) Hooks() []Hook
- func (c *OrderClient) Query() *OrderQuery
- func (c *OrderClient) Update() *OrderUpdate
- func (c *OrderClient) UpdateOne(o *Order) *OrderUpdateOne
- func (c *OrderClient) UpdateOneID(id int) *OrderUpdateOne
- func (c *OrderClient) Use(hooks ...Hook)
- type OrderCreate
- func (oc *OrderCreate) Exec(ctx context.Context) error
- func (oc *OrderCreate) ExecX(ctx context.Context)
- func (oc *OrderCreate) Mutation() *OrderMutation
- func (oc *OrderCreate) Save(ctx context.Context) (*Order, error)
- func (oc *OrderCreate) SaveX(ctx context.Context) *Order
- func (oc *OrderCreate) SetAddr(s string) *OrderCreate
- func (oc *OrderCreate) SetCreatedAt(t time.Time) *OrderCreate
- func (oc *OrderCreate) SetCustomerID(i int) *OrderCreate
- func (oc *OrderCreate) SetID(i int) *OrderCreate
- func (oc *OrderCreate) SetPrice(f float64) *OrderCreate
- func (oc *OrderCreate) SetStatus(i int32) *OrderCreate
- func (oc *OrderCreate) SetUpdatedAt(t time.Time) *OrderCreate
- type OrderCreateBulk
- type OrderDelete
- type OrderDeleteOne
- type OrderFunc
- type OrderGroupBy
- func (ogb *OrderGroupBy) Aggregate(fns ...AggregateFunc) *OrderGroupBy
- func (s *OrderGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *OrderGroupBy) BoolX(ctx context.Context) bool
- func (s *OrderGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *OrderGroupBy) BoolsX(ctx context.Context) []bool
- func (s *OrderGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *OrderGroupBy) Float64X(ctx context.Context) float64
- func (s *OrderGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *OrderGroupBy) Float64sX(ctx context.Context) []float64
- func (s *OrderGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *OrderGroupBy) IntX(ctx context.Context) int
- func (s *OrderGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *OrderGroupBy) IntsX(ctx context.Context) []int
- func (ogb *OrderGroupBy) Scan(ctx context.Context, v interface{}) error
- func (s *OrderGroupBy) ScanX(ctx context.Context, v interface{})
- func (s *OrderGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *OrderGroupBy) StringX(ctx context.Context) string
- func (s *OrderGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *OrderGroupBy) StringsX(ctx context.Context) []string
- type OrderMutation
- func (m *OrderMutation) AddCustomerID(i int)
- func (m *OrderMutation) AddField(name string, value ent.Value) error
- func (m *OrderMutation) AddPrice(f float64)
- func (m *OrderMutation) AddStatus(i int32)
- func (m *OrderMutation) AddedCustomerID() (r int, exists bool)
- func (m *OrderMutation) AddedEdges() []string
- func (m *OrderMutation) AddedField(name string) (ent.Value, bool)
- func (m *OrderMutation) AddedFields() []string
- func (m *OrderMutation) AddedIDs(name string) []ent.Value
- func (m *OrderMutation) AddedPrice() (r float64, exists bool)
- func (m *OrderMutation) AddedStatus() (r int32, exists bool)
- func (m *OrderMutation) Addr() (r string, exists bool)
- func (m *OrderMutation) ClearEdge(name string) error
- func (m *OrderMutation) ClearField(name string) error
- func (m *OrderMutation) ClearedEdges() []string
- func (m *OrderMutation) ClearedFields() []string
- func (m OrderMutation) Client() *Client
- func (m *OrderMutation) CreatedAt() (r time.Time, exists bool)
- func (m *OrderMutation) CustomerID() (r int, exists bool)
- func (m *OrderMutation) EdgeCleared(name string) bool
- func (m *OrderMutation) Field(name string) (ent.Value, bool)
- func (m *OrderMutation) FieldCleared(name string) bool
- func (m *OrderMutation) Fields() []string
- func (m *OrderMutation) ID() (id int, exists bool)
- func (m *OrderMutation) IDs(ctx context.Context) ([]int, error)
- func (m *OrderMutation) OldAddr(ctx context.Context) (v string, err error)
- func (m *OrderMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)
- func (m *OrderMutation) OldCustomerID(ctx context.Context) (v int, err error)
- func (m *OrderMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *OrderMutation) OldPrice(ctx context.Context) (v float64, err error)
- func (m *OrderMutation) OldStatus(ctx context.Context) (v int32, err error)
- func (m *OrderMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)
- func (m *OrderMutation) Op() Op
- func (m *OrderMutation) Price() (r float64, exists bool)
- func (m *OrderMutation) RemovedEdges() []string
- func (m *OrderMutation) RemovedIDs(name string) []ent.Value
- func (m *OrderMutation) ResetAddr()
- func (m *OrderMutation) ResetCreatedAt()
- func (m *OrderMutation) ResetCustomerID()
- func (m *OrderMutation) ResetEdge(name string) error
- func (m *OrderMutation) ResetField(name string) error
- func (m *OrderMutation) ResetPrice()
- func (m *OrderMutation) ResetStatus()
- func (m *OrderMutation) ResetUpdatedAt()
- func (m *OrderMutation) SetAddr(s string)
- func (m *OrderMutation) SetCreatedAt(t time.Time)
- func (m *OrderMutation) SetCustomerID(i int)
- func (m *OrderMutation) SetField(name string, value ent.Value) error
- func (m *OrderMutation) SetID(id int)
- func (m *OrderMutation) SetPrice(f float64)
- func (m *OrderMutation) SetStatus(i int32)
- func (m *OrderMutation) SetUpdatedAt(t time.Time)
- func (m *OrderMutation) Status() (r int32, exists bool)
- func (m OrderMutation) Tx() (*Tx, error)
- func (m *OrderMutation) Type() string
- func (m *OrderMutation) UpdatedAt() (r time.Time, exists bool)
- func (m *OrderMutation) Where(ps ...predicate.Order)
- type OrderQuery
- func (oq *OrderQuery) All(ctx context.Context) ([]*Order, error)
- func (oq *OrderQuery) AllX(ctx context.Context) []*Order
- func (oq *OrderQuery) Clone() *OrderQuery
- func (oq *OrderQuery) Count(ctx context.Context) (int, error)
- func (oq *OrderQuery) CountX(ctx context.Context) int
- func (oq *OrderQuery) Exist(ctx context.Context) (bool, error)
- func (oq *OrderQuery) ExistX(ctx context.Context) bool
- func (oq *OrderQuery) First(ctx context.Context) (*Order, error)
- func (oq *OrderQuery) FirstID(ctx context.Context) (id int, err error)
- func (oq *OrderQuery) FirstIDX(ctx context.Context) int
- func (oq *OrderQuery) FirstX(ctx context.Context) *Order
- func (oq *OrderQuery) GroupBy(field string, fields ...string) *OrderGroupBy
- func (oq *OrderQuery) IDs(ctx context.Context) ([]int, error)
- func (oq *OrderQuery) IDsX(ctx context.Context) []int
- func (oq *OrderQuery) Limit(limit int) *OrderQuery
- func (oq *OrderQuery) Offset(offset int) *OrderQuery
- func (oq *OrderQuery) Only(ctx context.Context) (*Order, error)
- func (oq *OrderQuery) OnlyID(ctx context.Context) (id int, err error)
- func (oq *OrderQuery) OnlyIDX(ctx context.Context) int
- func (oq *OrderQuery) OnlyX(ctx context.Context) *Order
- func (oq *OrderQuery) Order(o ...OrderFunc) *OrderQuery
- func (oq *OrderQuery) Select(fields ...string) *OrderSelect
- func (oq *OrderQuery) Unique(unique bool) *OrderQuery
- func (oq *OrderQuery) Where(ps ...predicate.Order) *OrderQuery
- type OrderSelect
- func (s *OrderSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *OrderSelect) BoolX(ctx context.Context) bool
- func (s *OrderSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *OrderSelect) BoolsX(ctx context.Context) []bool
- func (s *OrderSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *OrderSelect) Float64X(ctx context.Context) float64
- func (s *OrderSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *OrderSelect) Float64sX(ctx context.Context) []float64
- func (s *OrderSelect) Int(ctx context.Context) (_ int, err error)
- func (s *OrderSelect) IntX(ctx context.Context) int
- func (s *OrderSelect) Ints(ctx context.Context) ([]int, error)
- func (s *OrderSelect) IntsX(ctx context.Context) []int
- func (os *OrderSelect) Scan(ctx context.Context, v interface{}) error
- func (s *OrderSelect) ScanX(ctx context.Context, v interface{})
- func (s *OrderSelect) String(ctx context.Context) (_ string, err error)
- func (s *OrderSelect) StringX(ctx context.Context) string
- func (s *OrderSelect) Strings(ctx context.Context) ([]string, error)
- func (s *OrderSelect) StringsX(ctx context.Context) []string
- type OrderUpdate
- func (ou *OrderUpdate) AddCustomerID(i int) *OrderUpdate
- func (ou *OrderUpdate) AddPrice(f float64) *OrderUpdate
- func (ou *OrderUpdate) AddStatus(i int32) *OrderUpdate
- func (ou *OrderUpdate) Exec(ctx context.Context) error
- func (ou *OrderUpdate) ExecX(ctx context.Context)
- func (ou *OrderUpdate) Mutation() *OrderMutation
- func (ou *OrderUpdate) Save(ctx context.Context) (int, error)
- func (ou *OrderUpdate) SaveX(ctx context.Context) int
- func (ou *OrderUpdate) SetAddr(s string) *OrderUpdate
- func (ou *OrderUpdate) SetCreatedAt(t time.Time) *OrderUpdate
- func (ou *OrderUpdate) SetCustomerID(i int) *OrderUpdate
- func (ou *OrderUpdate) SetPrice(f float64) *OrderUpdate
- func (ou *OrderUpdate) SetStatus(i int32) *OrderUpdate
- func (ou *OrderUpdate) SetUpdatedAt(t time.Time) *OrderUpdate
- func (ou *OrderUpdate) Where(ps ...predicate.Order) *OrderUpdate
- type OrderUpdateOne
- func (ouo *OrderUpdateOne) AddCustomerID(i int) *OrderUpdateOne
- func (ouo *OrderUpdateOne) AddPrice(f float64) *OrderUpdateOne
- func (ouo *OrderUpdateOne) AddStatus(i int32) *OrderUpdateOne
- func (ouo *OrderUpdateOne) Exec(ctx context.Context) error
- func (ouo *OrderUpdateOne) ExecX(ctx context.Context)
- func (ouo *OrderUpdateOne) Mutation() *OrderMutation
- func (ouo *OrderUpdateOne) Save(ctx context.Context) (*Order, error)
- func (ouo *OrderUpdateOne) SaveX(ctx context.Context) *Order
- func (ouo *OrderUpdateOne) Select(field string, fields ...string) *OrderUpdateOne
- func (ouo *OrderUpdateOne) SetAddr(s string) *OrderUpdateOne
- func (ouo *OrderUpdateOne) SetCreatedAt(t time.Time) *OrderUpdateOne
- func (ouo *OrderUpdateOne) SetCustomerID(i int) *OrderUpdateOne
- func (ouo *OrderUpdateOne) SetPrice(f float64) *OrderUpdateOne
- func (ouo *OrderUpdateOne) SetStatus(i int32) *OrderUpdateOne
- func (ouo *OrderUpdateOne) SetUpdatedAt(t time.Time) *OrderUpdateOne
- type Orders
- type Policy
- type Query
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- 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. TypeCustomer = "Customer" TypeOrder = "Order" )
Variables ¶
This section is empty.
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(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.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 // Customer is the client for interacting with the Customer builders. Customer *CustomerClient // Order is the client for interacting with the Order builders. Order *OrderClient // 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(). Customer. Query(). Count(ctx)
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 Customer ¶
type Customer struct { // ID of the ent. ID int `json:"id,omitempty"` // Addr holds the value of the "addr" field. Addr string `json:"addr,omitempty"` // Age holds the value of the "age" field. Age int32 `json:"age,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // contains filtered or unexported fields }
Customer is the model entity for the Customer schema.
func (*Customer) Unwrap ¶
Unwrap unwraps the Customer 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 (*Customer) Update ¶
func (c *Customer) Update() *CustomerUpdateOne
Update returns a builder for updating this Customer. Note that you need to call Customer.Unwrap() before calling this method if this Customer was returned from a transaction, and the transaction was committed or rolled back.
type CustomerClient ¶
type CustomerClient struct {
// contains filtered or unexported fields
}
CustomerClient is a client for the Customer schema.
func NewCustomerClient ¶
func NewCustomerClient(c config) *CustomerClient
NewCustomerClient returns a client for the Customer from the given config.
func (*CustomerClient) Create ¶
func (c *CustomerClient) Create() *CustomerCreate
Create returns a create builder for Customer.
func (*CustomerClient) CreateBulk ¶
func (c *CustomerClient) CreateBulk(builders ...*CustomerCreate) *CustomerCreateBulk
CreateBulk returns a builder for creating a bulk of Customer entities.
func (*CustomerClient) Delete ¶
func (c *CustomerClient) Delete() *CustomerDelete
Delete returns a delete builder for Customer.
func (*CustomerClient) DeleteOne ¶
func (c *CustomerClient) DeleteOne(cu *Customer) *CustomerDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*CustomerClient) DeleteOneID ¶
func (c *CustomerClient) DeleteOneID(id int) *CustomerDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*CustomerClient) GetX ¶
func (c *CustomerClient) GetX(ctx context.Context, id int) *Customer
GetX is like Get, but panics if an error occurs.
func (*CustomerClient) Hooks ¶
func (c *CustomerClient) Hooks() []Hook
Hooks returns the client hooks.
func (*CustomerClient) Query ¶
func (c *CustomerClient) Query() *CustomerQuery
Query returns a query builder for Customer.
func (*CustomerClient) Update ¶
func (c *CustomerClient) Update() *CustomerUpdate
Update returns an update builder for Customer.
func (*CustomerClient) UpdateOne ¶
func (c *CustomerClient) UpdateOne(cu *Customer) *CustomerUpdateOne
UpdateOne returns an update builder for the given entity.
func (*CustomerClient) UpdateOneID ¶
func (c *CustomerClient) UpdateOneID(id int) *CustomerUpdateOne
UpdateOneID returns an update builder for the given id.
func (*CustomerClient) Use ¶
func (c *CustomerClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `customer.Hooks(f(g(h())))`.
type CustomerCreate ¶
type CustomerCreate struct {
// contains filtered or unexported fields
}
CustomerCreate is the builder for creating a Customer entity.
func (*CustomerCreate) Exec ¶
func (cc *CustomerCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*CustomerCreate) ExecX ¶
func (cc *CustomerCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CustomerCreate) Mutation ¶
func (cc *CustomerCreate) Mutation() *CustomerMutation
Mutation returns the CustomerMutation object of the builder.
func (*CustomerCreate) Save ¶
func (cc *CustomerCreate) Save(ctx context.Context) (*Customer, error)
Save creates the Customer in the database.
func (*CustomerCreate) SaveX ¶
func (cc *CustomerCreate) SaveX(ctx context.Context) *Customer
SaveX calls Save and panics if Save returns an error.
func (*CustomerCreate) SetAddr ¶
func (cc *CustomerCreate) SetAddr(s string) *CustomerCreate
SetAddr sets the "addr" field.
func (*CustomerCreate) SetAge ¶
func (cc *CustomerCreate) SetAge(i int32) *CustomerCreate
SetAge sets the "age" field.
func (*CustomerCreate) SetCreatedAt ¶
func (cc *CustomerCreate) SetCreatedAt(t time.Time) *CustomerCreate
SetCreatedAt sets the "created_at" field.
func (*CustomerCreate) SetID ¶
func (cc *CustomerCreate) SetID(i int) *CustomerCreate
SetID sets the "id" field.
func (*CustomerCreate) SetName ¶
func (cc *CustomerCreate) SetName(s string) *CustomerCreate
SetName sets the "name" field.
func (*CustomerCreate) SetUpdatedAt ¶
func (cc *CustomerCreate) SetUpdatedAt(t time.Time) *CustomerCreate
SetUpdatedAt sets the "updated_at" field.
type CustomerCreateBulk ¶
type CustomerCreateBulk struct {
// contains filtered or unexported fields
}
CustomerCreateBulk is the builder for creating many Customer entities in bulk.
func (*CustomerCreateBulk) Exec ¶
func (ccb *CustomerCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*CustomerCreateBulk) ExecX ¶
func (ccb *CustomerCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type CustomerDelete ¶
type CustomerDelete struct {
// contains filtered or unexported fields
}
CustomerDelete is the builder for deleting a Customer entity.
func (*CustomerDelete) Exec ¶
func (cd *CustomerDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*CustomerDelete) ExecX ¶
func (cd *CustomerDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*CustomerDelete) Where ¶
func (cd *CustomerDelete) Where(ps ...predicate.Customer) *CustomerDelete
Where appends a list predicates to the CustomerDelete builder.
type CustomerDeleteOne ¶
type CustomerDeleteOne struct {
// contains filtered or unexported fields
}
CustomerDeleteOne is the builder for deleting a single Customer entity.
func (*CustomerDeleteOne) Exec ¶
func (cdo *CustomerDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*CustomerDeleteOne) ExecX ¶
func (cdo *CustomerDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type CustomerGroupBy ¶
type CustomerGroupBy struct {
// contains filtered or unexported fields
}
CustomerGroupBy is the group-by builder for Customer entities.
func (*CustomerGroupBy) Aggregate ¶
func (cgb *CustomerGroupBy) Aggregate(fns ...AggregateFunc) *CustomerGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*CustomerGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*CustomerGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*CustomerGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*CustomerGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*CustomerGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*CustomerGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*CustomerGroupBy) Scan ¶
func (cgb *CustomerGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*CustomerGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type CustomerMutation ¶
type CustomerMutation struct {
// contains filtered or unexported fields
}
CustomerMutation represents an operation that mutates the Customer nodes in the graph.
func (*CustomerMutation) AddAge ¶
func (m *CustomerMutation) AddAge(i int32)
AddAge adds i to the "age" field.
func (*CustomerMutation) AddField ¶
func (m *CustomerMutation) 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 (*CustomerMutation) AddedAge ¶
func (m *CustomerMutation) AddedAge() (r int32, exists bool)
AddedAge returns the value that was added to the "age" field in this mutation.
func (*CustomerMutation) AddedEdges ¶
func (m *CustomerMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*CustomerMutation) AddedField ¶
func (m *CustomerMutation) 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 (*CustomerMutation) AddedFields ¶
func (m *CustomerMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*CustomerMutation) AddedIDs ¶
func (m *CustomerMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*CustomerMutation) Addr ¶
func (m *CustomerMutation) Addr() (r string, exists bool)
Addr returns the value of the "addr" field in the mutation.
func (*CustomerMutation) Age ¶
func (m *CustomerMutation) Age() (r int32, exists bool)
Age returns the value of the "age" field in the mutation.
func (*CustomerMutation) ClearEdge ¶
func (m *CustomerMutation) 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 (*CustomerMutation) ClearField ¶
func (m *CustomerMutation) 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 (*CustomerMutation) ClearedEdges ¶
func (m *CustomerMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*CustomerMutation) ClearedFields ¶
func (m *CustomerMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (CustomerMutation) Client ¶
func (m CustomerMutation) 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 (*CustomerMutation) CreatedAt ¶
func (m *CustomerMutation) CreatedAt() (r time.Time, exists bool)
CreatedAt returns the value of the "created_at" field in the mutation.
func (*CustomerMutation) EdgeCleared ¶
func (m *CustomerMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*CustomerMutation) Field ¶
func (m *CustomerMutation) 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 (*CustomerMutation) FieldCleared ¶
func (m *CustomerMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*CustomerMutation) Fields ¶
func (m *CustomerMutation) 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 (*CustomerMutation) ID ¶
func (m *CustomerMutation) ID() (id int, 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 (*CustomerMutation) IDs ¶
func (m *CustomerMutation) IDs(ctx context.Context) ([]int, error)
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 (*CustomerMutation) Name ¶
func (m *CustomerMutation) Name() (r string, exists bool)
Name returns the value of the "name" field in the mutation.
func (*CustomerMutation) OldAddr ¶
func (m *CustomerMutation) OldAddr(ctx context.Context) (v string, err error)
OldAddr returns the old "addr" field's value of the Customer entity. If the Customer 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 (*CustomerMutation) OldAge ¶
func (m *CustomerMutation) OldAge(ctx context.Context) (v int32, err error)
OldAge returns the old "age" field's value of the Customer entity. If the Customer 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 (*CustomerMutation) OldCreatedAt ¶
OldCreatedAt returns the old "created_at" field's value of the Customer entity. If the Customer 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 (*CustomerMutation) 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 (*CustomerMutation) OldName ¶
func (m *CustomerMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old "name" field's value of the Customer entity. If the Customer 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 (*CustomerMutation) OldUpdatedAt ¶
OldUpdatedAt returns the old "updated_at" field's value of the Customer entity. If the Customer 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 (*CustomerMutation) RemovedEdges ¶
func (m *CustomerMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*CustomerMutation) RemovedIDs ¶
func (m *CustomerMutation) 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 (*CustomerMutation) ResetAddr ¶
func (m *CustomerMutation) ResetAddr()
ResetAddr resets all changes to the "addr" field.
func (*CustomerMutation) ResetAge ¶
func (m *CustomerMutation) ResetAge()
ResetAge resets all changes to the "age" field.
func (*CustomerMutation) ResetCreatedAt ¶
func (m *CustomerMutation) ResetCreatedAt()
ResetCreatedAt resets all changes to the "created_at" field.
func (*CustomerMutation) ResetEdge ¶
func (m *CustomerMutation) 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 (*CustomerMutation) ResetField ¶
func (m *CustomerMutation) 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 (*CustomerMutation) ResetName ¶
func (m *CustomerMutation) ResetName()
ResetName resets all changes to the "name" field.
func (*CustomerMutation) ResetUpdatedAt ¶
func (m *CustomerMutation) ResetUpdatedAt()
ResetUpdatedAt resets all changes to the "updated_at" field.
func (*CustomerMutation) SetAddr ¶
func (m *CustomerMutation) SetAddr(s string)
SetAddr sets the "addr" field.
func (*CustomerMutation) SetAge ¶
func (m *CustomerMutation) SetAge(i int32)
SetAge sets the "age" field.
func (*CustomerMutation) SetCreatedAt ¶
func (m *CustomerMutation) SetCreatedAt(t time.Time)
SetCreatedAt sets the "created_at" field.
func (*CustomerMutation) SetField ¶
func (m *CustomerMutation) 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 (*CustomerMutation) SetID ¶
func (m *CustomerMutation) SetID(id int)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Customer entities.
func (*CustomerMutation) SetName ¶
func (m *CustomerMutation) SetName(s string)
SetName sets the "name" field.
func (*CustomerMutation) SetUpdatedAt ¶
func (m *CustomerMutation) SetUpdatedAt(t time.Time)
SetUpdatedAt sets the "updated_at" field.
func (CustomerMutation) Tx ¶
func (m CustomerMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*CustomerMutation) Type ¶
func (m *CustomerMutation) Type() string
Type returns the node type of this mutation (Customer).
func (*CustomerMutation) UpdatedAt ¶
func (m *CustomerMutation) UpdatedAt() (r time.Time, exists bool)
UpdatedAt returns the value of the "updated_at" field in the mutation.
func (*CustomerMutation) Where ¶
func (m *CustomerMutation) Where(ps ...predicate.Customer)
Where appends a list predicates to the CustomerMutation builder.
type CustomerQuery ¶
type CustomerQuery struct {
// contains filtered or unexported fields
}
CustomerQuery is the builder for querying Customer entities.
func (*CustomerQuery) All ¶
func (cq *CustomerQuery) All(ctx context.Context) ([]*Customer, error)
All executes the query and returns a list of Customers.
func (*CustomerQuery) AllX ¶
func (cq *CustomerQuery) AllX(ctx context.Context) []*Customer
AllX is like All, but panics if an error occurs.
func (*CustomerQuery) Clone ¶
func (cq *CustomerQuery) Clone() *CustomerQuery
Clone returns a duplicate of the CustomerQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*CustomerQuery) Count ¶
func (cq *CustomerQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*CustomerQuery) CountX ¶
func (cq *CustomerQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*CustomerQuery) Exist ¶
func (cq *CustomerQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*CustomerQuery) ExistX ¶
func (cq *CustomerQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*CustomerQuery) First ¶
func (cq *CustomerQuery) First(ctx context.Context) (*Customer, error)
First returns the first Customer entity from the query. Returns a *NotFoundError when no Customer was found.
func (*CustomerQuery) FirstID ¶
func (cq *CustomerQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Customer ID from the query. Returns a *NotFoundError when no Customer ID was found.
func (*CustomerQuery) FirstIDX ¶
func (cq *CustomerQuery) FirstIDX(ctx context.Context) int
FirstIDX is like FirstID, but panics if an error occurs.
func (*CustomerQuery) FirstX ¶
func (cq *CustomerQuery) FirstX(ctx context.Context) *Customer
FirstX is like First, but panics if an error occurs.
func (*CustomerQuery) GroupBy ¶
func (cq *CustomerQuery) GroupBy(field string, fields ...string) *CustomerGroupBy
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 { Addr string `json:"addr,omitempty"` Count int `json:"count,omitempty"` } client.Customer.Query(). GroupBy(customer.FieldAddr). Aggregate(ent.Count()). Scan(ctx, &v)
func (*CustomerQuery) IDs ¶
func (cq *CustomerQuery) IDs(ctx context.Context) ([]int, error)
IDs executes the query and returns a list of Customer IDs.
func (*CustomerQuery) IDsX ¶
func (cq *CustomerQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*CustomerQuery) Limit ¶
func (cq *CustomerQuery) Limit(limit int) *CustomerQuery
Limit adds a limit step to the query.
func (*CustomerQuery) Offset ¶
func (cq *CustomerQuery) Offset(offset int) *CustomerQuery
Offset adds an offset step to the query.
func (*CustomerQuery) Only ¶
func (cq *CustomerQuery) Only(ctx context.Context) (*Customer, error)
Only returns a single Customer entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Customer entity is found. Returns a *NotFoundError when no Customer entities are found.
func (*CustomerQuery) OnlyID ¶
func (cq *CustomerQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID is like Only, but returns the only Customer ID in the query. Returns a *NotSingularError when more than one Customer ID is found. Returns a *NotFoundError when no entities are found.
func (*CustomerQuery) OnlyIDX ¶
func (cq *CustomerQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*CustomerQuery) OnlyX ¶
func (cq *CustomerQuery) OnlyX(ctx context.Context) *Customer
OnlyX is like Only, but panics if an error occurs.
func (*CustomerQuery) Order ¶
func (cq *CustomerQuery) Order(o ...OrderFunc) *CustomerQuery
Order adds an order step to the query.
func (*CustomerQuery) Select ¶
func (cq *CustomerQuery) Select(fields ...string) *CustomerSelect
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 { Addr string `json:"addr,omitempty"` } client.Customer.Query(). Select(customer.FieldAddr). Scan(ctx, &v)
func (*CustomerQuery) Unique ¶
func (cq *CustomerQuery) Unique(unique bool) *CustomerQuery
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 (*CustomerQuery) Where ¶
func (cq *CustomerQuery) Where(ps ...predicate.Customer) *CustomerQuery
Where adds a new predicate for the CustomerQuery builder.
type CustomerSelect ¶
type CustomerSelect struct { *CustomerQuery // contains filtered or unexported fields }
CustomerSelect is the builder for selecting fields of Customer entities.
func (*CustomerSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*CustomerSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*CustomerSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*CustomerSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*CustomerSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*CustomerSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*CustomerSelect) Scan ¶
func (cs *CustomerSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*CustomerSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type CustomerUpdate ¶
type CustomerUpdate struct {
// contains filtered or unexported fields
}
CustomerUpdate is the builder for updating Customer entities.
func (*CustomerUpdate) AddAge ¶
func (cu *CustomerUpdate) AddAge(i int32) *CustomerUpdate
AddAge adds i to the "age" field.
func (*CustomerUpdate) Exec ¶
func (cu *CustomerUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*CustomerUpdate) ExecX ¶
func (cu *CustomerUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CustomerUpdate) Mutation ¶
func (cu *CustomerUpdate) Mutation() *CustomerMutation
Mutation returns the CustomerMutation object of the builder.
func (*CustomerUpdate) Save ¶
func (cu *CustomerUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*CustomerUpdate) SaveX ¶
func (cu *CustomerUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*CustomerUpdate) SetAddr ¶
func (cu *CustomerUpdate) SetAddr(s string) *CustomerUpdate
SetAddr sets the "addr" field.
func (*CustomerUpdate) SetAge ¶
func (cu *CustomerUpdate) SetAge(i int32) *CustomerUpdate
SetAge sets the "age" field.
func (*CustomerUpdate) SetCreatedAt ¶
func (cu *CustomerUpdate) SetCreatedAt(t time.Time) *CustomerUpdate
SetCreatedAt sets the "created_at" field.
func (*CustomerUpdate) SetName ¶
func (cu *CustomerUpdate) SetName(s string) *CustomerUpdate
SetName sets the "name" field.
func (*CustomerUpdate) SetUpdatedAt ¶
func (cu *CustomerUpdate) SetUpdatedAt(t time.Time) *CustomerUpdate
SetUpdatedAt sets the "updated_at" field.
func (*CustomerUpdate) Where ¶
func (cu *CustomerUpdate) Where(ps ...predicate.Customer) *CustomerUpdate
Where appends a list predicates to the CustomerUpdate builder.
type CustomerUpdateOne ¶
type CustomerUpdateOne struct {
// contains filtered or unexported fields
}
CustomerUpdateOne is the builder for updating a single Customer entity.
func (*CustomerUpdateOne) AddAge ¶
func (cuo *CustomerUpdateOne) AddAge(i int32) *CustomerUpdateOne
AddAge adds i to the "age" field.
func (*CustomerUpdateOne) Exec ¶
func (cuo *CustomerUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*CustomerUpdateOne) ExecX ¶
func (cuo *CustomerUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CustomerUpdateOne) Mutation ¶
func (cuo *CustomerUpdateOne) Mutation() *CustomerMutation
Mutation returns the CustomerMutation object of the builder.
func (*CustomerUpdateOne) Save ¶
func (cuo *CustomerUpdateOne) Save(ctx context.Context) (*Customer, error)
Save executes the query and returns the updated Customer entity.
func (*CustomerUpdateOne) SaveX ¶
func (cuo *CustomerUpdateOne) SaveX(ctx context.Context) *Customer
SaveX is like Save, but panics if an error occurs.
func (*CustomerUpdateOne) Select ¶
func (cuo *CustomerUpdateOne) Select(field string, fields ...string) *CustomerUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*CustomerUpdateOne) SetAddr ¶
func (cuo *CustomerUpdateOne) SetAddr(s string) *CustomerUpdateOne
SetAddr sets the "addr" field.
func (*CustomerUpdateOne) SetAge ¶
func (cuo *CustomerUpdateOne) SetAge(i int32) *CustomerUpdateOne
SetAge sets the "age" field.
func (*CustomerUpdateOne) SetCreatedAt ¶
func (cuo *CustomerUpdateOne) SetCreatedAt(t time.Time) *CustomerUpdateOne
SetCreatedAt sets the "created_at" field.
func (*CustomerUpdateOne) SetName ¶
func (cuo *CustomerUpdateOne) SetName(s string) *CustomerUpdateOne
SetName sets the "name" field.
func (*CustomerUpdateOne) SetUpdatedAt ¶
func (cuo *CustomerUpdateOne) SetUpdatedAt(t time.Time) *CustomerUpdateOne
SetUpdatedAt sets the "updated_at" field.
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 Order ¶
type Order struct { // ID of the ent. ID int `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // CustomerID holds the value of the "customer_id" field. CustomerID int `json:"customer_id,omitempty"` // Addr holds the value of the "addr" field. Addr string `json:"addr,omitempty"` // Price holds the value of the "price" field. Price float64 `json:"price,omitempty"` // Status holds the value of the "status" field. Status int32 `json:"status,omitempty"` // contains filtered or unexported fields }
Order is the model entity for the Order schema.
func (*Order) Unwrap ¶
Unwrap unwraps the Order 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 (*Order) Update ¶
func (o *Order) Update() *OrderUpdateOne
Update returns a builder for updating this Order. Note that you need to call Order.Unwrap() before calling this method if this Order was returned from a transaction, and the transaction was committed or rolled back.
type OrderClient ¶
type OrderClient struct {
// contains filtered or unexported fields
}
OrderClient is a client for the Order schema.
func NewOrderClient ¶
func NewOrderClient(c config) *OrderClient
NewOrderClient returns a client for the Order from the given config.
func (*OrderClient) Create ¶
func (c *OrderClient) Create() *OrderCreate
Create returns a create builder for Order.
func (*OrderClient) CreateBulk ¶
func (c *OrderClient) CreateBulk(builders ...*OrderCreate) *OrderCreateBulk
CreateBulk returns a builder for creating a bulk of Order entities.
func (*OrderClient) Delete ¶
func (c *OrderClient) Delete() *OrderDelete
Delete returns a delete builder for Order.
func (*OrderClient) DeleteOne ¶
func (c *OrderClient) DeleteOne(o *Order) *OrderDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*OrderClient) DeleteOneID ¶
func (c *OrderClient) DeleteOneID(id int) *OrderDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*OrderClient) GetX ¶
func (c *OrderClient) GetX(ctx context.Context, id int) *Order
GetX is like Get, but panics if an error occurs.
func (*OrderClient) Query ¶
func (c *OrderClient) Query() *OrderQuery
Query returns a query builder for Order.
func (*OrderClient) Update ¶
func (c *OrderClient) Update() *OrderUpdate
Update returns an update builder for Order.
func (*OrderClient) UpdateOne ¶
func (c *OrderClient) UpdateOne(o *Order) *OrderUpdateOne
UpdateOne returns an update builder for the given entity.
func (*OrderClient) UpdateOneID ¶
func (c *OrderClient) UpdateOneID(id int) *OrderUpdateOne
UpdateOneID returns an update builder for the given id.
func (*OrderClient) Use ¶
func (c *OrderClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `order.Hooks(f(g(h())))`.
type OrderCreate ¶
type OrderCreate struct {
// contains filtered or unexported fields
}
OrderCreate is the builder for creating a Order entity.
func (*OrderCreate) Exec ¶
func (oc *OrderCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*OrderCreate) ExecX ¶
func (oc *OrderCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*OrderCreate) Mutation ¶
func (oc *OrderCreate) Mutation() *OrderMutation
Mutation returns the OrderMutation object of the builder.
func (*OrderCreate) Save ¶
func (oc *OrderCreate) Save(ctx context.Context) (*Order, error)
Save creates the Order in the database.
func (*OrderCreate) SaveX ¶
func (oc *OrderCreate) SaveX(ctx context.Context) *Order
SaveX calls Save and panics if Save returns an error.
func (*OrderCreate) SetAddr ¶
func (oc *OrderCreate) SetAddr(s string) *OrderCreate
SetAddr sets the "addr" field.
func (*OrderCreate) SetCreatedAt ¶
func (oc *OrderCreate) SetCreatedAt(t time.Time) *OrderCreate
SetCreatedAt sets the "created_at" field.
func (*OrderCreate) SetCustomerID ¶
func (oc *OrderCreate) SetCustomerID(i int) *OrderCreate
SetCustomerID sets the "customer_id" field.
func (*OrderCreate) SetID ¶
func (oc *OrderCreate) SetID(i int) *OrderCreate
SetID sets the "id" field.
func (*OrderCreate) SetPrice ¶
func (oc *OrderCreate) SetPrice(f float64) *OrderCreate
SetPrice sets the "price" field.
func (*OrderCreate) SetStatus ¶
func (oc *OrderCreate) SetStatus(i int32) *OrderCreate
SetStatus sets the "status" field.
func (*OrderCreate) SetUpdatedAt ¶
func (oc *OrderCreate) SetUpdatedAt(t time.Time) *OrderCreate
SetUpdatedAt sets the "updated_at" field.
type OrderCreateBulk ¶
type OrderCreateBulk struct {
// contains filtered or unexported fields
}
OrderCreateBulk is the builder for creating many Order entities in bulk.
func (*OrderCreateBulk) Exec ¶
func (ocb *OrderCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*OrderCreateBulk) ExecX ¶
func (ocb *OrderCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type OrderDelete ¶
type OrderDelete struct {
// contains filtered or unexported fields
}
OrderDelete is the builder for deleting a Order entity.
func (*OrderDelete) Exec ¶
func (od *OrderDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*OrderDelete) ExecX ¶
func (od *OrderDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*OrderDelete) Where ¶
func (od *OrderDelete) Where(ps ...predicate.Order) *OrderDelete
Where appends a list predicates to the OrderDelete builder.
type OrderDeleteOne ¶
type OrderDeleteOne struct {
// contains filtered or unexported fields
}
OrderDeleteOne is the builder for deleting a single Order entity.
func (*OrderDeleteOne) Exec ¶
func (odo *OrderDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*OrderDeleteOne) ExecX ¶
func (odo *OrderDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type OrderGroupBy ¶
type OrderGroupBy struct {
// contains filtered or unexported fields
}
OrderGroupBy is the group-by builder for Order entities.
func (*OrderGroupBy) Aggregate ¶
func (ogb *OrderGroupBy) Aggregate(fns ...AggregateFunc) *OrderGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*OrderGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*OrderGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*OrderGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*OrderGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*OrderGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*OrderGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*OrderGroupBy) Scan ¶
func (ogb *OrderGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*OrderGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type OrderMutation ¶
type OrderMutation struct {
// contains filtered or unexported fields
}
OrderMutation represents an operation that mutates the Order nodes in the graph.
func (*OrderMutation) AddCustomerID ¶
func (m *OrderMutation) AddCustomerID(i int)
AddCustomerID adds i to the "customer_id" field.
func (*OrderMutation) AddField ¶
func (m *OrderMutation) 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 (*OrderMutation) AddPrice ¶
func (m *OrderMutation) AddPrice(f float64)
AddPrice adds f to the "price" field.
func (*OrderMutation) AddStatus ¶
func (m *OrderMutation) AddStatus(i int32)
AddStatus adds i to the "status" field.
func (*OrderMutation) AddedCustomerID ¶
func (m *OrderMutation) AddedCustomerID() (r int, exists bool)
AddedCustomerID returns the value that was added to the "customer_id" field in this mutation.
func (*OrderMutation) AddedEdges ¶
func (m *OrderMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*OrderMutation) AddedField ¶
func (m *OrderMutation) 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 (*OrderMutation) AddedFields ¶
func (m *OrderMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*OrderMutation) AddedIDs ¶
func (m *OrderMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*OrderMutation) AddedPrice ¶
func (m *OrderMutation) AddedPrice() (r float64, exists bool)
AddedPrice returns the value that was added to the "price" field in this mutation.
func (*OrderMutation) AddedStatus ¶
func (m *OrderMutation) AddedStatus() (r int32, exists bool)
AddedStatus returns the value that was added to the "status" field in this mutation.
func (*OrderMutation) Addr ¶
func (m *OrderMutation) Addr() (r string, exists bool)
Addr returns the value of the "addr" field in the mutation.
func (*OrderMutation) ClearEdge ¶
func (m *OrderMutation) 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 (*OrderMutation) ClearField ¶
func (m *OrderMutation) 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 (*OrderMutation) ClearedEdges ¶
func (m *OrderMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*OrderMutation) ClearedFields ¶
func (m *OrderMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (OrderMutation) Client ¶
func (m OrderMutation) 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 (*OrderMutation) CreatedAt ¶
func (m *OrderMutation) CreatedAt() (r time.Time, exists bool)
CreatedAt returns the value of the "created_at" field in the mutation.
func (*OrderMutation) CustomerID ¶
func (m *OrderMutation) CustomerID() (r int, exists bool)
CustomerID returns the value of the "customer_id" field in the mutation.
func (*OrderMutation) EdgeCleared ¶
func (m *OrderMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*OrderMutation) Field ¶
func (m *OrderMutation) 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 (*OrderMutation) FieldCleared ¶
func (m *OrderMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*OrderMutation) Fields ¶
func (m *OrderMutation) 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 (*OrderMutation) ID ¶
func (m *OrderMutation) ID() (id int, 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 (*OrderMutation) IDs ¶
func (m *OrderMutation) IDs(ctx context.Context) ([]int, error)
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 (*OrderMutation) OldAddr ¶
func (m *OrderMutation) OldAddr(ctx context.Context) (v string, err error)
OldAddr returns the old "addr" field's value of the Order entity. If the Order 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 (*OrderMutation) OldCreatedAt ¶
OldCreatedAt returns the old "created_at" field's value of the Order entity. If the Order 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 (*OrderMutation) OldCustomerID ¶
func (m *OrderMutation) OldCustomerID(ctx context.Context) (v int, err error)
OldCustomerID returns the old "customer_id" field's value of the Order entity. If the Order 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 (*OrderMutation) 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 (*OrderMutation) OldPrice ¶
func (m *OrderMutation) OldPrice(ctx context.Context) (v float64, err error)
OldPrice returns the old "price" field's value of the Order entity. If the Order 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 (*OrderMutation) OldStatus ¶
func (m *OrderMutation) OldStatus(ctx context.Context) (v int32, err error)
OldStatus returns the old "status" field's value of the Order entity. If the Order 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 (*OrderMutation) OldUpdatedAt ¶
OldUpdatedAt returns the old "updated_at" field's value of the Order entity. If the Order 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 (*OrderMutation) Price ¶
func (m *OrderMutation) Price() (r float64, exists bool)
Price returns the value of the "price" field in the mutation.
func (*OrderMutation) RemovedEdges ¶
func (m *OrderMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*OrderMutation) RemovedIDs ¶
func (m *OrderMutation) 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 (*OrderMutation) ResetAddr ¶
func (m *OrderMutation) ResetAddr()
ResetAddr resets all changes to the "addr" field.
func (*OrderMutation) ResetCreatedAt ¶
func (m *OrderMutation) ResetCreatedAt()
ResetCreatedAt resets all changes to the "created_at" field.
func (*OrderMutation) ResetCustomerID ¶
func (m *OrderMutation) ResetCustomerID()
ResetCustomerID resets all changes to the "customer_id" field.
func (*OrderMutation) ResetEdge ¶
func (m *OrderMutation) 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 (*OrderMutation) ResetField ¶
func (m *OrderMutation) 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 (*OrderMutation) ResetPrice ¶
func (m *OrderMutation) ResetPrice()
ResetPrice resets all changes to the "price" field.
func (*OrderMutation) ResetStatus ¶
func (m *OrderMutation) ResetStatus()
ResetStatus resets all changes to the "status" field.
func (*OrderMutation) ResetUpdatedAt ¶
func (m *OrderMutation) ResetUpdatedAt()
ResetUpdatedAt resets all changes to the "updated_at" field.
func (*OrderMutation) SetAddr ¶
func (m *OrderMutation) SetAddr(s string)
SetAddr sets the "addr" field.
func (*OrderMutation) SetCreatedAt ¶
func (m *OrderMutation) SetCreatedAt(t time.Time)
SetCreatedAt sets the "created_at" field.
func (*OrderMutation) SetCustomerID ¶
func (m *OrderMutation) SetCustomerID(i int)
SetCustomerID sets the "customer_id" field.
func (*OrderMutation) SetField ¶
func (m *OrderMutation) 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 (*OrderMutation) SetID ¶
func (m *OrderMutation) SetID(id int)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Order entities.
func (*OrderMutation) SetPrice ¶
func (m *OrderMutation) SetPrice(f float64)
SetPrice sets the "price" field.
func (*OrderMutation) SetStatus ¶
func (m *OrderMutation) SetStatus(i int32)
SetStatus sets the "status" field.
func (*OrderMutation) SetUpdatedAt ¶
func (m *OrderMutation) SetUpdatedAt(t time.Time)
SetUpdatedAt sets the "updated_at" field.
func (*OrderMutation) Status ¶
func (m *OrderMutation) Status() (r int32, exists bool)
Status returns the value of the "status" field in the mutation.
func (OrderMutation) Tx ¶
func (m OrderMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*OrderMutation) Type ¶
func (m *OrderMutation) Type() string
Type returns the node type of this mutation (Order).
func (*OrderMutation) UpdatedAt ¶
func (m *OrderMutation) UpdatedAt() (r time.Time, exists bool)
UpdatedAt returns the value of the "updated_at" field in the mutation.
func (*OrderMutation) Where ¶
func (m *OrderMutation) Where(ps ...predicate.Order)
Where appends a list predicates to the OrderMutation builder.
type OrderQuery ¶
type OrderQuery struct {
// contains filtered or unexported fields
}
OrderQuery is the builder for querying Order entities.
func (*OrderQuery) All ¶
func (oq *OrderQuery) All(ctx context.Context) ([]*Order, error)
All executes the query and returns a list of Orders.
func (*OrderQuery) AllX ¶
func (oq *OrderQuery) AllX(ctx context.Context) []*Order
AllX is like All, but panics if an error occurs.
func (*OrderQuery) Clone ¶
func (oq *OrderQuery) Clone() *OrderQuery
Clone returns a duplicate of the OrderQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*OrderQuery) Count ¶
func (oq *OrderQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*OrderQuery) CountX ¶
func (oq *OrderQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*OrderQuery) Exist ¶
func (oq *OrderQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*OrderQuery) ExistX ¶
func (oq *OrderQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*OrderQuery) First ¶
func (oq *OrderQuery) First(ctx context.Context) (*Order, error)
First returns the first Order entity from the query. Returns a *NotFoundError when no Order was found.
func (*OrderQuery) FirstID ¶
func (oq *OrderQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Order ID from the query. Returns a *NotFoundError when no Order ID was found.
func (*OrderQuery) FirstIDX ¶
func (oq *OrderQuery) FirstIDX(ctx context.Context) int
FirstIDX is like FirstID, but panics if an error occurs.
func (*OrderQuery) FirstX ¶
func (oq *OrderQuery) FirstX(ctx context.Context) *Order
FirstX is like First, but panics if an error occurs.
func (*OrderQuery) GroupBy ¶
func (oq *OrderQuery) GroupBy(field string, fields ...string) *OrderGroupBy
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 { CreatedAt time.Time `json:"created_at,omitempty"` Count int `json:"count,omitempty"` } client.Order.Query(). GroupBy(order.FieldCreatedAt). Aggregate(ent.Count()). Scan(ctx, &v)
func (*OrderQuery) IDs ¶
func (oq *OrderQuery) IDs(ctx context.Context) ([]int, error)
IDs executes the query and returns a list of Order IDs.
func (*OrderQuery) IDsX ¶
func (oq *OrderQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*OrderQuery) Limit ¶
func (oq *OrderQuery) Limit(limit int) *OrderQuery
Limit adds a limit step to the query.
func (*OrderQuery) Offset ¶
func (oq *OrderQuery) Offset(offset int) *OrderQuery
Offset adds an offset step to the query.
func (*OrderQuery) Only ¶
func (oq *OrderQuery) Only(ctx context.Context) (*Order, error)
Only returns a single Order entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Order entity is found. Returns a *NotFoundError when no Order entities are found.
func (*OrderQuery) OnlyID ¶
func (oq *OrderQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID is like Only, but returns the only Order ID in the query. Returns a *NotSingularError when more than one Order ID is found. Returns a *NotFoundError when no entities are found.
func (*OrderQuery) OnlyIDX ¶
func (oq *OrderQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*OrderQuery) OnlyX ¶
func (oq *OrderQuery) OnlyX(ctx context.Context) *Order
OnlyX is like Only, but panics if an error occurs.
func (*OrderQuery) Order ¶
func (oq *OrderQuery) Order(o ...OrderFunc) *OrderQuery
Order adds an order step to the query.
func (*OrderQuery) Select ¶
func (oq *OrderQuery) Select(fields ...string) *OrderSelect
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 { CreatedAt time.Time `json:"created_at,omitempty"` } client.Order.Query(). Select(order.FieldCreatedAt). Scan(ctx, &v)
func (*OrderQuery) Unique ¶
func (oq *OrderQuery) Unique(unique bool) *OrderQuery
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 (*OrderQuery) Where ¶
func (oq *OrderQuery) Where(ps ...predicate.Order) *OrderQuery
Where adds a new predicate for the OrderQuery builder.
type OrderSelect ¶
type OrderSelect struct { *OrderQuery // contains filtered or unexported fields }
OrderSelect is the builder for selecting fields of Order entities.
func (*OrderSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*OrderSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*OrderSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*OrderSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*OrderSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*OrderSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*OrderSelect) Scan ¶
func (os *OrderSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*OrderSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type OrderUpdate ¶
type OrderUpdate struct {
// contains filtered or unexported fields
}
OrderUpdate is the builder for updating Order entities.
func (*OrderUpdate) AddCustomerID ¶
func (ou *OrderUpdate) AddCustomerID(i int) *OrderUpdate
AddCustomerID adds i to the "customer_id" field.
func (*OrderUpdate) AddPrice ¶
func (ou *OrderUpdate) AddPrice(f float64) *OrderUpdate
AddPrice adds f to the "price" field.
func (*OrderUpdate) AddStatus ¶
func (ou *OrderUpdate) AddStatus(i int32) *OrderUpdate
AddStatus adds i to the "status" field.
func (*OrderUpdate) Exec ¶
func (ou *OrderUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*OrderUpdate) ExecX ¶
func (ou *OrderUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*OrderUpdate) Mutation ¶
func (ou *OrderUpdate) Mutation() *OrderMutation
Mutation returns the OrderMutation object of the builder.
func (*OrderUpdate) Save ¶
func (ou *OrderUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*OrderUpdate) SaveX ¶
func (ou *OrderUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*OrderUpdate) SetAddr ¶
func (ou *OrderUpdate) SetAddr(s string) *OrderUpdate
SetAddr sets the "addr" field.
func (*OrderUpdate) SetCreatedAt ¶
func (ou *OrderUpdate) SetCreatedAt(t time.Time) *OrderUpdate
SetCreatedAt sets the "created_at" field.
func (*OrderUpdate) SetCustomerID ¶
func (ou *OrderUpdate) SetCustomerID(i int) *OrderUpdate
SetCustomerID sets the "customer_id" field.
func (*OrderUpdate) SetPrice ¶
func (ou *OrderUpdate) SetPrice(f float64) *OrderUpdate
SetPrice sets the "price" field.
func (*OrderUpdate) SetStatus ¶
func (ou *OrderUpdate) SetStatus(i int32) *OrderUpdate
SetStatus sets the "status" field.
func (*OrderUpdate) SetUpdatedAt ¶
func (ou *OrderUpdate) SetUpdatedAt(t time.Time) *OrderUpdate
SetUpdatedAt sets the "updated_at" field.
func (*OrderUpdate) Where ¶
func (ou *OrderUpdate) Where(ps ...predicate.Order) *OrderUpdate
Where appends a list predicates to the OrderUpdate builder.
type OrderUpdateOne ¶
type OrderUpdateOne struct {
// contains filtered or unexported fields
}
OrderUpdateOne is the builder for updating a single Order entity.
func (*OrderUpdateOne) AddCustomerID ¶
func (ouo *OrderUpdateOne) AddCustomerID(i int) *OrderUpdateOne
AddCustomerID adds i to the "customer_id" field.
func (*OrderUpdateOne) AddPrice ¶
func (ouo *OrderUpdateOne) AddPrice(f float64) *OrderUpdateOne
AddPrice adds f to the "price" field.
func (*OrderUpdateOne) AddStatus ¶
func (ouo *OrderUpdateOne) AddStatus(i int32) *OrderUpdateOne
AddStatus adds i to the "status" field.
func (*OrderUpdateOne) Exec ¶
func (ouo *OrderUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*OrderUpdateOne) ExecX ¶
func (ouo *OrderUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*OrderUpdateOne) Mutation ¶
func (ouo *OrderUpdateOne) Mutation() *OrderMutation
Mutation returns the OrderMutation object of the builder.
func (*OrderUpdateOne) Save ¶
func (ouo *OrderUpdateOne) Save(ctx context.Context) (*Order, error)
Save executes the query and returns the updated Order entity.
func (*OrderUpdateOne) SaveX ¶
func (ouo *OrderUpdateOne) SaveX(ctx context.Context) *Order
SaveX is like Save, but panics if an error occurs.
func (*OrderUpdateOne) Select ¶
func (ouo *OrderUpdateOne) Select(field string, fields ...string) *OrderUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*OrderUpdateOne) SetAddr ¶
func (ouo *OrderUpdateOne) SetAddr(s string) *OrderUpdateOne
SetAddr sets the "addr" field.
func (*OrderUpdateOne) SetCreatedAt ¶
func (ouo *OrderUpdateOne) SetCreatedAt(t time.Time) *OrderUpdateOne
SetCreatedAt sets the "created_at" field.
func (*OrderUpdateOne) SetCustomerID ¶
func (ouo *OrderUpdateOne) SetCustomerID(i int) *OrderUpdateOne
SetCustomerID sets the "customer_id" field.
func (*OrderUpdateOne) SetPrice ¶
func (ouo *OrderUpdateOne) SetPrice(f float64) *OrderUpdateOne
SetPrice sets the "price" field.
func (*OrderUpdateOne) SetStatus ¶
func (ouo *OrderUpdateOne) SetStatus(i int32) *OrderUpdateOne
SetStatus sets the "status" field.
func (*OrderUpdateOne) SetUpdatedAt ¶
func (ouo *OrderUpdateOne) SetUpdatedAt(t time.Time) *OrderUpdateOne
SetUpdatedAt sets the "updated_at" field.
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 Tx ¶
type Tx struct { // Customer is the client for interacting with the Customer builders. Customer *CustomerClient // Order is the client for interacting with the Order builders. Order *OrderClient // 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.