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 Code
- type CodeClient
- func (c *CodeClient) Create() *CodeCreate
- func (c *CodeClient) CreateBulk(builders ...*CodeCreate) *CodeCreateBulk
- func (c *CodeClient) Delete() *CodeDelete
- func (c *CodeClient) DeleteOne(co *Code) *CodeDeleteOne
- func (c *CodeClient) DeleteOneID(id uuid.UUID) *CodeDeleteOne
- func (c *CodeClient) Get(ctx context.Context, id uuid.UUID) (*Code, error)
- func (c *CodeClient) GetX(ctx context.Context, id uuid.UUID) *Code
- func (c *CodeClient) Hooks() []Hook
- func (c *CodeClient) Query() *CodeQuery
- func (c *CodeClient) Update() *CodeUpdate
- func (c *CodeClient) UpdateOne(co *Code) *CodeUpdateOne
- func (c *CodeClient) UpdateOneID(id uuid.UUID) *CodeUpdateOne
- func (c *CodeClient) Use(hooks ...Hook)
- type CodeCreate
- func (cc *CodeCreate) Exec(ctx context.Context) error
- func (cc *CodeCreate) ExecX(ctx context.Context)
- func (cc *CodeCreate) Mutation() *CodeMutation
- func (cc *CodeCreate) Save(ctx context.Context) (*Code, error)
- func (cc *CodeCreate) SaveX(ctx context.Context) *Code
- func (cc *CodeCreate) SetContents(s string) *CodeCreate
- func (cc *CodeCreate) SetID(u uuid.UUID) *CodeCreate
- func (cc *CodeCreate) SetNillableID(u *uuid.UUID) *CodeCreate
- type CodeCreateBulk
- type CodeDelete
- type CodeDeleteOne
- type CodeGroupBy
- func (cgb *CodeGroupBy) Aggregate(fns ...AggregateFunc) *CodeGroupBy
- func (cgb *CodeGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (cgb *CodeGroupBy) BoolX(ctx context.Context) bool
- func (cgb *CodeGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (cgb *CodeGroupBy) BoolsX(ctx context.Context) []bool
- func (cgb *CodeGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (cgb *CodeGroupBy) Float64X(ctx context.Context) float64
- func (cgb *CodeGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (cgb *CodeGroupBy) Float64sX(ctx context.Context) []float64
- func (cgb *CodeGroupBy) Int(ctx context.Context) (_ int, err error)
- func (cgb *CodeGroupBy) IntX(ctx context.Context) int
- func (cgb *CodeGroupBy) Ints(ctx context.Context) ([]int, error)
- func (cgb *CodeGroupBy) IntsX(ctx context.Context) []int
- func (cgb *CodeGroupBy) Scan(ctx context.Context, v interface{}) error
- func (cgb *CodeGroupBy) ScanX(ctx context.Context, v interface{})
- func (cgb *CodeGroupBy) String(ctx context.Context) (_ string, err error)
- func (cgb *CodeGroupBy) StringX(ctx context.Context) string
- func (cgb *CodeGroupBy) Strings(ctx context.Context) ([]string, error)
- func (cgb *CodeGroupBy) StringsX(ctx context.Context) []string
- type CodeMutation
- func (m *CodeMutation) AddField(name string, value ent.Value) error
- func (m *CodeMutation) AddedEdges() []string
- func (m *CodeMutation) AddedField(name string) (ent.Value, bool)
- func (m *CodeMutation) AddedFields() []string
- func (m *CodeMutation) AddedIDs(name string) []ent.Value
- func (m *CodeMutation) ClearEdge(name string) error
- func (m *CodeMutation) ClearField(name string) error
- func (m *CodeMutation) ClearedEdges() []string
- func (m *CodeMutation) ClearedFields() []string
- func (m CodeMutation) Client() *Client
- func (m *CodeMutation) Contents() (r string, exists bool)
- func (m *CodeMutation) EdgeCleared(name string) bool
- func (m *CodeMutation) Field(name string) (ent.Value, bool)
- func (m *CodeMutation) FieldCleared(name string) bool
- func (m *CodeMutation) Fields() []string
- func (m *CodeMutation) ID() (id uuid.UUID, exists bool)
- func (m *CodeMutation) IDs(ctx context.Context) ([]uuid.UUID, error)
- func (m *CodeMutation) OldContents(ctx context.Context) (v string, err error)
- func (m *CodeMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *CodeMutation) Op() Op
- func (m *CodeMutation) RemovedEdges() []string
- func (m *CodeMutation) RemovedIDs(name string) []ent.Value
- func (m *CodeMutation) ResetContents()
- func (m *CodeMutation) ResetEdge(name string) error
- func (m *CodeMutation) ResetField(name string) error
- func (m *CodeMutation) SetContents(s string)
- func (m *CodeMutation) SetField(name string, value ent.Value) error
- func (m *CodeMutation) SetID(id uuid.UUID)
- func (m CodeMutation) Tx() (*Tx, error)
- func (m *CodeMutation) Type() string
- func (m *CodeMutation) Where(ps ...predicate.Code)
- type CodeQuery
- func (cq *CodeQuery) All(ctx context.Context) ([]*Code, error)
- func (cq *CodeQuery) AllX(ctx context.Context) []*Code
- func (cq *CodeQuery) Clone() *CodeQuery
- func (cq *CodeQuery) Count(ctx context.Context) (int, error)
- func (cq *CodeQuery) CountX(ctx context.Context) int
- func (cq *CodeQuery) Exist(ctx context.Context) (bool, error)
- func (cq *CodeQuery) ExistX(ctx context.Context) bool
- func (cq *CodeQuery) First(ctx context.Context) (*Code, error)
- func (cq *CodeQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)
- func (cq *CodeQuery) FirstIDX(ctx context.Context) uuid.UUID
- func (cq *CodeQuery) FirstX(ctx context.Context) *Code
- func (cq *CodeQuery) GroupBy(field string, fields ...string) *CodeGroupBy
- func (cq *CodeQuery) IDs(ctx context.Context) ([]uuid.UUID, error)
- func (cq *CodeQuery) IDsX(ctx context.Context) []uuid.UUID
- func (cq *CodeQuery) Limit(limit int) *CodeQuery
- func (cq *CodeQuery) Offset(offset int) *CodeQuery
- func (cq *CodeQuery) Only(ctx context.Context) (*Code, error)
- func (cq *CodeQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)
- func (cq *CodeQuery) OnlyIDX(ctx context.Context) uuid.UUID
- func (cq *CodeQuery) OnlyX(ctx context.Context) *Code
- func (cq *CodeQuery) Order(o ...OrderFunc) *CodeQuery
- func (cq *CodeQuery) Select(fields ...string) *CodeSelect
- func (cq *CodeQuery) Unique(unique bool) *CodeQuery
- func (cq *CodeQuery) Where(ps ...predicate.Code) *CodeQuery
- type CodeSelect
- func (cs *CodeSelect) Bool(ctx context.Context) (_ bool, err error)
- func (cs *CodeSelect) BoolX(ctx context.Context) bool
- func (cs *CodeSelect) Bools(ctx context.Context) ([]bool, error)
- func (cs *CodeSelect) BoolsX(ctx context.Context) []bool
- func (cs *CodeSelect) Float64(ctx context.Context) (_ float64, err error)
- func (cs *CodeSelect) Float64X(ctx context.Context) float64
- func (cs *CodeSelect) Float64s(ctx context.Context) ([]float64, error)
- func (cs *CodeSelect) Float64sX(ctx context.Context) []float64
- func (cs *CodeSelect) Int(ctx context.Context) (_ int, err error)
- func (cs *CodeSelect) IntX(ctx context.Context) int
- func (cs *CodeSelect) Ints(ctx context.Context) ([]int, error)
- func (cs *CodeSelect) IntsX(ctx context.Context) []int
- func (cs *CodeSelect) Scan(ctx context.Context, v interface{}) error
- func (cs *CodeSelect) ScanX(ctx context.Context, v interface{})
- func (cs *CodeSelect) String(ctx context.Context) (_ string, err error)
- func (cs *CodeSelect) StringX(ctx context.Context) string
- func (cs *CodeSelect) Strings(ctx context.Context) ([]string, error)
- func (cs *CodeSelect) StringsX(ctx context.Context) []string
- type CodeUpdate
- func (cu *CodeUpdate) Exec(ctx context.Context) error
- func (cu *CodeUpdate) ExecX(ctx context.Context)
- func (cu *CodeUpdate) Mutation() *CodeMutation
- func (cu *CodeUpdate) Save(ctx context.Context) (int, error)
- func (cu *CodeUpdate) SaveX(ctx context.Context) int
- func (cu *CodeUpdate) Where(ps ...predicate.Code) *CodeUpdate
- type CodeUpdateOne
- func (cuo *CodeUpdateOne) Exec(ctx context.Context) error
- func (cuo *CodeUpdateOne) ExecX(ctx context.Context)
- func (cuo *CodeUpdateOne) Mutation() *CodeMutation
- func (cuo *CodeUpdateOne) Save(ctx context.Context) (*Code, error)
- func (cuo *CodeUpdateOne) SaveX(ctx context.Context) *Code
- func (cuo *CodeUpdateOne) Select(field string, fields ...string) *CodeUpdateOne
- type Codes
- type CommitFunc
- type CommitHook
- type Committer
- type ConstraintError
- type Hook
- 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. TypeCode = "Code" )
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 // Code is the client for interacting with the Code builders. Code *CodeClient // 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(). Code. Query(). Count(ctx)
type Code ¶
type Code struct { // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // Contents holds the value of the "contents" field. Contents string `json:"contents,omitempty"` // contains filtered or unexported fields }
Code is the model entity for the Code schema.
func (*Code) Unwrap ¶
Unwrap unwraps the Code 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 (*Code) Update ¶
func (c *Code) Update() *CodeUpdateOne
Update returns a builder for updating this Code. Note that you need to call Code.Unwrap() before calling this method if this Code was returned from a transaction, and the transaction was committed or rolled back.
type CodeClient ¶
type CodeClient struct {
// contains filtered or unexported fields
}
CodeClient is a client for the Code schema.
func NewCodeClient ¶
func NewCodeClient(c config) *CodeClient
NewCodeClient returns a client for the Code from the given config.
func (*CodeClient) Create ¶
func (c *CodeClient) Create() *CodeCreate
Create returns a create builder for Code.
func (*CodeClient) CreateBulk ¶
func (c *CodeClient) CreateBulk(builders ...*CodeCreate) *CodeCreateBulk
CreateBulk returns a builder for creating a bulk of Code entities.
func (*CodeClient) Delete ¶
func (c *CodeClient) Delete() *CodeDelete
Delete returns a delete builder for Code.
func (*CodeClient) DeleteOne ¶
func (c *CodeClient) DeleteOne(co *Code) *CodeDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*CodeClient) DeleteOneID ¶
func (c *CodeClient) DeleteOneID(id uuid.UUID) *CodeDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*CodeClient) Query ¶
func (c *CodeClient) Query() *CodeQuery
Query returns a query builder for Code.
func (*CodeClient) Update ¶
func (c *CodeClient) Update() *CodeUpdate
Update returns an update builder for Code.
func (*CodeClient) UpdateOne ¶
func (c *CodeClient) UpdateOne(co *Code) *CodeUpdateOne
UpdateOne returns an update builder for the given entity.
func (*CodeClient) UpdateOneID ¶
func (c *CodeClient) UpdateOneID(id uuid.UUID) *CodeUpdateOne
UpdateOneID returns an update builder for the given id.
func (*CodeClient) Use ¶
func (c *CodeClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `code.Hooks(f(g(h())))`.
type CodeCreate ¶
type CodeCreate struct {
// contains filtered or unexported fields
}
CodeCreate is the builder for creating a Code entity.
func (*CodeCreate) Exec ¶
func (cc *CodeCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*CodeCreate) ExecX ¶
func (cc *CodeCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CodeCreate) Mutation ¶
func (cc *CodeCreate) Mutation() *CodeMutation
Mutation returns the CodeMutation object of the builder.
func (*CodeCreate) Save ¶
func (cc *CodeCreate) Save(ctx context.Context) (*Code, error)
Save creates the Code in the database.
func (*CodeCreate) SaveX ¶
func (cc *CodeCreate) SaveX(ctx context.Context) *Code
SaveX calls Save and panics if Save returns an error.
func (*CodeCreate) SetContents ¶
func (cc *CodeCreate) SetContents(s string) *CodeCreate
SetContents sets the "contents" field.
func (*CodeCreate) SetID ¶
func (cc *CodeCreate) SetID(u uuid.UUID) *CodeCreate
SetID sets the "id" field.
func (*CodeCreate) SetNillableID ¶
func (cc *CodeCreate) SetNillableID(u *uuid.UUID) *CodeCreate
SetNillableID sets the "id" field if the given value is not nil.
type CodeCreateBulk ¶
type CodeCreateBulk struct {
// contains filtered or unexported fields
}
CodeCreateBulk is the builder for creating many Code entities in bulk.
func (*CodeCreateBulk) Exec ¶
func (ccb *CodeCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*CodeCreateBulk) ExecX ¶
func (ccb *CodeCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type CodeDelete ¶
type CodeDelete struct {
// contains filtered or unexported fields
}
CodeDelete is the builder for deleting a Code entity.
func (*CodeDelete) Exec ¶
func (cd *CodeDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*CodeDelete) ExecX ¶
func (cd *CodeDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*CodeDelete) Where ¶
func (cd *CodeDelete) Where(ps ...predicate.Code) *CodeDelete
Where appends a list predicates to the CodeDelete builder.
type CodeDeleteOne ¶
type CodeDeleteOne struct {
// contains filtered or unexported fields
}
CodeDeleteOne is the builder for deleting a single Code entity.
func (*CodeDeleteOne) Exec ¶
func (cdo *CodeDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*CodeDeleteOne) ExecX ¶
func (cdo *CodeDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type CodeGroupBy ¶
type CodeGroupBy struct {
// contains filtered or unexported fields
}
CodeGroupBy is the group-by builder for Code entities.
func (*CodeGroupBy) Aggregate ¶
func (cgb *CodeGroupBy) Aggregate(fns ...AggregateFunc) *CodeGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*CodeGroupBy) Bool ¶
func (cgb *CodeGroupBy) 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 (*CodeGroupBy) BoolX ¶
func (cgb *CodeGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*CodeGroupBy) Bools ¶
func (cgb *CodeGroupBy) 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 (*CodeGroupBy) BoolsX ¶
func (cgb *CodeGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*CodeGroupBy) Float64 ¶
func (cgb *CodeGroupBy) 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 (*CodeGroupBy) Float64X ¶
func (cgb *CodeGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*CodeGroupBy) Float64s ¶
func (cgb *CodeGroupBy) 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 (*CodeGroupBy) Float64sX ¶
func (cgb *CodeGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*CodeGroupBy) Int ¶
func (cgb *CodeGroupBy) 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 (*CodeGroupBy) IntX ¶
func (cgb *CodeGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*CodeGroupBy) Ints ¶
func (cgb *CodeGroupBy) 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 (*CodeGroupBy) IntsX ¶
func (cgb *CodeGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*CodeGroupBy) Scan ¶
func (cgb *CodeGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*CodeGroupBy) ScanX ¶
func (cgb *CodeGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*CodeGroupBy) String ¶
func (cgb *CodeGroupBy) 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 (*CodeGroupBy) StringX ¶
func (cgb *CodeGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type CodeMutation ¶
type CodeMutation struct {
// contains filtered or unexported fields
}
CodeMutation represents an operation that mutates the Code nodes in the graph.
func (*CodeMutation) AddField ¶
func (m *CodeMutation) 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 (*CodeMutation) AddedEdges ¶
func (m *CodeMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*CodeMutation) AddedField ¶
func (m *CodeMutation) 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 (*CodeMutation) AddedFields ¶
func (m *CodeMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*CodeMutation) AddedIDs ¶
func (m *CodeMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*CodeMutation) ClearEdge ¶
func (m *CodeMutation) 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 (*CodeMutation) ClearField ¶
func (m *CodeMutation) 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 (*CodeMutation) ClearedEdges ¶
func (m *CodeMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*CodeMutation) ClearedFields ¶
func (m *CodeMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (CodeMutation) Client ¶
func (m CodeMutation) 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 (*CodeMutation) Contents ¶
func (m *CodeMutation) Contents() (r string, exists bool)
Contents returns the value of the "contents" field in the mutation.
func (*CodeMutation) EdgeCleared ¶
func (m *CodeMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*CodeMutation) Field ¶
func (m *CodeMutation) 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 (*CodeMutation) FieldCleared ¶
func (m *CodeMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*CodeMutation) Fields ¶
func (m *CodeMutation) 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 (*CodeMutation) ID ¶
func (m *CodeMutation) ID() (id uuid.UUID, exists bool)
ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.
func (*CodeMutation) IDs ¶
IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.
func (*CodeMutation) OldContents ¶
func (m *CodeMutation) OldContents(ctx context.Context) (v string, err error)
OldContents returns the old "contents" field's value of the Code entity. If the Code 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 (*CodeMutation) 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 (*CodeMutation) RemovedEdges ¶
func (m *CodeMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*CodeMutation) RemovedIDs ¶
func (m *CodeMutation) 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 (*CodeMutation) ResetContents ¶
func (m *CodeMutation) ResetContents()
ResetContents resets all changes to the "contents" field.
func (*CodeMutation) ResetEdge ¶
func (m *CodeMutation) 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 (*CodeMutation) ResetField ¶
func (m *CodeMutation) 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 (*CodeMutation) SetContents ¶
func (m *CodeMutation) SetContents(s string)
SetContents sets the "contents" field.
func (*CodeMutation) SetField ¶
func (m *CodeMutation) 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 (*CodeMutation) SetID ¶
func (m *CodeMutation) SetID(id uuid.UUID)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Code entities.
func (CodeMutation) Tx ¶
func (m CodeMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*CodeMutation) Type ¶
func (m *CodeMutation) Type() string
Type returns the node type of this mutation (Code).
func (*CodeMutation) Where ¶
func (m *CodeMutation) Where(ps ...predicate.Code)
Where appends a list predicates to the CodeMutation builder.
type CodeQuery ¶
type CodeQuery struct {
// contains filtered or unexported fields
}
CodeQuery is the builder for querying Code entities.
func (*CodeQuery) Clone ¶
Clone returns a duplicate of the CodeQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*CodeQuery) First ¶
First returns the first Code entity from the query. Returns a *NotFoundError when no Code was found.
func (*CodeQuery) FirstID ¶
FirstID returns the first Code ID from the query. Returns a *NotFoundError when no Code ID was found.
func (*CodeQuery) GroupBy ¶
func (cq *CodeQuery) GroupBy(field string, fields ...string) *CodeGroupBy
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 { Contents string `json:"contents,omitempty"` Count int `json:"count,omitempty"` } client.Code.Query(). GroupBy(code.FieldContents). Aggregate(ent.Count()). Scan(ctx, &v)
func (*CodeQuery) Only ¶
Only returns a single Code entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Code entity is found. Returns a *NotFoundError when no Code entities are found.
func (*CodeQuery) OnlyID ¶
OnlyID is like Only, but returns the only Code ID in the query. Returns a *NotSingularError when more than one Code ID is found. Returns a *NotFoundError when no entities are found.
func (*CodeQuery) Select ¶
func (cq *CodeQuery) Select(fields ...string) *CodeSelect
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 { Contents string `json:"contents,omitempty"` } client.Code.Query(). Select(code.FieldContents). Scan(ctx, &v)
type CodeSelect ¶
type CodeSelect struct { *CodeQuery // contains filtered or unexported fields }
CodeSelect is the builder for selecting fields of Code entities.
func (*CodeSelect) Bool ¶
func (cs *CodeSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*CodeSelect) BoolX ¶
func (cs *CodeSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*CodeSelect) Bools ¶
func (cs *CodeSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*CodeSelect) BoolsX ¶
func (cs *CodeSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*CodeSelect) Float64 ¶
func (cs *CodeSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*CodeSelect) Float64X ¶
func (cs *CodeSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*CodeSelect) Float64s ¶
func (cs *CodeSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*CodeSelect) Float64sX ¶
func (cs *CodeSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*CodeSelect) Int ¶
func (cs *CodeSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*CodeSelect) IntX ¶
func (cs *CodeSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*CodeSelect) Ints ¶
func (cs *CodeSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*CodeSelect) IntsX ¶
func (cs *CodeSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*CodeSelect) Scan ¶
func (cs *CodeSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*CodeSelect) ScanX ¶
func (cs *CodeSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*CodeSelect) String ¶
func (cs *CodeSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from a selector. It is only allowed when selecting one field.
func (*CodeSelect) StringX ¶
func (cs *CodeSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type CodeUpdate ¶
type CodeUpdate struct {
// contains filtered or unexported fields
}
CodeUpdate is the builder for updating Code entities.
func (*CodeUpdate) Exec ¶
func (cu *CodeUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*CodeUpdate) ExecX ¶
func (cu *CodeUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CodeUpdate) Mutation ¶
func (cu *CodeUpdate) Mutation() *CodeMutation
Mutation returns the CodeMutation object of the builder.
func (*CodeUpdate) Save ¶
func (cu *CodeUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*CodeUpdate) SaveX ¶
func (cu *CodeUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*CodeUpdate) Where ¶
func (cu *CodeUpdate) Where(ps ...predicate.Code) *CodeUpdate
Where appends a list predicates to the CodeUpdate builder.
type CodeUpdateOne ¶
type CodeUpdateOne struct {
// contains filtered or unexported fields
}
CodeUpdateOne is the builder for updating a single Code entity.
func (*CodeUpdateOne) Exec ¶
func (cuo *CodeUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*CodeUpdateOne) ExecX ¶
func (cuo *CodeUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CodeUpdateOne) Mutation ¶
func (cuo *CodeUpdateOne) Mutation() *CodeMutation
Mutation returns the CodeMutation object of the builder.
func (*CodeUpdateOne) Save ¶
func (cuo *CodeUpdateOne) Save(ctx context.Context) (*Code, error)
Save executes the query and returns the updated Code entity.
func (*CodeUpdateOne) SaveX ¶
func (cuo *CodeUpdateOne) SaveX(ctx context.Context) *Code
SaveX is like Save, but panics if an error occurs.
func (*CodeUpdateOne) Select ¶
func (cuo *CodeUpdateOne) Select(field string, fields ...string) *CodeUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
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 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 { // Code is the client for interacting with the Code builders. Code *CodeClient // 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.