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 Migration
- type MigrationClient
- func (c *MigrationClient) Create() *MigrationCreate
- func (c *MigrationClient) CreateBulk(builders ...*MigrationCreate) *MigrationCreateBulk
- func (c *MigrationClient) Delete() *MigrationDelete
- func (c *MigrationClient) DeleteOne(m *Migration) *MigrationDeleteOne
- func (c *MigrationClient) DeleteOneID(id int) *MigrationDeleteOne
- func (c *MigrationClient) Get(ctx context.Context, id int) (*Migration, error)
- func (c *MigrationClient) GetX(ctx context.Context, id int) *Migration
- func (c *MigrationClient) Hooks() []Hook
- func (c *MigrationClient) Query() *MigrationQuery
- func (c *MigrationClient) Update() *MigrationUpdate
- func (c *MigrationClient) UpdateOne(m *Migration) *MigrationUpdateOne
- func (c *MigrationClient) UpdateOneID(id int) *MigrationUpdateOne
- func (c *MigrationClient) Use(hooks ...Hook)
- type MigrationCreate
- func (mc *MigrationCreate) Mutation() *MigrationMutation
- func (mc *MigrationCreate) Save(ctx context.Context) (*Migration, error)
- func (mc *MigrationCreate) SaveX(ctx context.Context) *Migration
- func (mc *MigrationCreate) SetAppliedAt(t time.Time) *MigrationCreate
- func (mc *MigrationCreate) SetName(s string) *MigrationCreate
- func (mc *MigrationCreate) SetNillableAppliedAt(t *time.Time) *MigrationCreate
- type MigrationCreateBulk
- type MigrationDelete
- type MigrationDeleteOne
- type MigrationGroupBy
- func (mgb *MigrationGroupBy) Aggregate(fns ...AggregateFunc) *MigrationGroupBy
- func (mgb *MigrationGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (mgb *MigrationGroupBy) BoolX(ctx context.Context) bool
- func (mgb *MigrationGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (mgb *MigrationGroupBy) BoolsX(ctx context.Context) []bool
- func (mgb *MigrationGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (mgb *MigrationGroupBy) Float64X(ctx context.Context) float64
- func (mgb *MigrationGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (mgb *MigrationGroupBy) Float64sX(ctx context.Context) []float64
- func (mgb *MigrationGroupBy) Int(ctx context.Context) (_ int, err error)
- func (mgb *MigrationGroupBy) IntX(ctx context.Context) int
- func (mgb *MigrationGroupBy) Ints(ctx context.Context) ([]int, error)
- func (mgb *MigrationGroupBy) IntsX(ctx context.Context) []int
- func (mgb *MigrationGroupBy) Scan(ctx context.Context, v interface{}) error
- func (mgb *MigrationGroupBy) ScanX(ctx context.Context, v interface{})
- func (mgb *MigrationGroupBy) String(ctx context.Context) (_ string, err error)
- func (mgb *MigrationGroupBy) StringX(ctx context.Context) string
- func (mgb *MigrationGroupBy) Strings(ctx context.Context) ([]string, error)
- func (mgb *MigrationGroupBy) StringsX(ctx context.Context) []string
- type MigrationMutation
- func (m *MigrationMutation) AddField(name string, value ent.Value) error
- func (m *MigrationMutation) AddedEdges() []string
- func (m *MigrationMutation) AddedField(name string) (ent.Value, bool)
- func (m *MigrationMutation) AddedFields() []string
- func (m *MigrationMutation) AddedIDs(name string) []ent.Value
- func (m *MigrationMutation) AppliedAt() (r time.Time, exists bool)
- func (m *MigrationMutation) ClearEdge(name string) error
- func (m *MigrationMutation) ClearField(name string) error
- func (m *MigrationMutation) ClearedEdges() []string
- func (m *MigrationMutation) ClearedFields() []string
- func (m MigrationMutation) Client() *Client
- func (m *MigrationMutation) EdgeCleared(name string) bool
- func (m *MigrationMutation) Field(name string) (ent.Value, bool)
- func (m *MigrationMutation) FieldCleared(name string) bool
- func (m *MigrationMutation) Fields() []string
- func (m *MigrationMutation) ID() (id int, exists bool)
- func (m *MigrationMutation) Name() (r string, exists bool)
- func (m *MigrationMutation) OldAppliedAt(ctx context.Context) (v time.Time, err error)
- func (m *MigrationMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *MigrationMutation) OldName(ctx context.Context) (v string, err error)
- func (m *MigrationMutation) Op() Op
- func (m *MigrationMutation) RemovedEdges() []string
- func (m *MigrationMutation) RemovedIDs(name string) []ent.Value
- func (m *MigrationMutation) ResetAppliedAt()
- func (m *MigrationMutation) ResetEdge(name string) error
- func (m *MigrationMutation) ResetField(name string) error
- func (m *MigrationMutation) ResetName()
- func (m *MigrationMutation) SetAppliedAt(t time.Time)
- func (m *MigrationMutation) SetField(name string, value ent.Value) error
- func (m *MigrationMutation) SetName(s string)
- func (m MigrationMutation) Tx() (*Tx, error)
- func (m *MigrationMutation) Type() string
- type MigrationQuery
- func (mq *MigrationQuery) All(ctx context.Context) ([]*Migration, error)
- func (mq *MigrationQuery) AllX(ctx context.Context) []*Migration
- func (mq *MigrationQuery) Clone() *MigrationQuery
- func (mq *MigrationQuery) Count(ctx context.Context) (int, error)
- func (mq *MigrationQuery) CountX(ctx context.Context) int
- func (mq *MigrationQuery) Exist(ctx context.Context) (bool, error)
- func (mq *MigrationQuery) ExistX(ctx context.Context) bool
- func (mq *MigrationQuery) First(ctx context.Context) (*Migration, error)
- func (mq *MigrationQuery) FirstID(ctx context.Context) (id int, err error)
- func (mq *MigrationQuery) FirstIDX(ctx context.Context) int
- func (mq *MigrationQuery) FirstX(ctx context.Context) *Migration
- func (mq *MigrationQuery) GroupBy(field string, fields ...string) *MigrationGroupBy
- func (mq *MigrationQuery) IDs(ctx context.Context) ([]int, error)
- func (mq *MigrationQuery) IDsX(ctx context.Context) []int
- func (mq *MigrationQuery) Limit(limit int) *MigrationQuery
- func (mq *MigrationQuery) Offset(offset int) *MigrationQuery
- func (mq *MigrationQuery) Only(ctx context.Context) (*Migration, error)
- func (mq *MigrationQuery) OnlyID(ctx context.Context) (id int, err error)
- func (mq *MigrationQuery) OnlyIDX(ctx context.Context) int
- func (mq *MigrationQuery) OnlyX(ctx context.Context) *Migration
- func (mq *MigrationQuery) Order(o ...OrderFunc) *MigrationQuery
- func (mq *MigrationQuery) Select(field string, fields ...string) *MigrationSelect
- func (mq *MigrationQuery) Unique(unique bool) *MigrationQuery
- func (mq *MigrationQuery) Where(ps ...predicate.Migration) *MigrationQuery
- type MigrationSelect
- func (ms *MigrationSelect) Bool(ctx context.Context) (_ bool, err error)
- func (ms *MigrationSelect) BoolX(ctx context.Context) bool
- func (ms *MigrationSelect) Bools(ctx context.Context) ([]bool, error)
- func (ms *MigrationSelect) BoolsX(ctx context.Context) []bool
- func (ms *MigrationSelect) Float64(ctx context.Context) (_ float64, err error)
- func (ms *MigrationSelect) Float64X(ctx context.Context) float64
- func (ms *MigrationSelect) Float64s(ctx context.Context) ([]float64, error)
- func (ms *MigrationSelect) Float64sX(ctx context.Context) []float64
- func (ms *MigrationSelect) Int(ctx context.Context) (_ int, err error)
- func (ms *MigrationSelect) IntX(ctx context.Context) int
- func (ms *MigrationSelect) Ints(ctx context.Context) ([]int, error)
- func (ms *MigrationSelect) IntsX(ctx context.Context) []int
- func (ms *MigrationSelect) Scan(ctx context.Context, v interface{}) error
- func (ms *MigrationSelect) ScanX(ctx context.Context, v interface{})
- func (ms *MigrationSelect) String(ctx context.Context) (_ string, err error)
- func (ms *MigrationSelect) StringX(ctx context.Context) string
- func (ms *MigrationSelect) Strings(ctx context.Context) ([]string, error)
- func (ms *MigrationSelect) StringsX(ctx context.Context) []string
- type MigrationUpdate
- func (mu *MigrationUpdate) Exec(ctx context.Context) error
- func (mu *MigrationUpdate) ExecX(ctx context.Context)
- func (mu *MigrationUpdate) Mutation() *MigrationMutation
- func (mu *MigrationUpdate) Save(ctx context.Context) (int, error)
- func (mu *MigrationUpdate) SaveX(ctx context.Context) int
- func (mu *MigrationUpdate) SetAppliedAt(t time.Time) *MigrationUpdate
- func (mu *MigrationUpdate) SetName(s string) *MigrationUpdate
- func (mu *MigrationUpdate) Where(ps ...predicate.Migration) *MigrationUpdate
- type MigrationUpdateOne
- func (muo *MigrationUpdateOne) Exec(ctx context.Context) error
- func (muo *MigrationUpdateOne) ExecX(ctx context.Context)
- func (muo *MigrationUpdateOne) Mutation() *MigrationMutation
- func (muo *MigrationUpdateOne) Save(ctx context.Context) (*Migration, error)
- func (muo *MigrationUpdateOne) SaveX(ctx context.Context) *Migration
- func (muo *MigrationUpdateOne) Select(field string, fields ...string) *MigrationUpdateOne
- func (muo *MigrationUpdateOne) SetAppliedAt(t time.Time) *MigrationUpdateOne
- func (muo *MigrationUpdateOne) SetName(s string) *MigrationUpdateOne
- type Migrations
- 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. TypeMigration = "Migration" )
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 // Migration is the client for interacting with the Migration builders. Migration *MigrationClient // 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(). Migration. 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 Migration ¶
type Migration struct { // ID of the ent. ID int `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // AppliedAt holds the value of the "applied_at" field. AppliedAt time.Time `json:"applied_at,omitempty"` // contains filtered or unexported fields }
Migration is the model entity for the Migration schema.
func (*Migration) Unwrap ¶
Unwrap unwraps the Migration 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 (*Migration) Update ¶
func (m *Migration) Update() *MigrationUpdateOne
Update returns a builder for updating this Migration. Note that you need to call Migration.Unwrap() before calling this method if this Migration was returned from a transaction, and the transaction was committed or rolled back.
type MigrationClient ¶
type MigrationClient struct {
// contains filtered or unexported fields
}
MigrationClient is a client for the Migration schema.
func NewMigrationClient ¶
func NewMigrationClient(c config) *MigrationClient
NewMigrationClient returns a client for the Migration from the given config.
func (*MigrationClient) Create ¶
func (c *MigrationClient) Create() *MigrationCreate
Create returns a create builder for Migration.
func (*MigrationClient) CreateBulk ¶
func (c *MigrationClient) CreateBulk(builders ...*MigrationCreate) *MigrationCreateBulk
CreateBulk returns a builder for creating a bulk of Migration entities.
func (*MigrationClient) Delete ¶
func (c *MigrationClient) Delete() *MigrationDelete
Delete returns a delete builder for Migration.
func (*MigrationClient) DeleteOne ¶
func (c *MigrationClient) DeleteOne(m *Migration) *MigrationDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*MigrationClient) DeleteOneID ¶
func (c *MigrationClient) DeleteOneID(id int) *MigrationDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*MigrationClient) GetX ¶
func (c *MigrationClient) GetX(ctx context.Context, id int) *Migration
GetX is like Get, but panics if an error occurs.
func (*MigrationClient) Hooks ¶
func (c *MigrationClient) Hooks() []Hook
Hooks returns the client hooks.
func (*MigrationClient) Query ¶
func (c *MigrationClient) Query() *MigrationQuery
Query returns a query builder for Migration.
func (*MigrationClient) Update ¶
func (c *MigrationClient) Update() *MigrationUpdate
Update returns an update builder for Migration.
func (*MigrationClient) UpdateOne ¶
func (c *MigrationClient) UpdateOne(m *Migration) *MigrationUpdateOne
UpdateOne returns an update builder for the given entity.
func (*MigrationClient) UpdateOneID ¶
func (c *MigrationClient) UpdateOneID(id int) *MigrationUpdateOne
UpdateOneID returns an update builder for the given id.
func (*MigrationClient) Use ¶
func (c *MigrationClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `migration.Hooks(f(g(h())))`.
type MigrationCreate ¶
type MigrationCreate struct {
// contains filtered or unexported fields
}
MigrationCreate is the builder for creating a Migration entity.
func (*MigrationCreate) Mutation ¶
func (mc *MigrationCreate) Mutation() *MigrationMutation
Mutation returns the MigrationMutation object of the builder.
func (*MigrationCreate) Save ¶
func (mc *MigrationCreate) Save(ctx context.Context) (*Migration, error)
Save creates the Migration in the database.
func (*MigrationCreate) SaveX ¶
func (mc *MigrationCreate) SaveX(ctx context.Context) *Migration
SaveX calls Save and panics if Save returns an error.
func (*MigrationCreate) SetAppliedAt ¶
func (mc *MigrationCreate) SetAppliedAt(t time.Time) *MigrationCreate
SetAppliedAt sets the "applied_at" field.
func (*MigrationCreate) SetName ¶
func (mc *MigrationCreate) SetName(s string) *MigrationCreate
SetName sets the "name" field.
func (*MigrationCreate) SetNillableAppliedAt ¶
func (mc *MigrationCreate) SetNillableAppliedAt(t *time.Time) *MigrationCreate
SetNillableAppliedAt sets the "applied_at" field if the given value is not nil.
type MigrationCreateBulk ¶
type MigrationCreateBulk struct {
// contains filtered or unexported fields
}
MigrationCreateBulk is the builder for creating many Migration entities in bulk.
type MigrationDelete ¶
type MigrationDelete struct {
// contains filtered or unexported fields
}
MigrationDelete is the builder for deleting a Migration entity.
func (*MigrationDelete) Exec ¶
func (md *MigrationDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*MigrationDelete) ExecX ¶
func (md *MigrationDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*MigrationDelete) Where ¶
func (md *MigrationDelete) Where(ps ...predicate.Migration) *MigrationDelete
Where adds a new predicate to the MigrationDelete builder.
type MigrationDeleteOne ¶
type MigrationDeleteOne struct {
// contains filtered or unexported fields
}
MigrationDeleteOne is the builder for deleting a single Migration entity.
func (*MigrationDeleteOne) Exec ¶
func (mdo *MigrationDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*MigrationDeleteOne) ExecX ¶
func (mdo *MigrationDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type MigrationGroupBy ¶
type MigrationGroupBy struct {
// contains filtered or unexported fields
}
MigrationGroupBy is the group-by builder for Migration entities.
func (*MigrationGroupBy) Aggregate ¶
func (mgb *MigrationGroupBy) Aggregate(fns ...AggregateFunc) *MigrationGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*MigrationGroupBy) Bool ¶
func (mgb *MigrationGroupBy) 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 (*MigrationGroupBy) BoolX ¶
func (mgb *MigrationGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*MigrationGroupBy) Bools ¶
func (mgb *MigrationGroupBy) 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 (*MigrationGroupBy) BoolsX ¶
func (mgb *MigrationGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*MigrationGroupBy) Float64 ¶
func (mgb *MigrationGroupBy) 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 (*MigrationGroupBy) Float64X ¶
func (mgb *MigrationGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*MigrationGroupBy) Float64s ¶
func (mgb *MigrationGroupBy) 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 (*MigrationGroupBy) Float64sX ¶
func (mgb *MigrationGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*MigrationGroupBy) Int ¶
func (mgb *MigrationGroupBy) 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 (*MigrationGroupBy) IntX ¶
func (mgb *MigrationGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*MigrationGroupBy) Ints ¶
func (mgb *MigrationGroupBy) 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 (*MigrationGroupBy) IntsX ¶
func (mgb *MigrationGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*MigrationGroupBy) Scan ¶
func (mgb *MigrationGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*MigrationGroupBy) ScanX ¶
func (mgb *MigrationGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*MigrationGroupBy) String ¶
func (mgb *MigrationGroupBy) 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 (*MigrationGroupBy) StringX ¶
func (mgb *MigrationGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type MigrationMutation ¶
type MigrationMutation struct {
// contains filtered or unexported fields
}
MigrationMutation represents an operation that mutates the Migration nodes in the graph.
func (*MigrationMutation) AddField ¶
func (m *MigrationMutation) 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 (*MigrationMutation) AddedEdges ¶
func (m *MigrationMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*MigrationMutation) AddedField ¶
func (m *MigrationMutation) 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 (*MigrationMutation) AddedFields ¶
func (m *MigrationMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*MigrationMutation) AddedIDs ¶
func (m *MigrationMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*MigrationMutation) AppliedAt ¶
func (m *MigrationMutation) AppliedAt() (r time.Time, exists bool)
AppliedAt returns the value of the "applied_at" field in the mutation.
func (*MigrationMutation) ClearEdge ¶
func (m *MigrationMutation) 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 (*MigrationMutation) ClearField ¶
func (m *MigrationMutation) 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 (*MigrationMutation) ClearedEdges ¶
func (m *MigrationMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*MigrationMutation) ClearedFields ¶
func (m *MigrationMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (MigrationMutation) Client ¶
func (m MigrationMutation) 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 (*MigrationMutation) EdgeCleared ¶
func (m *MigrationMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*MigrationMutation) Field ¶
func (m *MigrationMutation) 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 (*MigrationMutation) FieldCleared ¶
func (m *MigrationMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*MigrationMutation) Fields ¶
func (m *MigrationMutation) 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 (*MigrationMutation) ID ¶
func (m *MigrationMutation) 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.
func (*MigrationMutation) Name ¶
func (m *MigrationMutation) Name() (r string, exists bool)
Name returns the value of the "name" field in the mutation.
func (*MigrationMutation) OldAppliedAt ¶
OldAppliedAt returns the old "applied_at" field's value of the Migration entity. If the Migration 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 (*MigrationMutation) 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 (*MigrationMutation) OldName ¶
func (m *MigrationMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old "name" field's value of the Migration entity. If the Migration 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 (*MigrationMutation) RemovedEdges ¶
func (m *MigrationMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*MigrationMutation) RemovedIDs ¶
func (m *MigrationMutation) 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 (*MigrationMutation) ResetAppliedAt ¶
func (m *MigrationMutation) ResetAppliedAt()
ResetAppliedAt resets all changes to the "applied_at" field.
func (*MigrationMutation) ResetEdge ¶
func (m *MigrationMutation) 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 (*MigrationMutation) ResetField ¶
func (m *MigrationMutation) 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 (*MigrationMutation) ResetName ¶
func (m *MigrationMutation) ResetName()
ResetName resets all changes to the "name" field.
func (*MigrationMutation) SetAppliedAt ¶
func (m *MigrationMutation) SetAppliedAt(t time.Time)
SetAppliedAt sets the "applied_at" field.
func (*MigrationMutation) SetField ¶
func (m *MigrationMutation) 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 (*MigrationMutation) SetName ¶
func (m *MigrationMutation) SetName(s string)
SetName sets the "name" field.
func (MigrationMutation) Tx ¶
func (m MigrationMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*MigrationMutation) Type ¶
func (m *MigrationMutation) Type() string
Type returns the node type of this mutation (Migration).
type MigrationQuery ¶
type MigrationQuery struct {
// contains filtered or unexported fields
}
MigrationQuery is the builder for querying Migration entities.
func (*MigrationQuery) All ¶
func (mq *MigrationQuery) All(ctx context.Context) ([]*Migration, error)
All executes the query and returns a list of Migrations.
func (*MigrationQuery) AllX ¶
func (mq *MigrationQuery) AllX(ctx context.Context) []*Migration
AllX is like All, but panics if an error occurs.
func (*MigrationQuery) Clone ¶
func (mq *MigrationQuery) Clone() *MigrationQuery
Clone returns a duplicate of the MigrationQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*MigrationQuery) Count ¶
func (mq *MigrationQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*MigrationQuery) CountX ¶
func (mq *MigrationQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*MigrationQuery) Exist ¶
func (mq *MigrationQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*MigrationQuery) ExistX ¶
func (mq *MigrationQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*MigrationQuery) First ¶
func (mq *MigrationQuery) First(ctx context.Context) (*Migration, error)
First returns the first Migration entity from the query. Returns a *NotFoundError when no Migration was found.
func (*MigrationQuery) FirstID ¶
func (mq *MigrationQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Migration ID from the query. Returns a *NotFoundError when no Migration ID was found.
func (*MigrationQuery) FirstIDX ¶
func (mq *MigrationQuery) FirstIDX(ctx context.Context) int
FirstIDX is like FirstID, but panics if an error occurs.
func (*MigrationQuery) FirstX ¶
func (mq *MigrationQuery) FirstX(ctx context.Context) *Migration
FirstX is like First, but panics if an error occurs.
func (*MigrationQuery) GroupBy ¶
func (mq *MigrationQuery) GroupBy(field string, fields ...string) *MigrationGroupBy
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 { Name string `json:"name,omitempty"` Count int `json:"count,omitempty"` } client.Migration.Query(). GroupBy(migration.FieldName). Aggregate(ent.Count()). Scan(ctx, &v)
func (*MigrationQuery) IDs ¶
func (mq *MigrationQuery) IDs(ctx context.Context) ([]int, error)
IDs executes the query and returns a list of Migration IDs.
func (*MigrationQuery) IDsX ¶
func (mq *MigrationQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*MigrationQuery) Limit ¶
func (mq *MigrationQuery) Limit(limit int) *MigrationQuery
Limit adds a limit step to the query.
func (*MigrationQuery) Offset ¶
func (mq *MigrationQuery) Offset(offset int) *MigrationQuery
Offset adds an offset step to the query.
func (*MigrationQuery) Only ¶
func (mq *MigrationQuery) Only(ctx context.Context) (*Migration, error)
Only returns a single Migration entity found by the query, ensuring it only returns one. Returns a *NotSingularError when exactly one Migration entity is not found. Returns a *NotFoundError when no Migration entities are found.
func (*MigrationQuery) OnlyID ¶
func (mq *MigrationQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID is like Only, but returns the only Migration ID in the query. Returns a *NotSingularError when exactly one Migration ID is not found. Returns a *NotFoundError when no entities are found.
func (*MigrationQuery) OnlyIDX ¶
func (mq *MigrationQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*MigrationQuery) OnlyX ¶
func (mq *MigrationQuery) OnlyX(ctx context.Context) *Migration
OnlyX is like Only, but panics if an error occurs.
func (*MigrationQuery) Order ¶
func (mq *MigrationQuery) Order(o ...OrderFunc) *MigrationQuery
Order adds an order step to the query.
func (*MigrationQuery) Select ¶
func (mq *MigrationQuery) Select(field string, fields ...string) *MigrationSelect
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 { Name string `json:"name,omitempty"` } client.Migration.Query(). Select(migration.FieldName). Scan(ctx, &v)
func (*MigrationQuery) Unique ¶
func (mq *MigrationQuery) Unique(unique bool) *MigrationQuery
Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.
func (*MigrationQuery) Where ¶
func (mq *MigrationQuery) Where(ps ...predicate.Migration) *MigrationQuery
Where adds a new predicate for the MigrationQuery builder.
type MigrationSelect ¶
type MigrationSelect struct { *MigrationQuery // contains filtered or unexported fields }
MigrationSelect is the builder for selecting fields of Migration entities.
func (*MigrationSelect) Bool ¶
func (ms *MigrationSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*MigrationSelect) BoolX ¶
func (ms *MigrationSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*MigrationSelect) Bools ¶
func (ms *MigrationSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*MigrationSelect) BoolsX ¶
func (ms *MigrationSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*MigrationSelect) Float64 ¶
func (ms *MigrationSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*MigrationSelect) Float64X ¶
func (ms *MigrationSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*MigrationSelect) Float64s ¶
func (ms *MigrationSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*MigrationSelect) Float64sX ¶
func (ms *MigrationSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*MigrationSelect) Int ¶
func (ms *MigrationSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*MigrationSelect) IntX ¶
func (ms *MigrationSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*MigrationSelect) Ints ¶
func (ms *MigrationSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*MigrationSelect) IntsX ¶
func (ms *MigrationSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*MigrationSelect) Scan ¶
func (ms *MigrationSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*MigrationSelect) ScanX ¶
func (ms *MigrationSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*MigrationSelect) String ¶
func (ms *MigrationSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from a selector. It is only allowed when selecting one field.
func (*MigrationSelect) StringX ¶
func (ms *MigrationSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type MigrationUpdate ¶
type MigrationUpdate struct {
// contains filtered or unexported fields
}
MigrationUpdate is the builder for updating Migration entities.
func (*MigrationUpdate) Exec ¶
func (mu *MigrationUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*MigrationUpdate) ExecX ¶
func (mu *MigrationUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*MigrationUpdate) Mutation ¶
func (mu *MigrationUpdate) Mutation() *MigrationMutation
Mutation returns the MigrationMutation object of the builder.
func (*MigrationUpdate) Save ¶
func (mu *MigrationUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*MigrationUpdate) SaveX ¶
func (mu *MigrationUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*MigrationUpdate) SetAppliedAt ¶
func (mu *MigrationUpdate) SetAppliedAt(t time.Time) *MigrationUpdate
SetAppliedAt sets the "applied_at" field.
func (*MigrationUpdate) SetName ¶
func (mu *MigrationUpdate) SetName(s string) *MigrationUpdate
SetName sets the "name" field.
func (*MigrationUpdate) Where ¶
func (mu *MigrationUpdate) Where(ps ...predicate.Migration) *MigrationUpdate
Where adds a new predicate for the MigrationUpdate builder.
type MigrationUpdateOne ¶
type MigrationUpdateOne struct {
// contains filtered or unexported fields
}
MigrationUpdateOne is the builder for updating a single Migration entity.
func (*MigrationUpdateOne) Exec ¶
func (muo *MigrationUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*MigrationUpdateOne) ExecX ¶
func (muo *MigrationUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*MigrationUpdateOne) Mutation ¶
func (muo *MigrationUpdateOne) Mutation() *MigrationMutation
Mutation returns the MigrationMutation object of the builder.
func (*MigrationUpdateOne) Save ¶
func (muo *MigrationUpdateOne) Save(ctx context.Context) (*Migration, error)
Save executes the query and returns the updated Migration entity.
func (*MigrationUpdateOne) SaveX ¶
func (muo *MigrationUpdateOne) SaveX(ctx context.Context) *Migration
SaveX is like Save, but panics if an error occurs.
func (*MigrationUpdateOne) Select ¶
func (muo *MigrationUpdateOne) Select(field string, fields ...string) *MigrationUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*MigrationUpdateOne) SetAppliedAt ¶
func (muo *MigrationUpdateOne) SetAppliedAt(t time.Time) *MigrationUpdateOne
SetAppliedAt sets the "applied_at" field.
func (*MigrationUpdateOne) SetName ¶
func (muo *MigrationUpdateOne) SetName(s string) *MigrationUpdateOne
SetName sets the "name" 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(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 { // Migration is the client for interacting with the Migration builders. Migration *MigrationClient // 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 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.