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 Link
- type LinkClient
- func (c *LinkClient) Create() *LinkCreate
- func (c *LinkClient) CreateBulk(builders ...*LinkCreate) *LinkCreateBulk
- func (c *LinkClient) Delete() *LinkDelete
- func (c *LinkClient) DeleteOne(l *Link) *LinkDeleteOne
- func (c *LinkClient) DeleteOneID(id int) *LinkDeleteOne
- func (c *LinkClient) Get(ctx context.Context, id int) (*Link, error)
- func (c *LinkClient) GetX(ctx context.Context, id int) *Link
- func (c *LinkClient) Hooks() []Hook
- func (c *LinkClient) Query() *LinkQuery
- func (c *LinkClient) Update() *LinkUpdate
- func (c *LinkClient) UpdateOne(l *Link) *LinkUpdateOne
- func (c *LinkClient) UpdateOneID(id int) *LinkUpdateOne
- func (c *LinkClient) Use(hooks ...Hook)
- type LinkCreate
- func (lc *LinkCreate) Exec(ctx context.Context) error
- func (lc *LinkCreate) ExecX(ctx context.Context)
- func (lc *LinkCreate) Mutation() *LinkMutation
- func (lc *LinkCreate) Save(ctx context.Context) (*Link, error)
- func (lc *LinkCreate) SaveX(ctx context.Context) *Link
- func (lc *LinkCreate) SetCreatedAt(t time.Time) *LinkCreate
- func (lc *LinkCreate) SetLink(s string) *LinkCreate
- func (lc *LinkCreate) SetNillableCreatedAt(t *time.Time) *LinkCreate
- func (lc *LinkCreate) SetTarget(s string) *LinkCreate
- type LinkCreateBulk
- type LinkDelete
- type LinkDeleteOne
- type LinkGroupBy
- func (lgb *LinkGroupBy) Aggregate(fns ...AggregateFunc) *LinkGroupBy
- func (lgb *LinkGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (lgb *LinkGroupBy) BoolX(ctx context.Context) bool
- func (lgb *LinkGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (lgb *LinkGroupBy) BoolsX(ctx context.Context) []bool
- func (lgb *LinkGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (lgb *LinkGroupBy) Float64X(ctx context.Context) float64
- func (lgb *LinkGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (lgb *LinkGroupBy) Float64sX(ctx context.Context) []float64
- func (lgb *LinkGroupBy) Int(ctx context.Context) (_ int, err error)
- func (lgb *LinkGroupBy) IntX(ctx context.Context) int
- func (lgb *LinkGroupBy) Ints(ctx context.Context) ([]int, error)
- func (lgb *LinkGroupBy) IntsX(ctx context.Context) []int
- func (lgb *LinkGroupBy) Scan(ctx context.Context, v interface{}) error
- func (lgb *LinkGroupBy) ScanX(ctx context.Context, v interface{})
- func (lgb *LinkGroupBy) String(ctx context.Context) (_ string, err error)
- func (lgb *LinkGroupBy) StringX(ctx context.Context) string
- func (lgb *LinkGroupBy) Strings(ctx context.Context) ([]string, error)
- func (lgb *LinkGroupBy) StringsX(ctx context.Context) []string
- type LinkMutation
- func (m *LinkMutation) AddField(name string, value ent.Value) error
- func (m *LinkMutation) AddedEdges() []string
- func (m *LinkMutation) AddedField(name string) (ent.Value, bool)
- func (m *LinkMutation) AddedFields() []string
- func (m *LinkMutation) AddedIDs(name string) []ent.Value
- func (m *LinkMutation) ClearEdge(name string) error
- func (m *LinkMutation) ClearField(name string) error
- func (m *LinkMutation) ClearedEdges() []string
- func (m *LinkMutation) ClearedFields() []string
- func (m LinkMutation) Client() *Client
- func (m *LinkMutation) CreatedAt() (r time.Time, exists bool)
- func (m *LinkMutation) EdgeCleared(name string) bool
- func (m *LinkMutation) Field(name string) (ent.Value, bool)
- func (m *LinkMutation) FieldCleared(name string) bool
- func (m *LinkMutation) Fields() []string
- func (m *LinkMutation) ID() (id int, exists bool)
- func (m *LinkMutation) IDs(ctx context.Context) ([]int, error)
- func (m *LinkMutation) Link() (r string, exists bool)
- func (m *LinkMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)
- func (m *LinkMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *LinkMutation) OldLink(ctx context.Context) (v string, err error)
- func (m *LinkMutation) OldTarget(ctx context.Context) (v string, err error)
- func (m *LinkMutation) Op() Op
- func (m *LinkMutation) RemovedEdges() []string
- func (m *LinkMutation) RemovedIDs(name string) []ent.Value
- func (m *LinkMutation) ResetCreatedAt()
- func (m *LinkMutation) ResetEdge(name string) error
- func (m *LinkMutation) ResetField(name string) error
- func (m *LinkMutation) ResetLink()
- func (m *LinkMutation) ResetTarget()
- func (m *LinkMutation) SetCreatedAt(t time.Time)
- func (m *LinkMutation) SetField(name string, value ent.Value) error
- func (m *LinkMutation) SetLink(s string)
- func (m *LinkMutation) SetTarget(s string)
- func (m *LinkMutation) Target() (r string, exists bool)
- func (m LinkMutation) Tx() (*Tx, error)
- func (m *LinkMutation) Type() string
- func (m *LinkMutation) Where(ps ...predicate.Link)
- type LinkQuery
- func (lq *LinkQuery) All(ctx context.Context) ([]*Link, error)
- func (lq *LinkQuery) AllX(ctx context.Context) []*Link
- func (lq *LinkQuery) Clone() *LinkQuery
- func (lq *LinkQuery) Count(ctx context.Context) (int, error)
- func (lq *LinkQuery) CountX(ctx context.Context) int
- func (lq *LinkQuery) Exist(ctx context.Context) (bool, error)
- func (lq *LinkQuery) ExistX(ctx context.Context) bool
- func (lq *LinkQuery) First(ctx context.Context) (*Link, error)
- func (lq *LinkQuery) FirstID(ctx context.Context) (id int, err error)
- func (lq *LinkQuery) FirstIDX(ctx context.Context) int
- func (lq *LinkQuery) FirstX(ctx context.Context) *Link
- func (lq *LinkQuery) GroupBy(field string, fields ...string) *LinkGroupBy
- func (lq *LinkQuery) IDs(ctx context.Context) ([]int, error)
- func (lq *LinkQuery) IDsX(ctx context.Context) []int
- func (lq *LinkQuery) Limit(limit int) *LinkQuery
- func (lq *LinkQuery) Offset(offset int) *LinkQuery
- func (lq *LinkQuery) Only(ctx context.Context) (*Link, error)
- func (lq *LinkQuery) OnlyID(ctx context.Context) (id int, err error)
- func (lq *LinkQuery) OnlyIDX(ctx context.Context) int
- func (lq *LinkQuery) OnlyX(ctx context.Context) *Link
- func (lq *LinkQuery) Order(o ...OrderFunc) *LinkQuery
- func (lq *LinkQuery) Select(fields ...string) *LinkSelect
- func (lq *LinkQuery) Unique(unique bool) *LinkQuery
- func (lq *LinkQuery) Where(ps ...predicate.Link) *LinkQuery
- type LinkSelect
- func (ls *LinkSelect) Bool(ctx context.Context) (_ bool, err error)
- func (ls *LinkSelect) BoolX(ctx context.Context) bool
- func (ls *LinkSelect) Bools(ctx context.Context) ([]bool, error)
- func (ls *LinkSelect) BoolsX(ctx context.Context) []bool
- func (ls *LinkSelect) Float64(ctx context.Context) (_ float64, err error)
- func (ls *LinkSelect) Float64X(ctx context.Context) float64
- func (ls *LinkSelect) Float64s(ctx context.Context) ([]float64, error)
- func (ls *LinkSelect) Float64sX(ctx context.Context) []float64
- func (ls *LinkSelect) Int(ctx context.Context) (_ int, err error)
- func (ls *LinkSelect) IntX(ctx context.Context) int
- func (ls *LinkSelect) Ints(ctx context.Context) ([]int, error)
- func (ls *LinkSelect) IntsX(ctx context.Context) []int
- func (ls *LinkSelect) Scan(ctx context.Context, v interface{}) error
- func (ls *LinkSelect) ScanX(ctx context.Context, v interface{})
- func (ls *LinkSelect) String(ctx context.Context) (_ string, err error)
- func (ls *LinkSelect) StringX(ctx context.Context) string
- func (ls *LinkSelect) Strings(ctx context.Context) ([]string, error)
- func (ls *LinkSelect) StringsX(ctx context.Context) []string
- type LinkUpdate
- func (lu *LinkUpdate) Exec(ctx context.Context) error
- func (lu *LinkUpdate) ExecX(ctx context.Context)
- func (lu *LinkUpdate) Mutation() *LinkMutation
- func (lu *LinkUpdate) Save(ctx context.Context) (int, error)
- func (lu *LinkUpdate) SaveX(ctx context.Context) int
- func (lu *LinkUpdate) SetCreatedAt(t time.Time) *LinkUpdate
- func (lu *LinkUpdate) SetLink(s string) *LinkUpdate
- func (lu *LinkUpdate) SetNillableCreatedAt(t *time.Time) *LinkUpdate
- func (lu *LinkUpdate) SetTarget(s string) *LinkUpdate
- func (lu *LinkUpdate) Where(ps ...predicate.Link) *LinkUpdate
- type LinkUpdateOne
- func (luo *LinkUpdateOne) Exec(ctx context.Context) error
- func (luo *LinkUpdateOne) ExecX(ctx context.Context)
- func (luo *LinkUpdateOne) Mutation() *LinkMutation
- func (luo *LinkUpdateOne) Save(ctx context.Context) (*Link, error)
- func (luo *LinkUpdateOne) SaveX(ctx context.Context) *Link
- func (luo *LinkUpdateOne) Select(field string, fields ...string) *LinkUpdateOne
- func (luo *LinkUpdateOne) SetCreatedAt(t time.Time) *LinkUpdateOne
- func (luo *LinkUpdateOne) SetLink(s string) *LinkUpdateOne
- func (luo *LinkUpdateOne) SetNillableCreatedAt(t *time.Time) *LinkUpdateOne
- func (luo *LinkUpdateOne) SetTarget(s string) *LinkUpdateOne
- type Links
- type MutateFunc
- type Mutation
- type Mutator
- 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. TypeLink = "Link" )
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
// Link is the client for interacting with the Link builders.
Link *LinkClient
// 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(). Link. 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 Link ¶
type Link struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// Link holds the value of the "link" field.
Link string `json:"link,omitempty"`
// Target holds the value of the "target" field.
Target string `json:"target,omitempty"`
// CreatedAt holds the value of the "createdAt" field.
CreatedAt time.Time `json:"createdAt,omitempty"`
// contains filtered or unexported fields
}
Link is the model entity for the Link schema.
func (*Link) Unwrap ¶
Unwrap unwraps the Link 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 (*Link) Update ¶
func (l *Link) Update() *LinkUpdateOne
Update returns a builder for updating this Link. Note that you need to call Link.Unwrap() before calling this method if this Link was returned from a transaction, and the transaction was committed or rolled back.
type LinkClient ¶
type LinkClient struct {
// contains filtered or unexported fields
}
LinkClient is a client for the Link schema.
func NewLinkClient ¶
func NewLinkClient(c config) *LinkClient
NewLinkClient returns a client for the Link from the given config.
func (*LinkClient) Create ¶
func (c *LinkClient) Create() *LinkCreate
Create returns a create builder for Link.
func (*LinkClient) CreateBulk ¶
func (c *LinkClient) CreateBulk(builders ...*LinkCreate) *LinkCreateBulk
CreateBulk returns a builder for creating a bulk of Link entities.
func (*LinkClient) Delete ¶
func (c *LinkClient) Delete() *LinkDelete
Delete returns a delete builder for Link.
func (*LinkClient) DeleteOne ¶
func (c *LinkClient) DeleteOne(l *Link) *LinkDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*LinkClient) DeleteOneID ¶
func (c *LinkClient) DeleteOneID(id int) *LinkDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*LinkClient) GetX ¶
func (c *LinkClient) GetX(ctx context.Context, id int) *Link
GetX is like Get, but panics if an error occurs.
func (*LinkClient) Query ¶
func (c *LinkClient) Query() *LinkQuery
Query returns a query builder for Link.
func (*LinkClient) Update ¶
func (c *LinkClient) Update() *LinkUpdate
Update returns an update builder for Link.
func (*LinkClient) UpdateOne ¶
func (c *LinkClient) UpdateOne(l *Link) *LinkUpdateOne
UpdateOne returns an update builder for the given entity.
func (*LinkClient) UpdateOneID ¶
func (c *LinkClient) UpdateOneID(id int) *LinkUpdateOne
UpdateOneID returns an update builder for the given id.
func (*LinkClient) Use ¶
func (c *LinkClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `link.Hooks(f(g(h())))`.
type LinkCreate ¶
type LinkCreate struct {
// contains filtered or unexported fields
}
LinkCreate is the builder for creating a Link entity.
func (*LinkCreate) Exec ¶
func (lc *LinkCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*LinkCreate) ExecX ¶
func (lc *LinkCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*LinkCreate) Mutation ¶
func (lc *LinkCreate) Mutation() *LinkMutation
Mutation returns the LinkMutation object of the builder.
func (*LinkCreate) Save ¶
func (lc *LinkCreate) Save(ctx context.Context) (*Link, error)
Save creates the Link in the database.
func (*LinkCreate) SaveX ¶
func (lc *LinkCreate) SaveX(ctx context.Context) *Link
SaveX calls Save and panics if Save returns an error.
func (*LinkCreate) SetCreatedAt ¶
func (lc *LinkCreate) SetCreatedAt(t time.Time) *LinkCreate
SetCreatedAt sets the "createdAt" field.
func (*LinkCreate) SetLink ¶
func (lc *LinkCreate) SetLink(s string) *LinkCreate
SetLink sets the "link" field.
func (*LinkCreate) SetNillableCreatedAt ¶
func (lc *LinkCreate) SetNillableCreatedAt(t *time.Time) *LinkCreate
SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
func (*LinkCreate) SetTarget ¶
func (lc *LinkCreate) SetTarget(s string) *LinkCreate
SetTarget sets the "target" field.
type LinkCreateBulk ¶
type LinkCreateBulk struct {
// contains filtered or unexported fields
}
LinkCreateBulk is the builder for creating many Link entities in bulk.
func (*LinkCreateBulk) Exec ¶
func (lcb *LinkCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*LinkCreateBulk) ExecX ¶
func (lcb *LinkCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type LinkDelete ¶
type LinkDelete struct {
// contains filtered or unexported fields
}
LinkDelete is the builder for deleting a Link entity.
func (*LinkDelete) Exec ¶
func (ld *LinkDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*LinkDelete) ExecX ¶
func (ld *LinkDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*LinkDelete) Where ¶
func (ld *LinkDelete) Where(ps ...predicate.Link) *LinkDelete
Where appends a list predicates to the LinkDelete builder.
type LinkDeleteOne ¶
type LinkDeleteOne struct {
// contains filtered or unexported fields
}
LinkDeleteOne is the builder for deleting a single Link entity.
func (*LinkDeleteOne) Exec ¶
func (ldo *LinkDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*LinkDeleteOne) ExecX ¶
func (ldo *LinkDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type LinkGroupBy ¶
type LinkGroupBy struct {
// contains filtered or unexported fields
}
LinkGroupBy is the group-by builder for Link entities.
func (*LinkGroupBy) Aggregate ¶
func (lgb *LinkGroupBy) Aggregate(fns ...AggregateFunc) *LinkGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*LinkGroupBy) Bool ¶
func (lgb *LinkGroupBy) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.
func (*LinkGroupBy) BoolX ¶
func (lgb *LinkGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*LinkGroupBy) Bools ¶
func (lgb *LinkGroupBy) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.
func (*LinkGroupBy) BoolsX ¶
func (lgb *LinkGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*LinkGroupBy) Float64 ¶
func (lgb *LinkGroupBy) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.
func (*LinkGroupBy) Float64X ¶
func (lgb *LinkGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*LinkGroupBy) Float64s ¶
func (lgb *LinkGroupBy) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.
func (*LinkGroupBy) Float64sX ¶
func (lgb *LinkGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*LinkGroupBy) Int ¶
func (lgb *LinkGroupBy) Int(ctx context.Context) (_ int, err error)
Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.
func (*LinkGroupBy) IntX ¶
func (lgb *LinkGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*LinkGroupBy) Ints ¶
func (lgb *LinkGroupBy) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.
func (*LinkGroupBy) IntsX ¶
func (lgb *LinkGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*LinkGroupBy) Scan ¶
func (lgb *LinkGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*LinkGroupBy) ScanX ¶
func (lgb *LinkGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*LinkGroupBy) String ¶
func (lgb *LinkGroupBy) String(ctx context.Context) (_ string, err error)
String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.
func (*LinkGroupBy) StringX ¶
func (lgb *LinkGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type LinkMutation ¶
type LinkMutation struct {
// contains filtered or unexported fields
}
LinkMutation represents an operation that mutates the Link nodes in the graph.
func (*LinkMutation) AddField ¶
func (m *LinkMutation) 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 (*LinkMutation) AddedEdges ¶
func (m *LinkMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*LinkMutation) AddedField ¶
func (m *LinkMutation) 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 (*LinkMutation) AddedFields ¶
func (m *LinkMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*LinkMutation) AddedIDs ¶
func (m *LinkMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*LinkMutation) ClearEdge ¶
func (m *LinkMutation) 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 (*LinkMutation) ClearField ¶
func (m *LinkMutation) 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 (*LinkMutation) ClearedEdges ¶
func (m *LinkMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*LinkMutation) ClearedFields ¶
func (m *LinkMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (LinkMutation) Client ¶
func (m LinkMutation) 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 (*LinkMutation) CreatedAt ¶
func (m *LinkMutation) CreatedAt() (r time.Time, exists bool)
CreatedAt returns the value of the "createdAt" field in the mutation.
func (*LinkMutation) EdgeCleared ¶
func (m *LinkMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*LinkMutation) Field ¶
func (m *LinkMutation) 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 (*LinkMutation) FieldCleared ¶
func (m *LinkMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*LinkMutation) Fields ¶
func (m *LinkMutation) 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 (*LinkMutation) ID ¶
func (m *LinkMutation) 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 (*LinkMutation) IDs ¶
func (m *LinkMutation) 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 (*LinkMutation) Link ¶
func (m *LinkMutation) Link() (r string, exists bool)
Link returns the value of the "link" field in the mutation.
func (*LinkMutation) OldCreatedAt ¶
OldCreatedAt returns the old "createdAt" field's value of the Link entity. If the Link 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 (*LinkMutation) 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 (*LinkMutation) OldLink ¶
func (m *LinkMutation) OldLink(ctx context.Context) (v string, err error)
OldLink returns the old "link" field's value of the Link entity. If the Link 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 (*LinkMutation) OldTarget ¶
func (m *LinkMutation) OldTarget(ctx context.Context) (v string, err error)
OldTarget returns the old "target" field's value of the Link entity. If the Link 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 (*LinkMutation) RemovedEdges ¶
func (m *LinkMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*LinkMutation) RemovedIDs ¶
func (m *LinkMutation) 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 (*LinkMutation) ResetCreatedAt ¶
func (m *LinkMutation) ResetCreatedAt()
ResetCreatedAt resets all changes to the "createdAt" field.
func (*LinkMutation) ResetEdge ¶
func (m *LinkMutation) 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 (*LinkMutation) ResetField ¶
func (m *LinkMutation) 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 (*LinkMutation) ResetLink ¶
func (m *LinkMutation) ResetLink()
ResetLink resets all changes to the "link" field.
func (*LinkMutation) ResetTarget ¶
func (m *LinkMutation) ResetTarget()
ResetTarget resets all changes to the "target" field.
func (*LinkMutation) SetCreatedAt ¶
func (m *LinkMutation) SetCreatedAt(t time.Time)
SetCreatedAt sets the "createdAt" field.
func (*LinkMutation) SetField ¶
func (m *LinkMutation) 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 (*LinkMutation) SetLink ¶
func (m *LinkMutation) SetLink(s string)
SetLink sets the "link" field.
func (*LinkMutation) SetTarget ¶
func (m *LinkMutation) SetTarget(s string)
SetTarget sets the "target" field.
func (*LinkMutation) Target ¶
func (m *LinkMutation) Target() (r string, exists bool)
Target returns the value of the "target" field in the mutation.
func (LinkMutation) Tx ¶
func (m LinkMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*LinkMutation) Type ¶
func (m *LinkMutation) Type() string
Type returns the node type of this mutation (Link).
func (*LinkMutation) Where ¶
func (m *LinkMutation) Where(ps ...predicate.Link)
Where appends a list predicates to the LinkMutation builder.
type LinkQuery ¶
type LinkQuery struct {
// contains filtered or unexported fields
}
LinkQuery is the builder for querying Link entities.
func (*LinkQuery) Clone ¶
Clone returns a duplicate of the LinkQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*LinkQuery) First ¶
First returns the first Link entity from the query. Returns a *NotFoundError when no Link was found.
func (*LinkQuery) FirstID ¶
FirstID returns the first Link ID from the query. Returns a *NotFoundError when no Link ID was found.
func (*LinkQuery) GroupBy ¶
func (lq *LinkQuery) GroupBy(field string, fields ...string) *LinkGroupBy
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 {
Link string `json:"link,omitempty"`
Count int `json:"count,omitempty"`
}
client.Link.Query().
GroupBy(link.FieldLink).
Aggregate(ent.Count()).
Scan(ctx, &v)
func (*LinkQuery) Only ¶
Only returns a single Link entity found by the query, ensuring it only returns one. Returns a *NotSingularError when exactly one Link entity is not found. Returns a *NotFoundError when no Link entities are found.
func (*LinkQuery) OnlyID ¶
OnlyID is like Only, but returns the only Link ID in the query. Returns a *NotSingularError when exactly one Link ID is not found. Returns a *NotFoundError when no entities are found.
func (*LinkQuery) Select ¶
func (lq *LinkQuery) Select(fields ...string) *LinkSelect
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 {
Link string `json:"link,omitempty"`
}
client.Link.Query().
Select(link.FieldLink).
Scan(ctx, &v)
type LinkSelect ¶
type LinkSelect struct {
*LinkQuery
// contains filtered or unexported fields
}
LinkSelect is the builder for selecting fields of Link entities.
func (*LinkSelect) Bool ¶
func (ls *LinkSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*LinkSelect) BoolX ¶
func (ls *LinkSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*LinkSelect) Bools ¶
func (ls *LinkSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*LinkSelect) BoolsX ¶
func (ls *LinkSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*LinkSelect) Float64 ¶
func (ls *LinkSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*LinkSelect) Float64X ¶
func (ls *LinkSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*LinkSelect) Float64s ¶
func (ls *LinkSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*LinkSelect) Float64sX ¶
func (ls *LinkSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*LinkSelect) Int ¶
func (ls *LinkSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*LinkSelect) IntX ¶
func (ls *LinkSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*LinkSelect) Ints ¶
func (ls *LinkSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*LinkSelect) IntsX ¶
func (ls *LinkSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*LinkSelect) Scan ¶
func (ls *LinkSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*LinkSelect) ScanX ¶
func (ls *LinkSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*LinkSelect) String ¶
func (ls *LinkSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from a selector. It is only allowed when selecting one field.
func (*LinkSelect) StringX ¶
func (ls *LinkSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type LinkUpdate ¶
type LinkUpdate struct {
// contains filtered or unexported fields
}
LinkUpdate is the builder for updating Link entities.
func (*LinkUpdate) Exec ¶
func (lu *LinkUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*LinkUpdate) ExecX ¶
func (lu *LinkUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*LinkUpdate) Mutation ¶
func (lu *LinkUpdate) Mutation() *LinkMutation
Mutation returns the LinkMutation object of the builder.
func (*LinkUpdate) Save ¶
func (lu *LinkUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*LinkUpdate) SaveX ¶
func (lu *LinkUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*LinkUpdate) SetCreatedAt ¶
func (lu *LinkUpdate) SetCreatedAt(t time.Time) *LinkUpdate
SetCreatedAt sets the "createdAt" field.
func (*LinkUpdate) SetLink ¶
func (lu *LinkUpdate) SetLink(s string) *LinkUpdate
SetLink sets the "link" field.
func (*LinkUpdate) SetNillableCreatedAt ¶
func (lu *LinkUpdate) SetNillableCreatedAt(t *time.Time) *LinkUpdate
SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
func (*LinkUpdate) SetTarget ¶
func (lu *LinkUpdate) SetTarget(s string) *LinkUpdate
SetTarget sets the "target" field.
func (*LinkUpdate) Where ¶
func (lu *LinkUpdate) Where(ps ...predicate.Link) *LinkUpdate
Where appends a list predicates to the LinkUpdate builder.
type LinkUpdateOne ¶
type LinkUpdateOne struct {
// contains filtered or unexported fields
}
LinkUpdateOne is the builder for updating a single Link entity.
func (*LinkUpdateOne) Exec ¶
func (luo *LinkUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*LinkUpdateOne) ExecX ¶
func (luo *LinkUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*LinkUpdateOne) Mutation ¶
func (luo *LinkUpdateOne) Mutation() *LinkMutation
Mutation returns the LinkMutation object of the builder.
func (*LinkUpdateOne) Save ¶
func (luo *LinkUpdateOne) Save(ctx context.Context) (*Link, error)
Save executes the query and returns the updated Link entity.
func (*LinkUpdateOne) SaveX ¶
func (luo *LinkUpdateOne) SaveX(ctx context.Context) *Link
SaveX is like Save, but panics if an error occurs.
func (*LinkUpdateOne) Select ¶
func (luo *LinkUpdateOne) Select(field string, fields ...string) *LinkUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*LinkUpdateOne) SetCreatedAt ¶
func (luo *LinkUpdateOne) SetCreatedAt(t time.Time) *LinkUpdateOne
SetCreatedAt sets the "createdAt" field.
func (*LinkUpdateOne) SetLink ¶
func (luo *LinkUpdateOne) SetLink(s string) *LinkUpdateOne
SetLink sets the "link" field.
func (*LinkUpdateOne) SetNillableCreatedAt ¶
func (luo *LinkUpdateOne) SetNillableCreatedAt(t *time.Time) *LinkUpdateOne
SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
func (*LinkUpdateOne) SetTarget ¶
func (luo *LinkUpdateOne) SetTarget(s string) *LinkUpdateOne
SetTarget sets the "target" 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 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 {
// Link is the client for interacting with the Link builders.
Link *LinkClient
// 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.