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 Miner
- type MinerClient
- func (c *MinerClient) Create() *MinerCreate
- func (c *MinerClient) CreateBulk(builders ...*MinerCreate) *MinerCreateBulk
- func (c *MinerClient) Delete() *MinerDelete
- func (c *MinerClient) DeleteOne(m *Miner) *MinerDeleteOne
- func (c *MinerClient) DeleteOneID(id int) *MinerDeleteOne
- func (c *MinerClient) Get(ctx context.Context, id int) (*Miner, error)
- func (c *MinerClient) GetX(ctx context.Context, id int) *Miner
- func (c *MinerClient) Hooks() []Hook
- func (c *MinerClient) Query() *MinerQuery
- func (c *MinerClient) Update() *MinerUpdate
- func (c *MinerClient) UpdateOne(m *Miner) *MinerUpdateOne
- func (c *MinerClient) UpdateOneID(id int) *MinerUpdateOne
- func (c *MinerClient) Use(hooks ...Hook)
- type MinerCreate
- func (mc *MinerCreate) Mutation() *MinerMutation
- func (mc *MinerCreate) Save(ctx context.Context) (*Miner, error)
- func (mc *MinerCreate) SaveX(ctx context.Context) *Miner
- func (mc *MinerCreate) SetMinerID(s string) *MinerCreate
- func (mc *MinerCreate) SetOwnerAddr(s string) *MinerCreate
- func (mc *MinerCreate) SetPeerID(s string) *MinerCreate
- func (mc *MinerCreate) SetSectorSize(s string) *MinerCreate
- func (mc *MinerCreate) SetStateRoot(s string) *MinerCreate
- func (mc *MinerCreate) SetWorkerAddr(s string) *MinerCreate
- type MinerCreateBulk
- type MinerDelete
- type MinerDeleteOne
- type MinerGroupBy
- func (mgb *MinerGroupBy) Aggregate(fns ...AggregateFunc) *MinerGroupBy
- func (mgb *MinerGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (mgb *MinerGroupBy) BoolX(ctx context.Context) bool
- func (mgb *MinerGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (mgb *MinerGroupBy) BoolsX(ctx context.Context) []bool
- func (mgb *MinerGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (mgb *MinerGroupBy) Float64X(ctx context.Context) float64
- func (mgb *MinerGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (mgb *MinerGroupBy) Float64sX(ctx context.Context) []float64
- func (mgb *MinerGroupBy) Int(ctx context.Context) (_ int, err error)
- func (mgb *MinerGroupBy) IntX(ctx context.Context) int
- func (mgb *MinerGroupBy) Ints(ctx context.Context) ([]int, error)
- func (mgb *MinerGroupBy) IntsX(ctx context.Context) []int
- func (mgb *MinerGroupBy) Scan(ctx context.Context, v interface{}) error
- func (mgb *MinerGroupBy) ScanX(ctx context.Context, v interface{})
- func (mgb *MinerGroupBy) String(ctx context.Context) (_ string, err error)
- func (mgb *MinerGroupBy) StringX(ctx context.Context) string
- func (mgb *MinerGroupBy) Strings(ctx context.Context) ([]string, error)
- func (mgb *MinerGroupBy) StringsX(ctx context.Context) []string
- type MinerMutation
- func (m *MinerMutation) AddField(name string, value ent.Value) error
- func (m *MinerMutation) AddedEdges() []string
- func (m *MinerMutation) AddedField(name string) (ent.Value, bool)
- func (m *MinerMutation) AddedFields() []string
- func (m *MinerMutation) AddedIDs(name string) []ent.Value
- func (m *MinerMutation) ClearEdge(name string) error
- func (m *MinerMutation) ClearField(name string) error
- func (m *MinerMutation) ClearedEdges() []string
- func (m *MinerMutation) ClearedFields() []string
- func (m MinerMutation) Client() *Client
- func (m *MinerMutation) EdgeCleared(name string) bool
- func (m *MinerMutation) Field(name string) (ent.Value, bool)
- func (m *MinerMutation) FieldCleared(name string) bool
- func (m *MinerMutation) Fields() []string
- func (m *MinerMutation) ID() (id int, exists bool)
- func (m *MinerMutation) MinerID() (r string, exists bool)
- func (m *MinerMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *MinerMutation) OldMinerID(ctx context.Context) (v string, err error)
- func (m *MinerMutation) OldOwnerAddr(ctx context.Context) (v string, err error)
- func (m *MinerMutation) OldPeerID(ctx context.Context) (v string, err error)
- func (m *MinerMutation) OldSectorSize(ctx context.Context) (v string, err error)
- func (m *MinerMutation) OldStateRoot(ctx context.Context) (v string, err error)
- func (m *MinerMutation) OldWorkerAddr(ctx context.Context) (v string, err error)
- func (m *MinerMutation) Op() Op
- func (m *MinerMutation) OwnerAddr() (r string, exists bool)
- func (m *MinerMutation) PeerID() (r string, exists bool)
- func (m *MinerMutation) RemovedEdges() []string
- func (m *MinerMutation) RemovedIDs(name string) []ent.Value
- func (m *MinerMutation) ResetEdge(name string) error
- func (m *MinerMutation) ResetField(name string) error
- func (m *MinerMutation) ResetMinerID()
- func (m *MinerMutation) ResetOwnerAddr()
- func (m *MinerMutation) ResetPeerID()
- func (m *MinerMutation) ResetSectorSize()
- func (m *MinerMutation) ResetStateRoot()
- func (m *MinerMutation) ResetWorkerAddr()
- func (m *MinerMutation) SectorSize() (r string, exists bool)
- func (m *MinerMutation) SetField(name string, value ent.Value) error
- func (m *MinerMutation) SetMinerID(s string)
- func (m *MinerMutation) SetOwnerAddr(s string)
- func (m *MinerMutation) SetPeerID(s string)
- func (m *MinerMutation) SetSectorSize(s string)
- func (m *MinerMutation) SetStateRoot(s string)
- func (m *MinerMutation) SetWorkerAddr(s string)
- func (m *MinerMutation) StateRoot() (r string, exists bool)
- func (m MinerMutation) Tx() (*Tx, error)
- func (m *MinerMutation) Type() string
- func (m *MinerMutation) WorkerAddr() (r string, exists bool)
- type MinerQuery
- func (mq *MinerQuery) All(ctx context.Context) ([]*Miner, error)
- func (mq *MinerQuery) AllX(ctx context.Context) []*Miner
- func (mq *MinerQuery) Clone() *MinerQuery
- func (mq *MinerQuery) Count(ctx context.Context) (int, error)
- func (mq *MinerQuery) CountX(ctx context.Context) int
- func (mq *MinerQuery) Exist(ctx context.Context) (bool, error)
- func (mq *MinerQuery) ExistX(ctx context.Context) bool
- func (mq *MinerQuery) First(ctx context.Context) (*Miner, error)
- func (mq *MinerQuery) FirstID(ctx context.Context) (id int, err error)
- func (mq *MinerQuery) FirstX(ctx context.Context) *Miner
- func (mq *MinerQuery) FirstXID(ctx context.Context) int
- func (mq *MinerQuery) GroupBy(field string, fields ...string) *MinerGroupBy
- func (mq *MinerQuery) IDs(ctx context.Context) ([]int, error)
- func (mq *MinerQuery) IDsX(ctx context.Context) []int
- func (mq *MinerQuery) Limit(limit int) *MinerQuery
- func (mq *MinerQuery) Offset(offset int) *MinerQuery
- func (mq *MinerQuery) Only(ctx context.Context) (*Miner, error)
- func (mq *MinerQuery) OnlyID(ctx context.Context) (id int, err error)
- func (mq *MinerQuery) OnlyIDX(ctx context.Context) int
- func (mq *MinerQuery) OnlyX(ctx context.Context) *Miner
- func (mq *MinerQuery) Order(o ...OrderFunc) *MinerQuery
- func (mq *MinerQuery) Select(field string, fields ...string) *MinerSelect
- func (mq *MinerQuery) Where(ps ...predicate.Miner) *MinerQuery
- type MinerSelect
- func (ms *MinerSelect) Bool(ctx context.Context) (_ bool, err error)
- func (ms *MinerSelect) BoolX(ctx context.Context) bool
- func (ms *MinerSelect) Bools(ctx context.Context) ([]bool, error)
- func (ms *MinerSelect) BoolsX(ctx context.Context) []bool
- func (ms *MinerSelect) Float64(ctx context.Context) (_ float64, err error)
- func (ms *MinerSelect) Float64X(ctx context.Context) float64
- func (ms *MinerSelect) Float64s(ctx context.Context) ([]float64, error)
- func (ms *MinerSelect) Float64sX(ctx context.Context) []float64
- func (ms *MinerSelect) Int(ctx context.Context) (_ int, err error)
- func (ms *MinerSelect) IntX(ctx context.Context) int
- func (ms *MinerSelect) Ints(ctx context.Context) ([]int, error)
- func (ms *MinerSelect) IntsX(ctx context.Context) []int
- func (ms *MinerSelect) Scan(ctx context.Context, v interface{}) error
- func (ms *MinerSelect) ScanX(ctx context.Context, v interface{})
- func (ms *MinerSelect) String(ctx context.Context) (_ string, err error)
- func (ms *MinerSelect) StringX(ctx context.Context) string
- func (ms *MinerSelect) Strings(ctx context.Context) ([]string, error)
- func (ms *MinerSelect) StringsX(ctx context.Context) []string
- type MinerUpdate
- func (mu *MinerUpdate) Exec(ctx context.Context) error
- func (mu *MinerUpdate) ExecX(ctx context.Context)
- func (mu *MinerUpdate) Mutation() *MinerMutation
- func (mu *MinerUpdate) Save(ctx context.Context) (int, error)
- func (mu *MinerUpdate) SaveX(ctx context.Context) int
- func (mu *MinerUpdate) SetMinerID(s string) *MinerUpdate
- func (mu *MinerUpdate) SetOwnerAddr(s string) *MinerUpdate
- func (mu *MinerUpdate) SetPeerID(s string) *MinerUpdate
- func (mu *MinerUpdate) SetSectorSize(s string) *MinerUpdate
- func (mu *MinerUpdate) SetStateRoot(s string) *MinerUpdate
- func (mu *MinerUpdate) SetWorkerAddr(s string) *MinerUpdate
- func (mu *MinerUpdate) Where(ps ...predicate.Miner) *MinerUpdate
- type MinerUpdateOne
- func (muo *MinerUpdateOne) Exec(ctx context.Context) error
- func (muo *MinerUpdateOne) ExecX(ctx context.Context)
- func (muo *MinerUpdateOne) Mutation() *MinerMutation
- func (muo *MinerUpdateOne) Save(ctx context.Context) (*Miner, error)
- func (muo *MinerUpdateOne) SaveX(ctx context.Context) *Miner
- func (muo *MinerUpdateOne) SetMinerID(s string) *MinerUpdateOne
- func (muo *MinerUpdateOne) SetOwnerAddr(s string) *MinerUpdateOne
- func (muo *MinerUpdateOne) SetPeerID(s string) *MinerUpdateOne
- func (muo *MinerUpdateOne) SetSectorSize(s string) *MinerUpdateOne
- func (muo *MinerUpdateOne) SetStateRoot(s string) *MinerUpdateOne
- func (muo *MinerUpdateOne) SetWorkerAddr(s string) *MinerUpdateOne
- type Miners
- 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. TypeMiner = "Miner" )
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 // Miner is the client for interacting with the Miner builders. Miner *MinerClient // contains filtered or unexported fields }
Client is the client that holds all ent builders.
func FromContext ¶
FromContext returns the Client stored in a context, or nil if there isn't one.
func Open ¶
Open opens a database/sql.DB specified by the driver name and the data source name, and returns a new client attached to it. Optional parameters can be added for configuring the client.
func (*Client) Debug ¶
Debug returns a new debug-client. It's used to get verbose logging on specific operations.
client.Debug(). Miner. 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 Miner ¶
type Miner struct { // ID of the ent. ID int `json:"id,omitempty"` // StateRoot holds the value of the "state_root" field. StateRoot string `json:"state_root,omitempty"` // MinerID holds the value of the "miner_id" field. MinerID string `json:"miner_id,omitempty"` // OwnerAddr holds the value of the "owner_addr" field. OwnerAddr string `json:"owner_addr,omitempty"` // WorkerAddr holds the value of the "worker_addr" field. WorkerAddr string `json:"worker_addr,omitempty"` // PeerID holds the value of the "peer_id" field. PeerID string `json:"peer_id,omitempty"` // SectorSize holds the value of the "sector_size" field. SectorSize string `json:"sector_size,omitempty"` // contains filtered or unexported fields }
Miner is the model entity for the Miner schema.
func (*Miner) Unwrap ¶
Unwrap unwraps the entity that was returned from a transaction after it was closed, so that all next queries will be executed through the driver which created the transaction.
func (*Miner) Update ¶
func (m *Miner) Update() *MinerUpdateOne
Update returns a builder for updating this Miner. Note that, you need to call Miner.Unwrap() before calling this method, if this Miner was returned from a transaction, and the transaction was committed or rolled back.
type MinerClient ¶
type MinerClient struct {
// contains filtered or unexported fields
}
MinerClient is a client for the Miner schema.
func NewMinerClient ¶
func NewMinerClient(c config) *MinerClient
NewMinerClient returns a client for the Miner from the given config.
func (*MinerClient) Create ¶
func (c *MinerClient) Create() *MinerCreate
Create returns a create builder for Miner.
func (*MinerClient) CreateBulk ¶
func (c *MinerClient) CreateBulk(builders ...*MinerCreate) *MinerCreateBulk
BulkCreate returns a builder for creating a bulk of Miner entities.
func (*MinerClient) Delete ¶
func (c *MinerClient) Delete() *MinerDelete
Delete returns a delete builder for Miner.
func (*MinerClient) DeleteOne ¶
func (c *MinerClient) DeleteOne(m *Miner) *MinerDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*MinerClient) DeleteOneID ¶
func (c *MinerClient) DeleteOneID(id int) *MinerDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*MinerClient) GetX ¶
func (c *MinerClient) GetX(ctx context.Context, id int) *Miner
GetX is like Get, but panics if an error occurs.
func (*MinerClient) Query ¶
func (c *MinerClient) Query() *MinerQuery
Query returns a query builder for Miner.
func (*MinerClient) Update ¶
func (c *MinerClient) Update() *MinerUpdate
Update returns an update builder for Miner.
func (*MinerClient) UpdateOne ¶
func (c *MinerClient) UpdateOne(m *Miner) *MinerUpdateOne
UpdateOne returns an update builder for the given entity.
func (*MinerClient) UpdateOneID ¶
func (c *MinerClient) UpdateOneID(id int) *MinerUpdateOne
UpdateOneID returns an update builder for the given id.
func (*MinerClient) Use ¶
func (c *MinerClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `miner.Hooks(f(g(h())))`.
type MinerCreate ¶
type MinerCreate struct {
// contains filtered or unexported fields
}
MinerCreate is the builder for creating a Miner entity.
func (*MinerCreate) Mutation ¶
func (mc *MinerCreate) Mutation() *MinerMutation
Mutation returns the MinerMutation object of the builder.
func (*MinerCreate) Save ¶
func (mc *MinerCreate) Save(ctx context.Context) (*Miner, error)
Save creates the Miner in the database.
func (*MinerCreate) SaveX ¶
func (mc *MinerCreate) SaveX(ctx context.Context) *Miner
SaveX calls Save and panics if Save returns an error.
func (*MinerCreate) SetMinerID ¶
func (mc *MinerCreate) SetMinerID(s string) *MinerCreate
SetMinerID sets the miner_id field.
func (*MinerCreate) SetOwnerAddr ¶
func (mc *MinerCreate) SetOwnerAddr(s string) *MinerCreate
SetOwnerAddr sets the owner_addr field.
func (*MinerCreate) SetPeerID ¶
func (mc *MinerCreate) SetPeerID(s string) *MinerCreate
SetPeerID sets the peer_id field.
func (*MinerCreate) SetSectorSize ¶
func (mc *MinerCreate) SetSectorSize(s string) *MinerCreate
SetSectorSize sets the sector_size field.
func (*MinerCreate) SetStateRoot ¶
func (mc *MinerCreate) SetStateRoot(s string) *MinerCreate
SetStateRoot sets the state_root field.
func (*MinerCreate) SetWorkerAddr ¶
func (mc *MinerCreate) SetWorkerAddr(s string) *MinerCreate
SetWorkerAddr sets the worker_addr field.
type MinerCreateBulk ¶
type MinerCreateBulk struct {
// contains filtered or unexported fields
}
MinerCreateBulk is the builder for creating a bulk of Miner entities.
type MinerDelete ¶
type MinerDelete struct {
// contains filtered or unexported fields
}
MinerDelete is the builder for deleting a Miner entity.
func (*MinerDelete) Exec ¶
func (md *MinerDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*MinerDelete) ExecX ¶
func (md *MinerDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*MinerDelete) Where ¶
func (md *MinerDelete) Where(ps ...predicate.Miner) *MinerDelete
Where adds a new predicate to the delete builder.
type MinerDeleteOne ¶
type MinerDeleteOne struct {
// contains filtered or unexported fields
}
MinerDeleteOne is the builder for deleting a single Miner entity.
func (*MinerDeleteOne) Exec ¶
func (mdo *MinerDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*MinerDeleteOne) ExecX ¶
func (mdo *MinerDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type MinerGroupBy ¶
type MinerGroupBy struct {
// contains filtered or unexported fields
}
MinerGroupBy is the builder for group-by Miner entities.
func (*MinerGroupBy) Aggregate ¶
func (mgb *MinerGroupBy) Aggregate(fns ...AggregateFunc) *MinerGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*MinerGroupBy) Bool ¶
func (mgb *MinerGroupBy) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
func (*MinerGroupBy) BoolX ¶
func (mgb *MinerGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*MinerGroupBy) Bools ¶
func (mgb *MinerGroupBy) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
func (*MinerGroupBy) BoolsX ¶
func (mgb *MinerGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*MinerGroupBy) Float64 ¶
func (mgb *MinerGroupBy) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
func (*MinerGroupBy) Float64X ¶
func (mgb *MinerGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*MinerGroupBy) Float64s ¶
func (mgb *MinerGroupBy) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
func (*MinerGroupBy) Float64sX ¶
func (mgb *MinerGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*MinerGroupBy) Int ¶
func (mgb *MinerGroupBy) Int(ctx context.Context) (_ int, err error)
Int returns a single int from group-by. It is only allowed when querying group-by with one field.
func (*MinerGroupBy) IntX ¶
func (mgb *MinerGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*MinerGroupBy) Ints ¶
func (mgb *MinerGroupBy) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
func (*MinerGroupBy) IntsX ¶
func (mgb *MinerGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*MinerGroupBy) Scan ¶
func (mgb *MinerGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scan the result into the given value.
func (*MinerGroupBy) ScanX ¶
func (mgb *MinerGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*MinerGroupBy) String ¶
func (mgb *MinerGroupBy) String(ctx context.Context) (_ string, err error)
String returns a single string from group-by. It is only allowed when querying group-by with one field.
func (*MinerGroupBy) StringX ¶
func (mgb *MinerGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type MinerMutation ¶
type MinerMutation struct {
// contains filtered or unexported fields
}
MinerMutation represents an operation that mutate the Miners nodes in the graph.
func (*MinerMutation) AddField ¶
func (m *MinerMutation) AddField(name string, value ent.Value) error
AddField adds the value for the given name. It returns an error if the field is not defined in the schema, or if the type mismatch the field type.
func (*MinerMutation) AddedEdges ¶
func (m *MinerMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*MinerMutation) AddedField ¶
func (m *MinerMutation) AddedField(name string) (ent.Value, bool)
AddedField returns the numeric value that was in/decremented from a field with the given name. The second value indicates that this field was not set, or was not define in the schema.
func (*MinerMutation) AddedFields ¶
func (m *MinerMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented or decremented during this mutation.
func (*MinerMutation) AddedIDs ¶
func (m *MinerMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all ids (to other nodes) that were added for the given edge name.
func (*MinerMutation) ClearEdge ¶
func (m *MinerMutation) ClearEdge(name string) error
ClearEdge clears the value for the given name. It returns an error if the edge name is not defined in the schema.
func (*MinerMutation) ClearField ¶
func (m *MinerMutation) ClearField(name string) error
ClearField clears the value for the given name. It returns an error if the field is not defined in the schema.
func (*MinerMutation) ClearedEdges ¶
func (m *MinerMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*MinerMutation) ClearedFields ¶
func (m *MinerMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (MinerMutation) Client ¶
func (m MinerMutation) 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 (*MinerMutation) EdgeCleared ¶
func (m *MinerMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean indicates if this edge was cleared in this mutation.
func (*MinerMutation) Field ¶
func (m *MinerMutation) Field(name string) (ent.Value, bool)
Field returns the value of a field with the given name. The second boolean value indicates that this field was not set, or was not define in the schema.
func (*MinerMutation) FieldCleared ¶
func (m *MinerMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicates if this field was cleared in this mutation.
func (*MinerMutation) Fields ¶
func (m *MinerMutation) Fields() []string
Fields returns all fields that were changed during this mutation. Note that, in order to get all numeric fields that were in/decremented, call AddedFields().
func (*MinerMutation) ID ¶
func (m *MinerMutation) ID() (id int, exists bool)
ID returns the id value in the mutation. Note that, the id is available only if it was provided to the builder.
func (*MinerMutation) MinerID ¶
func (m *MinerMutation) MinerID() (r string, exists bool)
MinerID returns the miner_id value in the mutation.
func (*MinerMutation) OldField ¶
OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database was failed.
func (*MinerMutation) OldMinerID ¶
func (m *MinerMutation) OldMinerID(ctx context.Context) (v string, err error)
OldMinerID returns the old miner_id value of the Miner. If the Miner object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or database query fails.
func (*MinerMutation) OldOwnerAddr ¶
func (m *MinerMutation) OldOwnerAddr(ctx context.Context) (v string, err error)
OldOwnerAddr returns the old owner_addr value of the Miner. If the Miner object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or database query fails.
func (*MinerMutation) OldPeerID ¶
func (m *MinerMutation) OldPeerID(ctx context.Context) (v string, err error)
OldPeerID returns the old peer_id value of the Miner. If the Miner object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or database query fails.
func (*MinerMutation) OldSectorSize ¶
func (m *MinerMutation) OldSectorSize(ctx context.Context) (v string, err error)
OldSectorSize returns the old sector_size value of the Miner. If the Miner object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or database query fails.
func (*MinerMutation) OldStateRoot ¶
func (m *MinerMutation) OldStateRoot(ctx context.Context) (v string, err error)
OldStateRoot returns the old state_root value of the Miner. If the Miner object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or database query fails.
func (*MinerMutation) OldWorkerAddr ¶
func (m *MinerMutation) OldWorkerAddr(ctx context.Context) (v string, err error)
OldWorkerAddr returns the old worker_addr value of the Miner. If the Miner object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or database query fails.
func (*MinerMutation) OwnerAddr ¶
func (m *MinerMutation) OwnerAddr() (r string, exists bool)
OwnerAddr returns the owner_addr value in the mutation.
func (*MinerMutation) PeerID ¶
func (m *MinerMutation) PeerID() (r string, exists bool)
PeerID returns the peer_id value in the mutation.
func (*MinerMutation) RemovedEdges ¶
func (m *MinerMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*MinerMutation) RemovedIDs ¶
func (m *MinerMutation) RemovedIDs(name string) []ent.Value
RemovedIDs returns all ids (to other nodes) that were removed for the given edge name.
func (*MinerMutation) ResetEdge ¶
func (m *MinerMutation) ResetEdge(name string) error
ResetEdge resets all changes in the mutation regarding the given edge name. It returns an error if the edge is not defined in the schema.
func (*MinerMutation) ResetField ¶
func (m *MinerMutation) ResetField(name string) error
ResetField resets all changes in the mutation regarding the given field name. It returns an error if the field is not defined in the schema.
func (*MinerMutation) ResetMinerID ¶
func (m *MinerMutation) ResetMinerID()
ResetMinerID reset all changes of the "miner_id" field.
func (*MinerMutation) ResetOwnerAddr ¶
func (m *MinerMutation) ResetOwnerAddr()
ResetOwnerAddr reset all changes of the "owner_addr" field.
func (*MinerMutation) ResetPeerID ¶
func (m *MinerMutation) ResetPeerID()
ResetPeerID reset all changes of the "peer_id" field.
func (*MinerMutation) ResetSectorSize ¶
func (m *MinerMutation) ResetSectorSize()
ResetSectorSize reset all changes of the "sector_size" field.
func (*MinerMutation) ResetStateRoot ¶
func (m *MinerMutation) ResetStateRoot()
ResetStateRoot reset all changes of the "state_root" field.
func (*MinerMutation) ResetWorkerAddr ¶
func (m *MinerMutation) ResetWorkerAddr()
ResetWorkerAddr reset all changes of the "worker_addr" field.
func (*MinerMutation) SectorSize ¶
func (m *MinerMutation) SectorSize() (r string, exists bool)
SectorSize returns the sector_size value in the mutation.
func (*MinerMutation) SetField ¶
func (m *MinerMutation) SetField(name string, value ent.Value) error
SetField sets the value for the given name. It returns an error if the field is not defined in the schema, or if the type mismatch the field type.
func (*MinerMutation) SetMinerID ¶
func (m *MinerMutation) SetMinerID(s string)
SetMinerID sets the miner_id field.
func (*MinerMutation) SetOwnerAddr ¶
func (m *MinerMutation) SetOwnerAddr(s string)
SetOwnerAddr sets the owner_addr field.
func (*MinerMutation) SetPeerID ¶
func (m *MinerMutation) SetPeerID(s string)
SetPeerID sets the peer_id field.
func (*MinerMutation) SetSectorSize ¶
func (m *MinerMutation) SetSectorSize(s string)
SetSectorSize sets the sector_size field.
func (*MinerMutation) SetStateRoot ¶
func (m *MinerMutation) SetStateRoot(s string)
SetStateRoot sets the state_root field.
func (*MinerMutation) SetWorkerAddr ¶
func (m *MinerMutation) SetWorkerAddr(s string)
SetWorkerAddr sets the worker_addr field.
func (*MinerMutation) StateRoot ¶
func (m *MinerMutation) StateRoot() (r string, exists bool)
StateRoot returns the state_root value in the mutation.
func (MinerMutation) Tx ¶
func (m MinerMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*MinerMutation) Type ¶
func (m *MinerMutation) Type() string
Type returns the node type of this mutation (Miner).
func (*MinerMutation) WorkerAddr ¶
func (m *MinerMutation) WorkerAddr() (r string, exists bool)
WorkerAddr returns the worker_addr value in the mutation.
type MinerQuery ¶
type MinerQuery struct {
// contains filtered or unexported fields
}
MinerQuery is the builder for querying Miner entities.
func (*MinerQuery) All ¶
func (mq *MinerQuery) All(ctx context.Context) ([]*Miner, error)
All executes the query and returns a list of Miners.
func (*MinerQuery) AllX ¶
func (mq *MinerQuery) AllX(ctx context.Context) []*Miner
AllX is like All, but panics if an error occurs.
func (*MinerQuery) Clone ¶
func (mq *MinerQuery) Clone() *MinerQuery
Clone returns a duplicate of the query builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*MinerQuery) Count ¶
func (mq *MinerQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*MinerQuery) CountX ¶
func (mq *MinerQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*MinerQuery) Exist ¶
func (mq *MinerQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*MinerQuery) ExistX ¶
func (mq *MinerQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*MinerQuery) First ¶
func (mq *MinerQuery) First(ctx context.Context) (*Miner, error)
First returns the first Miner entity in the query. Returns *NotFoundError when no miner was found.
func (*MinerQuery) FirstID ¶
func (mq *MinerQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Miner id in the query. Returns *NotFoundError when no id was found.
func (*MinerQuery) FirstX ¶
func (mq *MinerQuery) FirstX(ctx context.Context) *Miner
FirstX is like First, but panics if an error occurs.
func (*MinerQuery) FirstXID ¶
func (mq *MinerQuery) FirstXID(ctx context.Context) int
FirstXID is like FirstID, but panics if an error occurs.
func (*MinerQuery) GroupBy ¶
func (mq *MinerQuery) GroupBy(field string, fields ...string) *MinerGroupBy
GroupBy used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.
Example:
var v []struct { StateRoot string `json:"state_root,omitempty"` Count int `json:"count,omitempty"` } client.Miner.Query(). GroupBy(miner.FieldStateRoot). Aggregate(ent.Count()). Scan(ctx, &v)
func (*MinerQuery) IDs ¶
func (mq *MinerQuery) IDs(ctx context.Context) ([]int, error)
IDs executes the query and returns a list of Miner ids.
func (*MinerQuery) IDsX ¶
func (mq *MinerQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*MinerQuery) Limit ¶
func (mq *MinerQuery) Limit(limit int) *MinerQuery
Limit adds a limit step to the query.
func (*MinerQuery) Offset ¶
func (mq *MinerQuery) Offset(offset int) *MinerQuery
Offset adds an offset step to the query.
func (*MinerQuery) Only ¶
func (mq *MinerQuery) Only(ctx context.Context) (*Miner, error)
Only returns the only Miner entity in the query, returns an error if not exactly one entity was returned.
func (*MinerQuery) OnlyID ¶
func (mq *MinerQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID returns the only Miner id in the query, returns an error if not exactly one id was returned.
func (*MinerQuery) OnlyIDX ¶
func (mq *MinerQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*MinerQuery) OnlyX ¶
func (mq *MinerQuery) OnlyX(ctx context.Context) *Miner
OnlyX is like Only, but panics if an error occurs.
func (*MinerQuery) Order ¶
func (mq *MinerQuery) Order(o ...OrderFunc) *MinerQuery
Order adds an order step to the query.
func (*MinerQuery) Select ¶
func (mq *MinerQuery) Select(field string, fields ...string) *MinerSelect
Select one or more fields from the given query.
Example:
var v []struct { StateRoot string `json:"state_root,omitempty"` } client.Miner.Query(). Select(miner.FieldStateRoot). Scan(ctx, &v)
func (*MinerQuery) Where ¶
func (mq *MinerQuery) Where(ps ...predicate.Miner) *MinerQuery
Where adds a new predicate for the builder.
type MinerSelect ¶
type MinerSelect struct {
// contains filtered or unexported fields
}
MinerSelect is the builder for select fields of Miner entities.
func (*MinerSelect) Bool ¶
func (ms *MinerSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from selector. It is only allowed when selecting one field.
func (*MinerSelect) BoolX ¶
func (ms *MinerSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*MinerSelect) Bools ¶
func (ms *MinerSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from selector. It is only allowed when selecting one field.
func (*MinerSelect) BoolsX ¶
func (ms *MinerSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*MinerSelect) Float64 ¶
func (ms *MinerSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from selector. It is only allowed when selecting one field.
func (*MinerSelect) Float64X ¶
func (ms *MinerSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*MinerSelect) Float64s ¶
func (ms *MinerSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from selector. It is only allowed when selecting one field.
func (*MinerSelect) Float64sX ¶
func (ms *MinerSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*MinerSelect) Int ¶
func (ms *MinerSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from selector. It is only allowed when selecting one field.
func (*MinerSelect) IntX ¶
func (ms *MinerSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*MinerSelect) Ints ¶
func (ms *MinerSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from selector. It is only allowed when selecting one field.
func (*MinerSelect) IntsX ¶
func (ms *MinerSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*MinerSelect) Scan ¶
func (ms *MinerSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scan the result into the given value.
func (*MinerSelect) ScanX ¶
func (ms *MinerSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*MinerSelect) String ¶
func (ms *MinerSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from selector. It is only allowed when selecting one field.
func (*MinerSelect) StringX ¶
func (ms *MinerSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type MinerUpdate ¶
type MinerUpdate struct {
// contains filtered or unexported fields
}
MinerUpdate is the builder for updating Miner entities.
func (*MinerUpdate) Exec ¶
func (mu *MinerUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*MinerUpdate) ExecX ¶
func (mu *MinerUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*MinerUpdate) Mutation ¶
func (mu *MinerUpdate) Mutation() *MinerMutation
Mutation returns the MinerMutation object of the builder.
func (*MinerUpdate) Save ¶
func (mu *MinerUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of rows/vertices matched by this operation.
func (*MinerUpdate) SaveX ¶
func (mu *MinerUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*MinerUpdate) SetMinerID ¶
func (mu *MinerUpdate) SetMinerID(s string) *MinerUpdate
SetMinerID sets the miner_id field.
func (*MinerUpdate) SetOwnerAddr ¶
func (mu *MinerUpdate) SetOwnerAddr(s string) *MinerUpdate
SetOwnerAddr sets the owner_addr field.
func (*MinerUpdate) SetPeerID ¶
func (mu *MinerUpdate) SetPeerID(s string) *MinerUpdate
SetPeerID sets the peer_id field.
func (*MinerUpdate) SetSectorSize ¶
func (mu *MinerUpdate) SetSectorSize(s string) *MinerUpdate
SetSectorSize sets the sector_size field.
func (*MinerUpdate) SetStateRoot ¶
func (mu *MinerUpdate) SetStateRoot(s string) *MinerUpdate
SetStateRoot sets the state_root field.
func (*MinerUpdate) SetWorkerAddr ¶
func (mu *MinerUpdate) SetWorkerAddr(s string) *MinerUpdate
SetWorkerAddr sets the worker_addr field.
func (*MinerUpdate) Where ¶
func (mu *MinerUpdate) Where(ps ...predicate.Miner) *MinerUpdate
Where adds a new predicate for the builder.
type MinerUpdateOne ¶
type MinerUpdateOne struct {
// contains filtered or unexported fields
}
MinerUpdateOne is the builder for updating a single Miner entity.
func (*MinerUpdateOne) Exec ¶
func (muo *MinerUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*MinerUpdateOne) ExecX ¶
func (muo *MinerUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*MinerUpdateOne) Mutation ¶
func (muo *MinerUpdateOne) Mutation() *MinerMutation
Mutation returns the MinerMutation object of the builder.
func (*MinerUpdateOne) Save ¶
func (muo *MinerUpdateOne) Save(ctx context.Context) (*Miner, error)
Save executes the query and returns the updated entity.
func (*MinerUpdateOne) SaveX ¶
func (muo *MinerUpdateOne) SaveX(ctx context.Context) *Miner
SaveX is like Save, but panics if an error occurs.
func (*MinerUpdateOne) SetMinerID ¶
func (muo *MinerUpdateOne) SetMinerID(s string) *MinerUpdateOne
SetMinerID sets the miner_id field.
func (*MinerUpdateOne) SetOwnerAddr ¶
func (muo *MinerUpdateOne) SetOwnerAddr(s string) *MinerUpdateOne
SetOwnerAddr sets the owner_addr field.
func (*MinerUpdateOne) SetPeerID ¶
func (muo *MinerUpdateOne) SetPeerID(s string) *MinerUpdateOne
SetPeerID sets the peer_id field.
func (*MinerUpdateOne) SetSectorSize ¶
func (muo *MinerUpdateOne) SetSectorSize(s string) *MinerUpdateOne
SetSectorSize sets the sector_size field.
func (*MinerUpdateOne) SetStateRoot ¶
func (muo *MinerUpdateOne) SetStateRoot(s string) *MinerUpdateOne
SetStateRoot sets the state_root field.
func (*MinerUpdateOne) SetWorkerAddr ¶
func (muo *MinerUpdateOne) SetWorkerAddr(s string) *MinerUpdateOne
SetWorkerAddr sets the worker_addr field.
type MutateFunc ¶
type MutateFunc = ent.MutateFunc
ent aliases to avoid import conflict 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 { // Miner is the client for interacting with the Miner builders. Miner *MinerClient // contains filtered or unexported fields }
Tx is a transactional client that is created by calling Client.Tx().
func TxFromContext ¶
TxFromContext returns the Tx stored in a context, or nil if there isn't one.
func (*Tx) OnRollback ¶
func (tx *Tx) OnRollback(f RollbackHook)
OnRollback adds a hook to call on rollback.
type ValidationError ¶
type ValidationError struct { Name string // Field or edge name. // contains filtered or unexported fields }
ValidationError returns when validating a field fails.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap implements the errors.Wrapper interface.