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 Hook
- type MutateFunc
- type Mutation
- type Mutator
- type Node
- type NodeClient
- func (c *NodeClient) Create() *NodeCreate
- func (c *NodeClient) CreateBulk(builders ...*NodeCreate) *NodeCreateBulk
- func (c *NodeClient) Delete() *NodeDelete
- func (c *NodeClient) DeleteOne(n *Node) *NodeDeleteOne
- func (c *NodeClient) DeleteOneID(id int) *NodeDeleteOne
- func (c *NodeClient) Get(ctx context.Context, id int) (*Node, error)
- func (c *NodeClient) GetX(ctx context.Context, id int) *Node
- func (c *NodeClient) Hooks() []Hook
- func (c *NodeClient) Query() *NodeQuery
- func (c *NodeClient) QueryNext(n *Node) *NodeQuery
- func (c *NodeClient) QueryPrev(n *Node) *NodeQuery
- func (c *NodeClient) Update() *NodeUpdate
- func (c *NodeClient) UpdateOne(n *Node) *NodeUpdateOne
- func (c *NodeClient) UpdateOneID(id int) *NodeUpdateOne
- func (c *NodeClient) Use(hooks ...Hook)
- type NodeCreate
- func (nc *NodeCreate) Mutation() *NodeMutation
- func (nc *NodeCreate) Save(ctx context.Context) (*Node, error)
- func (nc *NodeCreate) SaveX(ctx context.Context) *Node
- func (nc *NodeCreate) SetNext(n *Node) *NodeCreate
- func (nc *NodeCreate) SetNextID(id int) *NodeCreate
- func (nc *NodeCreate) SetNillableNextID(id *int) *NodeCreate
- func (nc *NodeCreate) SetNillablePrevID(id *int) *NodeCreate
- func (nc *NodeCreate) SetPrev(n *Node) *NodeCreate
- func (nc *NodeCreate) SetPrevID(id int) *NodeCreate
- func (nc *NodeCreate) SetValue(i int) *NodeCreate
- type NodeCreateBulk
- type NodeDelete
- type NodeDeleteOne
- type NodeEdges
- type NodeGroupBy
- func (ngb *NodeGroupBy) Aggregate(fns ...AggregateFunc) *NodeGroupBy
- func (ngb *NodeGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (ngb *NodeGroupBy) BoolX(ctx context.Context) bool
- func (ngb *NodeGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (ngb *NodeGroupBy) BoolsX(ctx context.Context) []bool
- func (ngb *NodeGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (ngb *NodeGroupBy) Float64X(ctx context.Context) float64
- func (ngb *NodeGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (ngb *NodeGroupBy) Float64sX(ctx context.Context) []float64
- func (ngb *NodeGroupBy) Int(ctx context.Context) (_ int, err error)
- func (ngb *NodeGroupBy) IntX(ctx context.Context) int
- func (ngb *NodeGroupBy) Ints(ctx context.Context) ([]int, error)
- func (ngb *NodeGroupBy) IntsX(ctx context.Context) []int
- func (ngb *NodeGroupBy) Scan(ctx context.Context, v interface{}) error
- func (ngb *NodeGroupBy) ScanX(ctx context.Context, v interface{})
- func (ngb *NodeGroupBy) String(ctx context.Context) (_ string, err error)
- func (ngb *NodeGroupBy) StringX(ctx context.Context) string
- func (ngb *NodeGroupBy) Strings(ctx context.Context) ([]string, error)
- func (ngb *NodeGroupBy) StringsX(ctx context.Context) []string
- type NodeMutation
- func (m *NodeMutation) AddField(name string, value ent.Value) error
- func (m *NodeMutation) AddValue(i int)
- func (m *NodeMutation) AddedEdges() []string
- func (m *NodeMutation) AddedField(name string) (ent.Value, bool)
- func (m *NodeMutation) AddedFields() []string
- func (m *NodeMutation) AddedIDs(name string) []ent.Value
- func (m *NodeMutation) AddedValue() (r int, exists bool)
- func (m *NodeMutation) ClearEdge(name string) error
- func (m *NodeMutation) ClearField(name string) error
- func (m *NodeMutation) ClearNext()
- func (m *NodeMutation) ClearPrev()
- func (m *NodeMutation) ClearedEdges() []string
- func (m *NodeMutation) ClearedFields() []string
- func (m NodeMutation) Client() *Client
- func (m *NodeMutation) EdgeCleared(name string) bool
- func (m *NodeMutation) Field(name string) (ent.Value, bool)
- func (m *NodeMutation) FieldCleared(name string) bool
- func (m *NodeMutation) Fields() []string
- func (m *NodeMutation) ID() (id int, exists bool)
- func (m *NodeMutation) NextCleared() bool
- func (m *NodeMutation) NextID() (id int, exists bool)
- func (m *NodeMutation) NextIDs() (ids []int)
- func (m *NodeMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *NodeMutation) OldValue(ctx context.Context) (v int, err error)
- func (m *NodeMutation) Op() Op
- func (m *NodeMutation) PrevCleared() bool
- func (m *NodeMutation) PrevID() (id int, exists bool)
- func (m *NodeMutation) PrevIDs() (ids []int)
- func (m *NodeMutation) RemovedEdges() []string
- func (m *NodeMutation) RemovedIDs(name string) []ent.Value
- func (m *NodeMutation) ResetEdge(name string) error
- func (m *NodeMutation) ResetField(name string) error
- func (m *NodeMutation) ResetNext()
- func (m *NodeMutation) ResetPrev()
- func (m *NodeMutation) ResetValue()
- func (m *NodeMutation) SetField(name string, value ent.Value) error
- func (m *NodeMutation) SetNextID(id int)
- func (m *NodeMutation) SetPrevID(id int)
- func (m *NodeMutation) SetValue(i int)
- func (m NodeMutation) Tx() (*Tx, error)
- func (m *NodeMutation) Type() string
- func (m *NodeMutation) Value() (r int, exists bool)
- type NodeQuery
- func (nq *NodeQuery) All(ctx context.Context) ([]*Node, error)
- func (nq *NodeQuery) AllX(ctx context.Context) []*Node
- func (nq *NodeQuery) Clone() *NodeQuery
- func (nq *NodeQuery) Count(ctx context.Context) (int, error)
- func (nq *NodeQuery) CountX(ctx context.Context) int
- func (nq *NodeQuery) Exist(ctx context.Context) (bool, error)
- func (nq *NodeQuery) ExistX(ctx context.Context) bool
- func (nq *NodeQuery) First(ctx context.Context) (*Node, error)
- func (nq *NodeQuery) FirstID(ctx context.Context) (id int, err error)
- func (nq *NodeQuery) FirstIDX(ctx context.Context) int
- func (nq *NodeQuery) FirstX(ctx context.Context) *Node
- func (nq *NodeQuery) GroupBy(field string, fields ...string) *NodeGroupBy
- func (nq *NodeQuery) IDs(ctx context.Context) ([]int, error)
- func (nq *NodeQuery) IDsX(ctx context.Context) []int
- func (nq *NodeQuery) Limit(limit int) *NodeQuery
- func (nq *NodeQuery) Offset(offset int) *NodeQuery
- func (nq *NodeQuery) Only(ctx context.Context) (*Node, error)
- func (nq *NodeQuery) OnlyID(ctx context.Context) (id int, err error)
- func (nq *NodeQuery) OnlyIDX(ctx context.Context) int
- func (nq *NodeQuery) OnlyX(ctx context.Context) *Node
- func (nq *NodeQuery) Order(o ...OrderFunc) *NodeQuery
- func (nq *NodeQuery) QueryNext() *NodeQuery
- func (nq *NodeQuery) QueryPrev() *NodeQuery
- func (nq *NodeQuery) Select(field string, fields ...string) *NodeSelect
- func (nq *NodeQuery) Where(ps ...predicate.Node) *NodeQuery
- func (nq *NodeQuery) WithNext(opts ...func(*NodeQuery)) *NodeQuery
- func (nq *NodeQuery) WithPrev(opts ...func(*NodeQuery)) *NodeQuery
- type NodeSelect
- func (ns *NodeSelect) Bool(ctx context.Context) (_ bool, err error)
- func (ns *NodeSelect) BoolX(ctx context.Context) bool
- func (ns *NodeSelect) Bools(ctx context.Context) ([]bool, error)
- func (ns *NodeSelect) BoolsX(ctx context.Context) []bool
- func (ns *NodeSelect) Float64(ctx context.Context) (_ float64, err error)
- func (ns *NodeSelect) Float64X(ctx context.Context) float64
- func (ns *NodeSelect) Float64s(ctx context.Context) ([]float64, error)
- func (ns *NodeSelect) Float64sX(ctx context.Context) []float64
- func (ns *NodeSelect) Int(ctx context.Context) (_ int, err error)
- func (ns *NodeSelect) IntX(ctx context.Context) int
- func (ns *NodeSelect) Ints(ctx context.Context) ([]int, error)
- func (ns *NodeSelect) IntsX(ctx context.Context) []int
- func (ns *NodeSelect) Scan(ctx context.Context, v interface{}) error
- func (ns *NodeSelect) ScanX(ctx context.Context, v interface{})
- func (ns *NodeSelect) String(ctx context.Context) (_ string, err error)
- func (ns *NodeSelect) StringX(ctx context.Context) string
- func (ns *NodeSelect) Strings(ctx context.Context) ([]string, error)
- func (ns *NodeSelect) StringsX(ctx context.Context) []string
- type NodeUpdate
- func (nu *NodeUpdate) AddValue(i int) *NodeUpdate
- func (nu *NodeUpdate) ClearNext() *NodeUpdate
- func (nu *NodeUpdate) ClearPrev() *NodeUpdate
- func (nu *NodeUpdate) Exec(ctx context.Context) error
- func (nu *NodeUpdate) ExecX(ctx context.Context)
- func (nu *NodeUpdate) Mutation() *NodeMutation
- func (nu *NodeUpdate) Save(ctx context.Context) (int, error)
- func (nu *NodeUpdate) SaveX(ctx context.Context) int
- func (nu *NodeUpdate) SetNext(n *Node) *NodeUpdate
- func (nu *NodeUpdate) SetNextID(id int) *NodeUpdate
- func (nu *NodeUpdate) SetNillableNextID(id *int) *NodeUpdate
- func (nu *NodeUpdate) SetNillablePrevID(id *int) *NodeUpdate
- func (nu *NodeUpdate) SetPrev(n *Node) *NodeUpdate
- func (nu *NodeUpdate) SetPrevID(id int) *NodeUpdate
- func (nu *NodeUpdate) SetValue(i int) *NodeUpdate
- func (nu *NodeUpdate) Where(ps ...predicate.Node) *NodeUpdate
- type NodeUpdateOne
- func (nuo *NodeUpdateOne) AddValue(i int) *NodeUpdateOne
- func (nuo *NodeUpdateOne) ClearNext() *NodeUpdateOne
- func (nuo *NodeUpdateOne) ClearPrev() *NodeUpdateOne
- func (nuo *NodeUpdateOne) Exec(ctx context.Context) error
- func (nuo *NodeUpdateOne) ExecX(ctx context.Context)
- func (nuo *NodeUpdateOne) Mutation() *NodeMutation
- func (nuo *NodeUpdateOne) Save(ctx context.Context) (*Node, error)
- func (nuo *NodeUpdateOne) SaveX(ctx context.Context) *Node
- func (nuo *NodeUpdateOne) SetNext(n *Node) *NodeUpdateOne
- func (nuo *NodeUpdateOne) SetNextID(id int) *NodeUpdateOne
- func (nuo *NodeUpdateOne) SetNillableNextID(id *int) *NodeUpdateOne
- func (nuo *NodeUpdateOne) SetNillablePrevID(id *int) *NodeUpdateOne
- func (nuo *NodeUpdateOne) SetPrev(n *Node) *NodeUpdateOne
- func (nuo *NodeUpdateOne) SetPrevID(id int) *NodeUpdateOne
- func (nuo *NodeUpdateOne) SetValue(i int) *NodeUpdateOne
- type Nodes
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- 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. TypeNode = "Node" )
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 validaton 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 // Node is the client for interacting with the Node builders. Node *NodeClient // contains filtered or unexported fields }
Client is the client that holds all ent builders.
func FromContext ¶
FromContext returns the Client stored in 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(). Node. 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(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 MutateFunc ¶
type MutateFunc = ent.MutateFunc
ent aliases to avoid import conflict in user's code.
type Node ¶
type Node struct { // ID of the ent. ID int `json:"id,omitempty"` // Value holds the value of the "value" field. Value int `json:"value,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the NodeQuery when eager-loading is set. Edges NodeEdges `json:"edges"` // contains filtered or unexported fields }
Node is the model entity for the Node schema.
func (*Node) Unwrap ¶
Unwrap unwraps the entity that was returned from a transaction after it was closed, so that all next queries will be executed through the driver which created the transaction.
func (*Node) Update ¶
func (n *Node) Update() *NodeUpdateOne
Update returns a builder for updating this Node. Note that, you need to call Node.Unwrap() before calling this method, if this Node was returned from a transaction, and the transaction was committed or rolled back.
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
NodeClient is a client for the Node schema.
func NewNodeClient ¶
func NewNodeClient(c config) *NodeClient
NewNodeClient returns a client for the Node from the given config.
func (*NodeClient) Create ¶
func (c *NodeClient) Create() *NodeCreate
Create returns a create builder for Node.
func (*NodeClient) CreateBulk ¶
func (c *NodeClient) CreateBulk(builders ...*NodeCreate) *NodeCreateBulk
CreateBulk returns a builder for creating a bulk of Node entities.
func (*NodeClient) Delete ¶
func (c *NodeClient) Delete() *NodeDelete
Delete returns a delete builder for Node.
func (*NodeClient) DeleteOne ¶
func (c *NodeClient) DeleteOne(n *Node) *NodeDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*NodeClient) DeleteOneID ¶
func (c *NodeClient) DeleteOneID(id int) *NodeDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*NodeClient) GetX ¶
func (c *NodeClient) GetX(ctx context.Context, id int) *Node
GetX is like Get, but panics if an error occurs.
func (*NodeClient) Query ¶
func (c *NodeClient) Query() *NodeQuery
Query returns a query builder for Node.
func (*NodeClient) QueryNext ¶
func (c *NodeClient) QueryNext(n *Node) *NodeQuery
QueryNext queries the next edge of a Node.
func (*NodeClient) QueryPrev ¶
func (c *NodeClient) QueryPrev(n *Node) *NodeQuery
QueryPrev queries the prev edge of a Node.
func (*NodeClient) Update ¶
func (c *NodeClient) Update() *NodeUpdate
Update returns an update builder for Node.
func (*NodeClient) UpdateOne ¶
func (c *NodeClient) UpdateOne(n *Node) *NodeUpdateOne
UpdateOne returns an update builder for the given entity.
func (*NodeClient) UpdateOneID ¶
func (c *NodeClient) UpdateOneID(id int) *NodeUpdateOne
UpdateOneID returns an update builder for the given id.
func (*NodeClient) Use ¶
func (c *NodeClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `node.Hooks(f(g(h())))`.
type NodeCreate ¶
type NodeCreate struct {
// contains filtered or unexported fields
}
NodeCreate is the builder for creating a Node entity.
func (*NodeCreate) Mutation ¶
func (nc *NodeCreate) Mutation() *NodeMutation
Mutation returns the NodeMutation object of the builder.
func (*NodeCreate) Save ¶
func (nc *NodeCreate) Save(ctx context.Context) (*Node, error)
Save creates the Node in the database.
func (*NodeCreate) SaveX ¶
func (nc *NodeCreate) SaveX(ctx context.Context) *Node
SaveX calls Save and panics if Save returns an error.
func (*NodeCreate) SetNext ¶
func (nc *NodeCreate) SetNext(n *Node) *NodeCreate
SetNext sets the next edge to Node.
func (*NodeCreate) SetNextID ¶
func (nc *NodeCreate) SetNextID(id int) *NodeCreate
SetNextID sets the next edge to Node by id.
func (*NodeCreate) SetNillableNextID ¶
func (nc *NodeCreate) SetNillableNextID(id *int) *NodeCreate
SetNillableNextID sets the next edge to Node by id if the given value is not nil.
func (*NodeCreate) SetNillablePrevID ¶
func (nc *NodeCreate) SetNillablePrevID(id *int) *NodeCreate
SetNillablePrevID sets the prev edge to Node by id if the given value is not nil.
func (*NodeCreate) SetPrev ¶
func (nc *NodeCreate) SetPrev(n *Node) *NodeCreate
SetPrev sets the prev edge to Node.
func (*NodeCreate) SetPrevID ¶
func (nc *NodeCreate) SetPrevID(id int) *NodeCreate
SetPrevID sets the prev edge to Node by id.
func (*NodeCreate) SetValue ¶
func (nc *NodeCreate) SetValue(i int) *NodeCreate
SetValue sets the value field.
type NodeCreateBulk ¶
type NodeCreateBulk struct {
// contains filtered or unexported fields
}
NodeCreateBulk is the builder for creating a bulk of Node entities.
type NodeDelete ¶
type NodeDelete struct {
// contains filtered or unexported fields
}
NodeDelete is the builder for deleting a Node entity.
func (*NodeDelete) Exec ¶
func (nd *NodeDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*NodeDelete) ExecX ¶
func (nd *NodeDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*NodeDelete) Where ¶
func (nd *NodeDelete) Where(ps ...predicate.Node) *NodeDelete
Where adds a new predicate to the delete builder.
type NodeDeleteOne ¶
type NodeDeleteOne struct {
// contains filtered or unexported fields
}
NodeDeleteOne is the builder for deleting a single Node entity.
func (*NodeDeleteOne) Exec ¶
func (ndo *NodeDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*NodeDeleteOne) ExecX ¶
func (ndo *NodeDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type NodeEdges ¶
type NodeEdges struct { // Prev holds the value of the prev edge. Prev *Node // Next holds the value of the next edge. Next *Node // contains filtered or unexported fields }
NodeEdges holds the relations/edges for other nodes in the graph.
type NodeGroupBy ¶
type NodeGroupBy struct {
// contains filtered or unexported fields
}
NodeGroupBy is the builder for group-by Node entities.
func (*NodeGroupBy) Aggregate ¶
func (ngb *NodeGroupBy) Aggregate(fns ...AggregateFunc) *NodeGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*NodeGroupBy) Bool ¶
func (ngb *NodeGroupBy) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
func (*NodeGroupBy) BoolX ¶
func (ngb *NodeGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*NodeGroupBy) Bools ¶
func (ngb *NodeGroupBy) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
func (*NodeGroupBy) BoolsX ¶
func (ngb *NodeGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*NodeGroupBy) Float64 ¶
func (ngb *NodeGroupBy) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
func (*NodeGroupBy) Float64X ¶
func (ngb *NodeGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*NodeGroupBy) Float64s ¶
func (ngb *NodeGroupBy) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
func (*NodeGroupBy) Float64sX ¶
func (ngb *NodeGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*NodeGroupBy) Int ¶
func (ngb *NodeGroupBy) Int(ctx context.Context) (_ int, err error)
Int returns a single int from group-by. It is only allowed when querying group-by with one field.
func (*NodeGroupBy) IntX ¶
func (ngb *NodeGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*NodeGroupBy) Ints ¶
func (ngb *NodeGroupBy) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
func (*NodeGroupBy) IntsX ¶
func (ngb *NodeGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*NodeGroupBy) Scan ¶
func (ngb *NodeGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scan the result into the given value.
func (*NodeGroupBy) ScanX ¶
func (ngb *NodeGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*NodeGroupBy) String ¶
func (ngb *NodeGroupBy) String(ctx context.Context) (_ string, err error)
String returns a single string from group-by. It is only allowed when querying group-by with one field.
func (*NodeGroupBy) StringX ¶
func (ngb *NodeGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type NodeMutation ¶
type NodeMutation struct {
// contains filtered or unexported fields
}
NodeMutation represents an operation that mutate the Nodes nodes in the graph.
func (*NodeMutation) AddField ¶
func (m *NodeMutation) AddField(name string, value ent.Value) error
AddField adds the value for the given name. It returns an error if the field is not defined in the schema, or if the type mismatch the field type.
func (*NodeMutation) AddedEdges ¶
func (m *NodeMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*NodeMutation) AddedField ¶
func (m *NodeMutation) AddedField(name string) (ent.Value, bool)
AddedField returns the numeric value that was in/decremented from a field with the given name. The second value indicates that this field was not set, or was not define in the schema.
func (*NodeMutation) AddedFields ¶
func (m *NodeMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented or decremented during this mutation.
func (*NodeMutation) AddedIDs ¶
func (m *NodeMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all ids (to other nodes) that were added for the given edge name.
func (*NodeMutation) AddedValue ¶
func (m *NodeMutation) AddedValue() (r int, exists bool)
AddedValue returns the value that was added to the value field in this mutation.
func (*NodeMutation) ClearEdge ¶
func (m *NodeMutation) ClearEdge(name string) error
ClearEdge clears the value for the given name. It returns an error if the edge name is not defined in the schema.
func (*NodeMutation) ClearField ¶
func (m *NodeMutation) ClearField(name string) error
ClearField clears the value for the given name. It returns an error if the field is not defined in the schema.
func (*NodeMutation) ClearNext ¶
func (m *NodeMutation) ClearNext()
ClearNext clears the next edge to Node.
func (*NodeMutation) ClearPrev ¶
func (m *NodeMutation) ClearPrev()
ClearPrev clears the prev edge to Node.
func (*NodeMutation) ClearedEdges ¶
func (m *NodeMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*NodeMutation) ClearedFields ¶
func (m *NodeMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (NodeMutation) Client ¶
func (m NodeMutation) 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 (*NodeMutation) EdgeCleared ¶
func (m *NodeMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean indicates if this edge was cleared in this mutation.
func (*NodeMutation) Field ¶
func (m *NodeMutation) Field(name string) (ent.Value, bool)
Field returns the value of a field with the given name. The second boolean value indicates that this field was not set, or was not define in the schema.
func (*NodeMutation) FieldCleared ¶
func (m *NodeMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicates if this field was cleared in this mutation.
func (*NodeMutation) Fields ¶
func (m *NodeMutation) Fields() []string
Fields returns all fields that were changed during this mutation. Note that, in order to get all numeric fields that were in/decremented, call AddedFields().
func (*NodeMutation) ID ¶
func (m *NodeMutation) ID() (id int, exists bool)
ID returns the id value in the mutation. Note that, the id is available only if it was provided to the builder.
func (*NodeMutation) NextCleared ¶
func (m *NodeMutation) NextCleared() bool
NextCleared returns if the edge next was cleared.
func (*NodeMutation) NextID ¶
func (m *NodeMutation) NextID() (id int, exists bool)
NextID returns the next id in the mutation.
func (*NodeMutation) NextIDs ¶
func (m *NodeMutation) NextIDs() (ids []int)
NextIDs returns the next ids in the mutation. Note that ids always returns len(ids) <= 1 for unique edges, and you should use NextID instead. It exists only for internal usage by the builders.
func (*NodeMutation) 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 was failed.
func (*NodeMutation) OldValue ¶
func (m *NodeMutation) OldValue(ctx context.Context) (v int, err error)
OldValue returns the old value value of the Node. If the Node 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 database query fails.
func (*NodeMutation) PrevCleared ¶
func (m *NodeMutation) PrevCleared() bool
PrevCleared returns if the edge prev was cleared.
func (*NodeMutation) PrevID ¶
func (m *NodeMutation) PrevID() (id int, exists bool)
PrevID returns the prev id in the mutation.
func (*NodeMutation) PrevIDs ¶
func (m *NodeMutation) PrevIDs() (ids []int)
PrevIDs returns the prev ids in the mutation. Note that ids always returns len(ids) <= 1 for unique edges, and you should use PrevID instead. It exists only for internal usage by the builders.
func (*NodeMutation) RemovedEdges ¶
func (m *NodeMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*NodeMutation) RemovedIDs ¶
func (m *NodeMutation) RemovedIDs(name string) []ent.Value
RemovedIDs returns all ids (to other nodes) that were removed for the given edge name.
func (*NodeMutation) ResetEdge ¶
func (m *NodeMutation) ResetEdge(name string) error
ResetEdge resets all changes in the mutation regarding the given edge name. It returns an error if the edge is not defined in the schema.
func (*NodeMutation) ResetField ¶
func (m *NodeMutation) ResetField(name string) error
ResetField resets all changes in the mutation regarding the given field name. It returns an error if the field is not defined in the schema.
func (*NodeMutation) ResetNext ¶
func (m *NodeMutation) ResetNext()
ResetNext reset all changes of the "next" edge.
func (*NodeMutation) ResetPrev ¶
func (m *NodeMutation) ResetPrev()
ResetPrev reset all changes of the "prev" edge.
func (*NodeMutation) ResetValue ¶
func (m *NodeMutation) ResetValue()
ResetValue reset all changes of the "value" field.
func (*NodeMutation) SetField ¶
func (m *NodeMutation) SetField(name string, value ent.Value) error
SetField sets the value for the given name. It returns an error if the field is not defined in the schema, or if the type mismatch the field type.
func (*NodeMutation) SetNextID ¶
func (m *NodeMutation) SetNextID(id int)
SetNextID sets the next edge to Node by id.
func (*NodeMutation) SetPrevID ¶
func (m *NodeMutation) SetPrevID(id int)
SetPrevID sets the prev edge to Node by id.
func (*NodeMutation) SetValue ¶
func (m *NodeMutation) SetValue(i int)
SetValue sets the value field.
func (NodeMutation) Tx ¶
func (m NodeMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*NodeMutation) Type ¶
func (m *NodeMutation) Type() string
Type returns the node type of this mutation (Node).
func (*NodeMutation) Value ¶
func (m *NodeMutation) Value() (r int, exists bool)
Value returns the value value in the mutation.
type NodeQuery ¶
type NodeQuery struct {
// contains filtered or unexported fields
}
NodeQuery is the builder for querying Node entities.
func (*NodeQuery) Clone ¶
Clone returns a duplicate of the query builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*NodeQuery) First ¶
First returns the first Node entity in the query. Returns *NotFoundError when no node was found.
func (*NodeQuery) FirstID ¶
FirstID returns the first Node id in the query. Returns *NotFoundError when no id was found.
func (*NodeQuery) FirstIDX ¶ added in v0.5.0
FirstIDX is like FirstID, but panics if an error occurs.
func (*NodeQuery) GroupBy ¶
func (nq *NodeQuery) GroupBy(field string, fields ...string) *NodeGroupBy
GroupBy 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 int `json:"value,omitempty"` Count int `json:"count,omitempty"` } client.Node.Query(). GroupBy(node.FieldValue). Aggregate(ent.Count()). Scan(ctx, &v)
func (*NodeQuery) Only ¶
Only returns the only Node entity in the query, returns an error if not exactly one entity was returned.
func (*NodeQuery) OnlyID ¶
OnlyID returns the only Node id in the query, returns an error if not exactly one id was returned.
func (*NodeQuery) Select ¶
func (nq *NodeQuery) Select(field string, fields ...string) *NodeSelect
Select one or more fields from the given query.
Example:
var v []struct { Value int `json:"value,omitempty"` } client.Node.Query(). Select(node.FieldValue). Scan(ctx, &v)
type NodeSelect ¶
type NodeSelect struct {
// contains filtered or unexported fields
}
NodeSelect is the builder for select fields of Node entities.
func (*NodeSelect) Bool ¶
func (ns *NodeSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from selector. It is only allowed when selecting one field.
func (*NodeSelect) BoolX ¶
func (ns *NodeSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*NodeSelect) Bools ¶
func (ns *NodeSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from selector. It is only allowed when selecting one field.
func (*NodeSelect) BoolsX ¶
func (ns *NodeSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*NodeSelect) Float64 ¶
func (ns *NodeSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from selector. It is only allowed when selecting one field.
func (*NodeSelect) Float64X ¶
func (ns *NodeSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*NodeSelect) Float64s ¶
func (ns *NodeSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from selector. It is only allowed when selecting one field.
func (*NodeSelect) Float64sX ¶
func (ns *NodeSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*NodeSelect) Int ¶
func (ns *NodeSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from selector. It is only allowed when selecting one field.
func (*NodeSelect) IntX ¶
func (ns *NodeSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*NodeSelect) Ints ¶
func (ns *NodeSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from selector. It is only allowed when selecting one field.
func (*NodeSelect) IntsX ¶
func (ns *NodeSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*NodeSelect) Scan ¶
func (ns *NodeSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scan the result into the given value.
func (*NodeSelect) ScanX ¶
func (ns *NodeSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*NodeSelect) String ¶
func (ns *NodeSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from selector. It is only allowed when selecting one field.
func (*NodeSelect) StringX ¶
func (ns *NodeSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type NodeUpdate ¶
type NodeUpdate struct {
// contains filtered or unexported fields
}
NodeUpdate is the builder for updating Node entities.
func (*NodeUpdate) AddValue ¶
func (nu *NodeUpdate) AddValue(i int) *NodeUpdate
AddValue adds i to value.
func (*NodeUpdate) ClearNext ¶
func (nu *NodeUpdate) ClearNext() *NodeUpdate
ClearNext clears the "next" edge to type Node.
func (*NodeUpdate) ClearPrev ¶
func (nu *NodeUpdate) ClearPrev() *NodeUpdate
ClearPrev clears the "prev" edge to type Node.
func (*NodeUpdate) Exec ¶
func (nu *NodeUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*NodeUpdate) ExecX ¶
func (nu *NodeUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*NodeUpdate) Mutation ¶
func (nu *NodeUpdate) Mutation() *NodeMutation
Mutation returns the NodeMutation object of the builder.
func (*NodeUpdate) Save ¶
func (nu *NodeUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*NodeUpdate) SaveX ¶
func (nu *NodeUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*NodeUpdate) SetNext ¶
func (nu *NodeUpdate) SetNext(n *Node) *NodeUpdate
SetNext sets the next edge to Node.
func (*NodeUpdate) SetNextID ¶
func (nu *NodeUpdate) SetNextID(id int) *NodeUpdate
SetNextID sets the next edge to Node by id.
func (*NodeUpdate) SetNillableNextID ¶
func (nu *NodeUpdate) SetNillableNextID(id *int) *NodeUpdate
SetNillableNextID sets the next edge to Node by id if the given value is not nil.
func (*NodeUpdate) SetNillablePrevID ¶
func (nu *NodeUpdate) SetNillablePrevID(id *int) *NodeUpdate
SetNillablePrevID sets the prev edge to Node by id if the given value is not nil.
func (*NodeUpdate) SetPrev ¶
func (nu *NodeUpdate) SetPrev(n *Node) *NodeUpdate
SetPrev sets the prev edge to Node.
func (*NodeUpdate) SetPrevID ¶
func (nu *NodeUpdate) SetPrevID(id int) *NodeUpdate
SetPrevID sets the prev edge to Node by id.
func (*NodeUpdate) SetValue ¶
func (nu *NodeUpdate) SetValue(i int) *NodeUpdate
SetValue sets the value field.
func (*NodeUpdate) Where ¶
func (nu *NodeUpdate) Where(ps ...predicate.Node) *NodeUpdate
Where adds a new predicate for the builder.
type NodeUpdateOne ¶
type NodeUpdateOne struct {
// contains filtered or unexported fields
}
NodeUpdateOne is the builder for updating a single Node entity.
func (*NodeUpdateOne) AddValue ¶
func (nuo *NodeUpdateOne) AddValue(i int) *NodeUpdateOne
AddValue adds i to value.
func (*NodeUpdateOne) ClearNext ¶
func (nuo *NodeUpdateOne) ClearNext() *NodeUpdateOne
ClearNext clears the "next" edge to type Node.
func (*NodeUpdateOne) ClearPrev ¶
func (nuo *NodeUpdateOne) ClearPrev() *NodeUpdateOne
ClearPrev clears the "prev" edge to type Node.
func (*NodeUpdateOne) Exec ¶
func (nuo *NodeUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*NodeUpdateOne) ExecX ¶
func (nuo *NodeUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*NodeUpdateOne) Mutation ¶
func (nuo *NodeUpdateOne) Mutation() *NodeMutation
Mutation returns the NodeMutation object of the builder.
func (*NodeUpdateOne) Save ¶
func (nuo *NodeUpdateOne) Save(ctx context.Context) (*Node, error)
Save executes the query and returns the updated entity.
func (*NodeUpdateOne) SaveX ¶
func (nuo *NodeUpdateOne) SaveX(ctx context.Context) *Node
SaveX is like Save, but panics if an error occurs.
func (*NodeUpdateOne) SetNext ¶
func (nuo *NodeUpdateOne) SetNext(n *Node) *NodeUpdateOne
SetNext sets the next edge to Node.
func (*NodeUpdateOne) SetNextID ¶
func (nuo *NodeUpdateOne) SetNextID(id int) *NodeUpdateOne
SetNextID sets the next edge to Node by id.
func (*NodeUpdateOne) SetNillableNextID ¶
func (nuo *NodeUpdateOne) SetNillableNextID(id *int) *NodeUpdateOne
SetNillableNextID sets the next edge to Node by id if the given value is not nil.
func (*NodeUpdateOne) SetNillablePrevID ¶
func (nuo *NodeUpdateOne) SetNillablePrevID(id *int) *NodeUpdateOne
SetNillablePrevID sets the prev edge to Node by id if the given value is not nil.
func (*NodeUpdateOne) SetPrev ¶
func (nuo *NodeUpdateOne) SetPrev(n *Node) *NodeUpdateOne
SetPrev sets the prev edge to Node.
func (*NodeUpdateOne) SetPrevID ¶
func (nuo *NodeUpdateOne) SetPrevID(id int) *NodeUpdateOne
SetPrevID sets the prev edge to Node by id.
func (*NodeUpdateOne) SetValue ¶
func (nuo *NodeUpdateOne) SetValue(i int) *NodeUpdateOne
SetValue sets the value field.
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 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(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 Rollbacker method.
type Tx ¶
type Tx struct { // Node is the client for interacting with the Node builders. Node *NodeClient // contains filtered or unexported fields }
Tx is a transactional client that is created by calling Client.Tx().
func TxFromContext ¶
TxFromContext returns the Tx stored in 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 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.