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 Counter
- type CounterClient
- func (c *CounterClient) Create() *CounterCreate
- func (c *CounterClient) CreateBulk(builders ...*CounterCreate) *CounterCreateBulk
- func (c *CounterClient) Delete() *CounterDelete
- func (c *CounterClient) DeleteOne(co *Counter) *CounterDeleteOne
- func (c *CounterClient) DeleteOneID(id string) *CounterDeleteOne
- func (c *CounterClient) Get(ctx context.Context, id string) (*Counter, error)
- func (c *CounterClient) GetX(ctx context.Context, id string) *Counter
- func (c *CounterClient) Hooks() []Hook
- func (c *CounterClient) Intercept(interceptors ...Interceptor)
- func (c *CounterClient) Interceptors() []Interceptor
- func (c *CounterClient) MapCreateBulk(slice any, setFunc func(*CounterCreate, int)) *CounterCreateBulk
- func (c *CounterClient) Query() *CounterQuery
- func (c *CounterClient) Update() *CounterUpdate
- func (c *CounterClient) UpdateOne(co *Counter) *CounterUpdateOne
- func (c *CounterClient) UpdateOneID(id string) *CounterUpdateOne
- func (c *CounterClient) Use(hooks ...Hook)
- type CounterCreate
- func (cc *CounterCreate) Exec(ctx context.Context) error
- func (cc *CounterCreate) ExecX(ctx context.Context)
- func (cc *CounterCreate) Mutation() *CounterMutation
- func (cc *CounterCreate) Save(ctx context.Context) (*Counter, error)
- func (cc *CounterCreate) SaveX(ctx context.Context) *Counter
- func (cc *CounterCreate) SetID(s string) *CounterCreate
- func (cc *CounterCreate) SetValue(i int64) *CounterCreate
- type CounterCreateBulk
- type CounterDelete
- type CounterDeleteOne
- type CounterGroupBy
- func (cgb *CounterGroupBy) Aggregate(fns ...AggregateFunc) *CounterGroupBy
- func (s *CounterGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *CounterGroupBy) BoolX(ctx context.Context) bool
- func (s *CounterGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *CounterGroupBy) BoolsX(ctx context.Context) []bool
- func (s *CounterGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *CounterGroupBy) Float64X(ctx context.Context) float64
- func (s *CounterGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *CounterGroupBy) Float64sX(ctx context.Context) []float64
- func (s *CounterGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *CounterGroupBy) IntX(ctx context.Context) int
- func (s *CounterGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *CounterGroupBy) IntsX(ctx context.Context) []int
- func (cgb *CounterGroupBy) Scan(ctx context.Context, v any) error
- func (s *CounterGroupBy) ScanX(ctx context.Context, v any)
- func (s *CounterGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *CounterGroupBy) StringX(ctx context.Context) string
- func (s *CounterGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *CounterGroupBy) StringsX(ctx context.Context) []string
- type CounterMutation
- func (m *CounterMutation) AddField(name string, value ent.Value) error
- func (m *CounterMutation) AddValue(i int64)
- func (m *CounterMutation) AddedEdges() []string
- func (m *CounterMutation) AddedField(name string) (ent.Value, bool)
- func (m *CounterMutation) AddedFields() []string
- func (m *CounterMutation) AddedIDs(name string) []ent.Value
- func (m *CounterMutation) AddedValue() (r int64, exists bool)
- func (m *CounterMutation) ClearEdge(name string) error
- func (m *CounterMutation) ClearField(name string) error
- func (m *CounterMutation) ClearedEdges() []string
- func (m *CounterMutation) ClearedFields() []string
- func (m CounterMutation) Client() *Client
- func (m *CounterMutation) EdgeCleared(name string) bool
- func (m *CounterMutation) Field(name string) (ent.Value, bool)
- func (m *CounterMutation) FieldCleared(name string) bool
- func (m *CounterMutation) Fields() []string
- func (m *CounterMutation) ID() (id string, exists bool)
- func (m *CounterMutation) IDs(ctx context.Context) ([]string, error)
- func (m *CounterMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *CounterMutation) OldValue(ctx context.Context) (v int64, err error)
- func (m *CounterMutation) Op() Op
- func (m *CounterMutation) RemovedEdges() []string
- func (m *CounterMutation) RemovedIDs(name string) []ent.Value
- func (m *CounterMutation) ResetEdge(name string) error
- func (m *CounterMutation) ResetField(name string) error
- func (m *CounterMutation) ResetValue()
- func (m *CounterMutation) SetField(name string, value ent.Value) error
- func (m *CounterMutation) SetID(id string)
- func (m *CounterMutation) SetOp(op Op)
- func (m *CounterMutation) SetValue(i int64)
- func (m CounterMutation) Tx() (*Tx, error)
- func (m *CounterMutation) Type() string
- func (m *CounterMutation) Value() (r int64, exists bool)
- func (m *CounterMutation) Where(ps ...predicate.Counter)
- func (m *CounterMutation) WhereP(ps ...func(*sql.Selector))
- type CounterQuery
- func (cq *CounterQuery) Aggregate(fns ...AggregateFunc) *CounterSelect
- func (cq *CounterQuery) All(ctx context.Context) ([]*Counter, error)
- func (cq *CounterQuery) AllX(ctx context.Context) []*Counter
- func (cq *CounterQuery) Clone() *CounterQuery
- func (cq *CounterQuery) Count(ctx context.Context) (int, error)
- func (cq *CounterQuery) CountX(ctx context.Context) int
- func (cq *CounterQuery) Exist(ctx context.Context) (bool, error)
- func (cq *CounterQuery) ExistX(ctx context.Context) bool
- func (cq *CounterQuery) First(ctx context.Context) (*Counter, error)
- func (cq *CounterQuery) FirstID(ctx context.Context) (id string, err error)
- func (cq *CounterQuery) FirstIDX(ctx context.Context) string
- func (cq *CounterQuery) FirstX(ctx context.Context) *Counter
- func (cq *CounterQuery) GroupBy(field string, fields ...string) *CounterGroupBy
- func (cq *CounterQuery) IDs(ctx context.Context) (ids []string, err error)
- func (cq *CounterQuery) IDsX(ctx context.Context) []string
- func (cq *CounterQuery) Limit(limit int) *CounterQuery
- func (cq *CounterQuery) Offset(offset int) *CounterQuery
- func (cq *CounterQuery) Only(ctx context.Context) (*Counter, error)
- func (cq *CounterQuery) OnlyID(ctx context.Context) (id string, err error)
- func (cq *CounterQuery) OnlyIDX(ctx context.Context) string
- func (cq *CounterQuery) OnlyX(ctx context.Context) *Counter
- func (cq *CounterQuery) Order(o ...counter.OrderOption) *CounterQuery
- func (cq *CounterQuery) Select(fields ...string) *CounterSelect
- func (cq *CounterQuery) Unique(unique bool) *CounterQuery
- func (cq *CounterQuery) Where(ps ...predicate.Counter) *CounterQuery
- type CounterSelect
- func (cs *CounterSelect) Aggregate(fns ...AggregateFunc) *CounterSelect
- func (s *CounterSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *CounterSelect) BoolX(ctx context.Context) bool
- func (s *CounterSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *CounterSelect) BoolsX(ctx context.Context) []bool
- func (s *CounterSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *CounterSelect) Float64X(ctx context.Context) float64
- func (s *CounterSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *CounterSelect) Float64sX(ctx context.Context) []float64
- func (s *CounterSelect) Int(ctx context.Context) (_ int, err error)
- func (s *CounterSelect) IntX(ctx context.Context) int
- func (s *CounterSelect) Ints(ctx context.Context) ([]int, error)
- func (s *CounterSelect) IntsX(ctx context.Context) []int
- func (cs *CounterSelect) Scan(ctx context.Context, v any) error
- func (s *CounterSelect) ScanX(ctx context.Context, v any)
- func (s *CounterSelect) String(ctx context.Context) (_ string, err error)
- func (s *CounterSelect) StringX(ctx context.Context) string
- func (s *CounterSelect) Strings(ctx context.Context) ([]string, error)
- func (s *CounterSelect) StringsX(ctx context.Context) []string
- type CounterUpdate
- func (cu *CounterUpdate) AddValue(i int64) *CounterUpdate
- func (cu *CounterUpdate) Exec(ctx context.Context) error
- func (cu *CounterUpdate) ExecX(ctx context.Context)
- func (cu *CounterUpdate) Mutation() *CounterMutation
- func (cu *CounterUpdate) Save(ctx context.Context) (int, error)
- func (cu *CounterUpdate) SaveX(ctx context.Context) int
- func (cu *CounterUpdate) SetNillableValue(i *int64) *CounterUpdate
- func (cu *CounterUpdate) SetValue(i int64) *CounterUpdate
- func (cu *CounterUpdate) Where(ps ...predicate.Counter) *CounterUpdate
- type CounterUpdateOne
- func (cuo *CounterUpdateOne) AddValue(i int64) *CounterUpdateOne
- func (cuo *CounterUpdateOne) Exec(ctx context.Context) error
- func (cuo *CounterUpdateOne) ExecX(ctx context.Context)
- func (cuo *CounterUpdateOne) Mutation() *CounterMutation
- func (cuo *CounterUpdateOne) Save(ctx context.Context) (*Counter, error)
- func (cuo *CounterUpdateOne) SaveX(ctx context.Context) *Counter
- func (cuo *CounterUpdateOne) Select(field string, fields ...string) *CounterUpdateOne
- func (cuo *CounterUpdateOne) SetNillableValue(i *int64) *CounterUpdateOne
- func (cuo *CounterUpdateOne) SetValue(i int64) *CounterUpdateOne
- func (cuo *CounterUpdateOne) Where(ps ...predicate.Counter) *CounterUpdateOne
- type Counters
- type Hook
- 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. TypeCounter = "Counter" )
Variables ¶
var ErrTxStarted = errors.New("ent: 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(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 // Counter is the client for interacting with the Counter builders. Counter *CounterClient // 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(). Counter. 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 Counter ¶
type Counter struct { // ID of the ent. ID string `json:"id,omitempty"` // Value holds the value of the "value" field. Value int64 `json:"value,omitempty"` // contains filtered or unexported fields }
Counter is the model entity for the Counter schema.
func (*Counter) GetValue ¶
GetValue returns the ent.Value that was dynamically selected and assigned to the Counter. This includes values selected through modifiers, order, etc.
func (*Counter) Unwrap ¶
Unwrap unwraps the Counter 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 (*Counter) Update ¶
func (c *Counter) Update() *CounterUpdateOne
Update returns a builder for updating this Counter. Note that you need to call Counter.Unwrap() before calling this method if this Counter was returned from a transaction, and the transaction was committed or rolled back.
type CounterClient ¶
type CounterClient struct {
// contains filtered or unexported fields
}
CounterClient is a client for the Counter schema.
func NewCounterClient ¶
func NewCounterClient(c config) *CounterClient
NewCounterClient returns a client for the Counter from the given config.
func (*CounterClient) Create ¶
func (c *CounterClient) Create() *CounterCreate
Create returns a builder for creating a Counter entity.
func (*CounterClient) CreateBulk ¶
func (c *CounterClient) CreateBulk(builders ...*CounterCreate) *CounterCreateBulk
CreateBulk returns a builder for creating a bulk of Counter entities.
func (*CounterClient) Delete ¶
func (c *CounterClient) Delete() *CounterDelete
Delete returns a delete builder for Counter.
func (*CounterClient) DeleteOne ¶
func (c *CounterClient) DeleteOne(co *Counter) *CounterDeleteOne
DeleteOne returns a builder for deleting the given entity.
func (*CounterClient) DeleteOneID ¶
func (c *CounterClient) DeleteOneID(id string) *CounterDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
func (*CounterClient) GetX ¶
func (c *CounterClient) GetX(ctx context.Context, id string) *Counter
GetX is like Get, but panics if an error occurs.
func (*CounterClient) Hooks ¶
func (c *CounterClient) Hooks() []Hook
Hooks returns the client hooks.
func (*CounterClient) Intercept ¶
func (c *CounterClient) Intercept(interceptors ...Interceptor)
Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `counter.Intercept(f(g(h())))`.
func (*CounterClient) Interceptors ¶
func (c *CounterClient) Interceptors() []Interceptor
Interceptors returns the client interceptors.
func (*CounterClient) MapCreateBulk ¶
func (c *CounterClient) MapCreateBulk(slice any, setFunc func(*CounterCreate, int)) *CounterCreateBulk
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 (*CounterClient) Query ¶
func (c *CounterClient) Query() *CounterQuery
Query returns a query builder for Counter.
func (*CounterClient) Update ¶
func (c *CounterClient) Update() *CounterUpdate
Update returns an update builder for Counter.
func (*CounterClient) UpdateOne ¶
func (c *CounterClient) UpdateOne(co *Counter) *CounterUpdateOne
UpdateOne returns an update builder for the given entity.
func (*CounterClient) UpdateOneID ¶
func (c *CounterClient) UpdateOneID(id string) *CounterUpdateOne
UpdateOneID returns an update builder for the given id.
func (*CounterClient) Use ¶
func (c *CounterClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `counter.Hooks(f(g(h())))`.
type CounterCreate ¶
type CounterCreate struct {
// contains filtered or unexported fields
}
CounterCreate is the builder for creating a Counter entity.
func (*CounterCreate) Exec ¶
func (cc *CounterCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*CounterCreate) ExecX ¶
func (cc *CounterCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CounterCreate) Mutation ¶
func (cc *CounterCreate) Mutation() *CounterMutation
Mutation returns the CounterMutation object of the builder.
func (*CounterCreate) Save ¶
func (cc *CounterCreate) Save(ctx context.Context) (*Counter, error)
Save creates the Counter in the database.
func (*CounterCreate) SaveX ¶
func (cc *CounterCreate) SaveX(ctx context.Context) *Counter
SaveX calls Save and panics if Save returns an error.
func (*CounterCreate) SetID ¶
func (cc *CounterCreate) SetID(s string) *CounterCreate
SetID sets the "id" field.
func (*CounterCreate) SetValue ¶
func (cc *CounterCreate) SetValue(i int64) *CounterCreate
SetValue sets the "value" field.
type CounterCreateBulk ¶
type CounterCreateBulk struct {
// contains filtered or unexported fields
}
CounterCreateBulk is the builder for creating many Counter entities in bulk.
func (*CounterCreateBulk) Exec ¶
func (ccb *CounterCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*CounterCreateBulk) ExecX ¶
func (ccb *CounterCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type CounterDelete ¶
type CounterDelete struct {
// contains filtered or unexported fields
}
CounterDelete is the builder for deleting a Counter entity.
func (*CounterDelete) Exec ¶
func (cd *CounterDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*CounterDelete) ExecX ¶
func (cd *CounterDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*CounterDelete) Where ¶
func (cd *CounterDelete) Where(ps ...predicate.Counter) *CounterDelete
Where appends a list predicates to the CounterDelete builder.
type CounterDeleteOne ¶
type CounterDeleteOne struct {
// contains filtered or unexported fields
}
CounterDeleteOne is the builder for deleting a single Counter entity.
func (*CounterDeleteOne) Exec ¶
func (cdo *CounterDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*CounterDeleteOne) ExecX ¶
func (cdo *CounterDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CounterDeleteOne) Where ¶
func (cdo *CounterDeleteOne) Where(ps ...predicate.Counter) *CounterDeleteOne
Where appends a list predicates to the CounterDelete builder.
type CounterGroupBy ¶
type CounterGroupBy struct {
// contains filtered or unexported fields
}
CounterGroupBy is the group-by builder for Counter entities.
func (*CounterGroupBy) Aggregate ¶
func (cgb *CounterGroupBy) Aggregate(fns ...AggregateFunc) *CounterGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*CounterGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*CounterGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*CounterGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*CounterGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*CounterGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*CounterGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*CounterGroupBy) Scan ¶
func (cgb *CounterGroupBy) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*CounterGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type CounterMutation ¶
type CounterMutation struct {
// contains filtered or unexported fields
}
CounterMutation represents an operation that mutates the Counter nodes in the graph.
func (*CounterMutation) AddField ¶
func (m *CounterMutation) 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 (*CounterMutation) AddValue ¶
func (m *CounterMutation) AddValue(i int64)
AddValue adds i to the "value" field.
func (*CounterMutation) AddedEdges ¶
func (m *CounterMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*CounterMutation) AddedField ¶
func (m *CounterMutation) 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 (*CounterMutation) AddedFields ¶
func (m *CounterMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*CounterMutation) AddedIDs ¶
func (m *CounterMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*CounterMutation) AddedValue ¶
func (m *CounterMutation) AddedValue() (r int64, exists bool)
AddedValue returns the value that was added to the "value" field in this mutation.
func (*CounterMutation) ClearEdge ¶
func (m *CounterMutation) 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 (*CounterMutation) ClearField ¶
func (m *CounterMutation) 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 (*CounterMutation) ClearedEdges ¶
func (m *CounterMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*CounterMutation) ClearedFields ¶
func (m *CounterMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (CounterMutation) Client ¶
func (m CounterMutation) 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 (*CounterMutation) EdgeCleared ¶
func (m *CounterMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*CounterMutation) Field ¶
func (m *CounterMutation) 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 (*CounterMutation) FieldCleared ¶
func (m *CounterMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*CounterMutation) Fields ¶
func (m *CounterMutation) 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 (*CounterMutation) ID ¶
func (m *CounterMutation) ID() (id string, 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 (*CounterMutation) IDs ¶
func (m *CounterMutation) IDs(ctx context.Context) ([]string, 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 (*CounterMutation) 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 (*CounterMutation) OldValue ¶
func (m *CounterMutation) OldValue(ctx context.Context) (v int64, err error)
OldValue returns the old "value" field's value of the Counter entity. If the Counter 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 (*CounterMutation) RemovedEdges ¶
func (m *CounterMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*CounterMutation) RemovedIDs ¶
func (m *CounterMutation) 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 (*CounterMutation) ResetEdge ¶
func (m *CounterMutation) 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 (*CounterMutation) ResetField ¶
func (m *CounterMutation) 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 (*CounterMutation) ResetValue ¶
func (m *CounterMutation) ResetValue()
ResetValue resets all changes to the "value" field.
func (*CounterMutation) SetField ¶
func (m *CounterMutation) 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 (*CounterMutation) SetID ¶
func (m *CounterMutation) SetID(id string)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Counter entities.
func (*CounterMutation) SetOp ¶
func (m *CounterMutation) SetOp(op Op)
SetOp allows setting the mutation operation.
func (*CounterMutation) SetValue ¶
func (m *CounterMutation) SetValue(i int64)
SetValue sets the "value" field.
func (CounterMutation) Tx ¶
func (m CounterMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*CounterMutation) Type ¶
func (m *CounterMutation) Type() string
Type returns the node type of this mutation (Counter).
func (*CounterMutation) Value ¶
func (m *CounterMutation) Value() (r int64, exists bool)
Value returns the value of the "value" field in the mutation.
func (*CounterMutation) Where ¶
func (m *CounterMutation) Where(ps ...predicate.Counter)
Where appends a list predicates to the CounterMutation builder.
func (*CounterMutation) WhereP ¶
func (m *CounterMutation) WhereP(ps ...func(*sql.Selector))
WhereP appends storage-level predicates to the CounterMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.
type CounterQuery ¶
type CounterQuery struct {
// contains filtered or unexported fields
}
CounterQuery is the builder for querying Counter entities.
func (*CounterQuery) Aggregate ¶
func (cq *CounterQuery) Aggregate(fns ...AggregateFunc) *CounterSelect
Aggregate returns a CounterSelect configured with the given aggregations.
func (*CounterQuery) All ¶
func (cq *CounterQuery) All(ctx context.Context) ([]*Counter, error)
All executes the query and returns a list of Counters.
func (*CounterQuery) AllX ¶
func (cq *CounterQuery) AllX(ctx context.Context) []*Counter
AllX is like All, but panics if an error occurs.
func (*CounterQuery) Clone ¶
func (cq *CounterQuery) Clone() *CounterQuery
Clone returns a duplicate of the CounterQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*CounterQuery) Count ¶
func (cq *CounterQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*CounterQuery) CountX ¶
func (cq *CounterQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*CounterQuery) Exist ¶
func (cq *CounterQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*CounterQuery) ExistX ¶
func (cq *CounterQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*CounterQuery) First ¶
func (cq *CounterQuery) First(ctx context.Context) (*Counter, error)
First returns the first Counter entity from the query. Returns a *NotFoundError when no Counter was found.
func (*CounterQuery) FirstID ¶
func (cq *CounterQuery) FirstID(ctx context.Context) (id string, err error)
FirstID returns the first Counter ID from the query. Returns a *NotFoundError when no Counter ID was found.
func (*CounterQuery) FirstIDX ¶
func (cq *CounterQuery) FirstIDX(ctx context.Context) string
FirstIDX is like FirstID, but panics if an error occurs.
func (*CounterQuery) FirstX ¶
func (cq *CounterQuery) FirstX(ctx context.Context) *Counter
FirstX is like First, but panics if an error occurs.
func (*CounterQuery) GroupBy ¶
func (cq *CounterQuery) GroupBy(field string, fields ...string) *CounterGroupBy
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 { Value int64 `json:"value,omitempty"` Count int `json:"count,omitempty"` } client.Counter.Query(). GroupBy(counter.FieldValue). Aggregate(ent.Count()). Scan(ctx, &v)
func (*CounterQuery) IDs ¶
func (cq *CounterQuery) IDs(ctx context.Context) (ids []string, err error)
IDs executes the query and returns a list of Counter IDs.
func (*CounterQuery) IDsX ¶
func (cq *CounterQuery) IDsX(ctx context.Context) []string
IDsX is like IDs, but panics if an error occurs.
func (*CounterQuery) Limit ¶
func (cq *CounterQuery) Limit(limit int) *CounterQuery
Limit the number of records to be returned by this query.
func (*CounterQuery) Offset ¶
func (cq *CounterQuery) Offset(offset int) *CounterQuery
Offset to start from.
func (*CounterQuery) Only ¶
func (cq *CounterQuery) Only(ctx context.Context) (*Counter, error)
Only returns a single Counter entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Counter entity is found. Returns a *NotFoundError when no Counter entities are found.
func (*CounterQuery) OnlyID ¶
func (cq *CounterQuery) OnlyID(ctx context.Context) (id string, err error)
OnlyID is like Only, but returns the only Counter ID in the query. Returns a *NotSingularError when more than one Counter ID is found. Returns a *NotFoundError when no entities are found.
func (*CounterQuery) OnlyIDX ¶
func (cq *CounterQuery) OnlyIDX(ctx context.Context) string
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*CounterQuery) OnlyX ¶
func (cq *CounterQuery) OnlyX(ctx context.Context) *Counter
OnlyX is like Only, but panics if an error occurs.
func (*CounterQuery) Order ¶
func (cq *CounterQuery) Order(o ...counter.OrderOption) *CounterQuery
Order specifies how the records should be ordered.
func (*CounterQuery) Select ¶
func (cq *CounterQuery) Select(fields ...string) *CounterSelect
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 { Value int64 `json:"value,omitempty"` } client.Counter.Query(). Select(counter.FieldValue). Scan(ctx, &v)
func (*CounterQuery) Unique ¶
func (cq *CounterQuery) Unique(unique bool) *CounterQuery
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 (*CounterQuery) Where ¶
func (cq *CounterQuery) Where(ps ...predicate.Counter) *CounterQuery
Where adds a new predicate for the CounterQuery builder.
type CounterSelect ¶
type CounterSelect struct { *CounterQuery // contains filtered or unexported fields }
CounterSelect is the builder for selecting fields of Counter entities.
func (*CounterSelect) Aggregate ¶
func (cs *CounterSelect) Aggregate(fns ...AggregateFunc) *CounterSelect
Aggregate adds the given aggregation functions to the selector query.
func (*CounterSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*CounterSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*CounterSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*CounterSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*CounterSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*CounterSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*CounterSelect) Scan ¶
func (cs *CounterSelect) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*CounterSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type CounterUpdate ¶
type CounterUpdate struct {
// contains filtered or unexported fields
}
CounterUpdate is the builder for updating Counter entities.
func (*CounterUpdate) AddValue ¶
func (cu *CounterUpdate) AddValue(i int64) *CounterUpdate
AddValue adds i to the "value" field.
func (*CounterUpdate) Exec ¶
func (cu *CounterUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*CounterUpdate) ExecX ¶
func (cu *CounterUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CounterUpdate) Mutation ¶
func (cu *CounterUpdate) Mutation() *CounterMutation
Mutation returns the CounterMutation object of the builder.
func (*CounterUpdate) Save ¶
func (cu *CounterUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*CounterUpdate) SaveX ¶
func (cu *CounterUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*CounterUpdate) SetNillableValue ¶
func (cu *CounterUpdate) SetNillableValue(i *int64) *CounterUpdate
SetNillableValue sets the "value" field if the given value is not nil.
func (*CounterUpdate) SetValue ¶
func (cu *CounterUpdate) SetValue(i int64) *CounterUpdate
SetValue sets the "value" field.
func (*CounterUpdate) Where ¶
func (cu *CounterUpdate) Where(ps ...predicate.Counter) *CounterUpdate
Where appends a list predicates to the CounterUpdate builder.
type CounterUpdateOne ¶
type CounterUpdateOne struct {
// contains filtered or unexported fields
}
CounterUpdateOne is the builder for updating a single Counter entity.
func (*CounterUpdateOne) AddValue ¶
func (cuo *CounterUpdateOne) AddValue(i int64) *CounterUpdateOne
AddValue adds i to the "value" field.
func (*CounterUpdateOne) Exec ¶
func (cuo *CounterUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*CounterUpdateOne) ExecX ¶
func (cuo *CounterUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CounterUpdateOne) Mutation ¶
func (cuo *CounterUpdateOne) Mutation() *CounterMutation
Mutation returns the CounterMutation object of the builder.
func (*CounterUpdateOne) Save ¶
func (cuo *CounterUpdateOne) Save(ctx context.Context) (*Counter, error)
Save executes the query and returns the updated Counter entity.
func (*CounterUpdateOne) SaveX ¶
func (cuo *CounterUpdateOne) SaveX(ctx context.Context) *Counter
SaveX is like Save, but panics if an error occurs.
func (*CounterUpdateOne) Select ¶
func (cuo *CounterUpdateOne) Select(field string, fields ...string) *CounterUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*CounterUpdateOne) SetNillableValue ¶
func (cuo *CounterUpdateOne) SetNillableValue(i *int64) *CounterUpdateOne
SetNillableValue sets the "value" field if the given value is not nil.
func (*CounterUpdateOne) SetValue ¶
func (cuo *CounterUpdateOne) SetValue(i int64) *CounterUpdateOne
SetValue sets the "value" field.
func (*CounterUpdateOne) Where ¶
func (cuo *CounterUpdateOne) Where(ps ...predicate.Counter) *CounterUpdateOne
Where appends a list predicates to the CounterUpdate 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 { // Counter is the client for interacting with the Counter builders. Counter *CounterClient // 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.