Documentation
¶
Index ¶
- Constants
- Variables
- func Asc(fields ...string) func(*sql.Selector)
- func Desc(fields ...string) func(*sql.Selector)
- 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
- func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (c *Client) Close() error
- func (c *Client) Debug() *Client
- func (c *Client) Intercept(interceptors ...Interceptor)
- func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error)
- func (c *Client) Tx(ctx context.Context) (*Tx, error)
- func (c *Client) Use(hooks ...Hook)
- type CommitFunc
- type CommitHook
- type Committer
- type ConstraintError
- type Hook
- type InterceptFunc
- type Interceptor
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- type Policy
- type Querier
- type QuerierFunc
- type Query
- type QueryContext
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- type Token
- type TokenClient
- func (c *TokenClient) Create() *TokenCreate
- func (c *TokenClient) CreateBulk(builders ...*TokenCreate) *TokenCreateBulk
- func (c *TokenClient) Delete() *TokenDelete
- func (c *TokenClient) DeleteOne(t *Token) *TokenDeleteOne
- func (c *TokenClient) DeleteOneID(id int) *TokenDeleteOne
- func (c *TokenClient) Get(ctx context.Context, id int) (*Token, error)
- func (c *TokenClient) GetX(ctx context.Context, id int) *Token
- func (c *TokenClient) Hooks() []Hook
- func (c *TokenClient) Intercept(interceptors ...Interceptor)
- func (c *TokenClient) Interceptors() []Interceptor
- func (c *TokenClient) MapCreateBulk(slice any, setFunc func(*TokenCreate, int)) *TokenCreateBulk
- func (c *TokenClient) Query() *TokenQuery
- func (c *TokenClient) Update() *TokenUpdate
- func (c *TokenClient) UpdateOne(t *Token) *TokenUpdateOne
- func (c *TokenClient) UpdateOneID(id int) *TokenUpdateOne
- func (c *TokenClient) Use(hooks ...Hook)
- type TokenCreate
- func (tc *TokenCreate) Exec(ctx context.Context) error
- func (tc *TokenCreate) ExecX(ctx context.Context)
- func (tc *TokenCreate) Mutation() *TokenMutation
- func (tc *TokenCreate) Save(ctx context.Context) (*Token, error)
- func (tc *TokenCreate) SaveX(ctx context.Context) *Token
- func (tc *TokenCreate) SetCreatedAt(t time.Time) *TokenCreate
- func (tc *TokenCreate) SetHash(b []byte) *TokenCreate
- func (tc *TokenCreate) SetHeaders(t types.Headers) *TokenCreate
- func (tc *TokenCreate) SetHost(s string) *TokenCreate
- func (tc *TokenCreate) SetID(i int) *TokenCreate
- func (tc *TokenCreate) SetKeyID(ti *types.KeyID) *TokenCreate
- func (tc *TokenCreate) SetLabel(s string) *TokenCreate
- func (tc *TokenCreate) SetLastAccessAt(t time.Time) *TokenCreate
- func (tc *TokenCreate) SetNillableCreatedAt(t *time.Time) *TokenCreate
- func (tc *TokenCreate) SetNillableHost(s *string) *TokenCreate
- func (tc *TokenCreate) SetNillableLabel(s *string) *TokenCreate
- func (tc *TokenCreate) SetNillableLastAccessAt(t *time.Time) *TokenCreate
- func (tc *TokenCreate) SetNillablePath(s *string) *TokenCreate
- func (tc *TokenCreate) SetNillableRequests(i *int64) *TokenCreate
- func (tc *TokenCreate) SetNillableUpdatedAt(t *time.Time) *TokenCreate
- func (tc *TokenCreate) SetPath(s string) *TokenCreate
- func (tc *TokenCreate) SetRequests(i int64) *TokenCreate
- func (tc *TokenCreate) SetUpdatedAt(t time.Time) *TokenCreate
- func (tc *TokenCreate) SetUser(s string) *TokenCreate
- type TokenCreateBulk
- type TokenDelete
- type TokenDeleteOne
- type TokenGroupBy
- func (tgb *TokenGroupBy) Aggregate(fns ...AggregateFunc) *TokenGroupBy
- func (s *TokenGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *TokenGroupBy) BoolX(ctx context.Context) bool
- func (s *TokenGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *TokenGroupBy) BoolsX(ctx context.Context) []bool
- func (s *TokenGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *TokenGroupBy) Float64X(ctx context.Context) float64
- func (s *TokenGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *TokenGroupBy) Float64sX(ctx context.Context) []float64
- func (s *TokenGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *TokenGroupBy) IntX(ctx context.Context) int
- func (s *TokenGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *TokenGroupBy) IntsX(ctx context.Context) []int
- func (tgb *TokenGroupBy) Scan(ctx context.Context, v any) error
- func (s *TokenGroupBy) ScanX(ctx context.Context, v any)
- func (s *TokenGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *TokenGroupBy) StringX(ctx context.Context) string
- func (s *TokenGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *TokenGroupBy) StringsX(ctx context.Context) []string
- type TokenMutation
- func (m *TokenMutation) AddField(name string, value ent.Value) error
- func (m *TokenMutation) AddRequests(i int64)
- func (m *TokenMutation) AddedEdges() []string
- func (m *TokenMutation) AddedField(name string) (ent.Value, bool)
- func (m *TokenMutation) AddedFields() []string
- func (m *TokenMutation) AddedIDs(name string) []ent.Value
- func (m *TokenMutation) AddedRequests() (r int64, exists bool)
- func (m *TokenMutation) AppendHeaders(t types.Headers)
- func (m *TokenMutation) AppendedHeaders() (types.Headers, bool)
- func (m *TokenMutation) ClearEdge(name string) error
- func (m *TokenMutation) ClearField(name string) error
- func (m *TokenMutation) ClearHeaders()
- func (m *TokenMutation) ClearedEdges() []string
- func (m *TokenMutation) ClearedFields() []string
- func (m TokenMutation) Client() *Client
- func (m *TokenMutation) CreatedAt() (r time.Time, exists bool)
- func (m *TokenMutation) EdgeCleared(name string) bool
- func (m *TokenMutation) Field(name string) (ent.Value, bool)
- func (m *TokenMutation) FieldCleared(name string) bool
- func (m *TokenMutation) Fields() []string
- func (m *TokenMutation) Hash() (r []byte, exists bool)
- func (m *TokenMutation) Headers() (r types.Headers, exists bool)
- func (m *TokenMutation) HeadersCleared() bool
- func (m *TokenMutation) Host() (r string, exists bool)
- func (m *TokenMutation) ID() (id int, exists bool)
- func (m *TokenMutation) IDs(ctx context.Context) ([]int, error)
- func (m *TokenMutation) KeyID() (r *types.KeyID, exists bool)
- func (m *TokenMutation) Label() (r string, exists bool)
- func (m *TokenMutation) LastAccessAt() (r time.Time, exists bool)
- func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)
- func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *TokenMutation) OldHash(ctx context.Context) (v []byte, err error)
- func (m *TokenMutation) OldHeaders(ctx context.Context) (v types.Headers, err error)
- func (m *TokenMutation) OldHost(ctx context.Context) (v string, err error)
- func (m *TokenMutation) OldKeyID(ctx context.Context) (v *types.KeyID, err error)
- func (m *TokenMutation) OldLabel(ctx context.Context) (v string, err error)
- func (m *TokenMutation) OldLastAccessAt(ctx context.Context) (v time.Time, err error)
- func (m *TokenMutation) OldPath(ctx context.Context) (v string, err error)
- func (m *TokenMutation) OldRequests(ctx context.Context) (v int64, err error)
- func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)
- func (m *TokenMutation) OldUser(ctx context.Context) (v string, err error)
- func (m *TokenMutation) Op() Op
- func (m *TokenMutation) Path() (r string, exists bool)
- func (m *TokenMutation) RemovedEdges() []string
- func (m *TokenMutation) RemovedIDs(name string) []ent.Value
- func (m *TokenMutation) Requests() (r int64, exists bool)
- func (m *TokenMutation) ResetCreatedAt()
- func (m *TokenMutation) ResetEdge(name string) error
- func (m *TokenMutation) ResetField(name string) error
- func (m *TokenMutation) ResetHash()
- func (m *TokenMutation) ResetHeaders()
- func (m *TokenMutation) ResetHost()
- func (m *TokenMutation) ResetKeyID()
- func (m *TokenMutation) ResetLabel()
- func (m *TokenMutation) ResetLastAccessAt()
- func (m *TokenMutation) ResetPath()
- func (m *TokenMutation) ResetRequests()
- func (m *TokenMutation) ResetUpdatedAt()
- func (m *TokenMutation) ResetUser()
- func (m *TokenMutation) SetCreatedAt(t time.Time)
- func (m *TokenMutation) SetField(name string, value ent.Value) error
- func (m *TokenMutation) SetHash(b []byte)
- func (m *TokenMutation) SetHeaders(t types.Headers)
- func (m *TokenMutation) SetHost(s string)
- func (m *TokenMutation) SetID(id int)
- func (m *TokenMutation) SetKeyID(ti *types.KeyID)
- func (m *TokenMutation) SetLabel(s string)
- func (m *TokenMutation) SetLastAccessAt(t time.Time)
- func (m *TokenMutation) SetOp(op Op)
- func (m *TokenMutation) SetPath(s string)
- func (m *TokenMutation) SetRequests(i int64)
- func (m *TokenMutation) SetUpdatedAt(t time.Time)
- func (m *TokenMutation) SetUser(s string)
- func (m TokenMutation) Tx() (*Tx, error)
- func (m *TokenMutation) Type() string
- func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool)
- func (m *TokenMutation) User() (r string, exists bool)
- func (m *TokenMutation) Where(ps ...predicate.Token)
- func (m *TokenMutation) WhereP(ps ...func(*sql.Selector))
- type TokenQuery
- func (tq *TokenQuery) Aggregate(fns ...AggregateFunc) *TokenSelect
- func (tq *TokenQuery) All(ctx context.Context) ([]*Token, error)
- func (tq *TokenQuery) AllX(ctx context.Context) []*Token
- func (tq *TokenQuery) Clone() *TokenQuery
- func (tq *TokenQuery) Count(ctx context.Context) (int, error)
- func (tq *TokenQuery) CountX(ctx context.Context) int
- func (tq *TokenQuery) Exist(ctx context.Context) (bool, error)
- func (tq *TokenQuery) ExistX(ctx context.Context) bool
- func (tq *TokenQuery) First(ctx context.Context) (*Token, error)
- func (tq *TokenQuery) FirstID(ctx context.Context) (id int, err error)
- func (tq *TokenQuery) FirstIDX(ctx context.Context) int
- func (tq *TokenQuery) FirstX(ctx context.Context) *Token
- func (tq *TokenQuery) GroupBy(field string, fields ...string) *TokenGroupBy
- func (tq *TokenQuery) IDs(ctx context.Context) (ids []int, err error)
- func (tq *TokenQuery) IDsX(ctx context.Context) []int
- func (tq *TokenQuery) Limit(limit int) *TokenQuery
- func (tq *TokenQuery) Offset(offset int) *TokenQuery
- func (tq *TokenQuery) Only(ctx context.Context) (*Token, error)
- func (tq *TokenQuery) OnlyID(ctx context.Context) (id int, err error)
- func (tq *TokenQuery) OnlyIDX(ctx context.Context) int
- func (tq *TokenQuery) OnlyX(ctx context.Context) *Token
- func (tq *TokenQuery) Order(o ...token.OrderOption) *TokenQuery
- func (tq *TokenQuery) Select(fields ...string) *TokenSelect
- func (tq *TokenQuery) Unique(unique bool) *TokenQuery
- func (tq *TokenQuery) Where(ps ...predicate.Token) *TokenQuery
- type TokenSelect
- func (ts *TokenSelect) Aggregate(fns ...AggregateFunc) *TokenSelect
- func (s *TokenSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *TokenSelect) BoolX(ctx context.Context) bool
- func (s *TokenSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *TokenSelect) BoolsX(ctx context.Context) []bool
- func (s *TokenSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *TokenSelect) Float64X(ctx context.Context) float64
- func (s *TokenSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *TokenSelect) Float64sX(ctx context.Context) []float64
- func (s *TokenSelect) Int(ctx context.Context) (_ int, err error)
- func (s *TokenSelect) IntX(ctx context.Context) int
- func (s *TokenSelect) Ints(ctx context.Context) ([]int, error)
- func (s *TokenSelect) IntsX(ctx context.Context) []int
- func (ts *TokenSelect) Scan(ctx context.Context, v any) error
- func (s *TokenSelect) ScanX(ctx context.Context, v any)
- func (s *TokenSelect) String(ctx context.Context) (_ string, err error)
- func (s *TokenSelect) StringX(ctx context.Context) string
- func (s *TokenSelect) Strings(ctx context.Context) ([]string, error)
- func (s *TokenSelect) StringsX(ctx context.Context) []string
- type TokenUpdate
- func (tu *TokenUpdate) AddRequests(i int64) *TokenUpdate
- func (tu *TokenUpdate) AppendHeaders(t types.Headers) *TokenUpdate
- func (tu *TokenUpdate) ClearHeaders() *TokenUpdate
- func (tu *TokenUpdate) Exec(ctx context.Context) error
- func (tu *TokenUpdate) ExecX(ctx context.Context)
- func (tu *TokenUpdate) Mutation() *TokenMutation
- func (tu *TokenUpdate) Save(ctx context.Context) (int, error)
- func (tu *TokenUpdate) SaveX(ctx context.Context) int
- func (tu *TokenUpdate) SetCreatedAt(t time.Time) *TokenUpdate
- func (tu *TokenUpdate) SetHash(b []byte) *TokenUpdate
- func (tu *TokenUpdate) SetHeaders(t types.Headers) *TokenUpdate
- func (tu *TokenUpdate) SetHost(s string) *TokenUpdate
- func (tu *TokenUpdate) SetKeyID(ti *types.KeyID) *TokenUpdate
- func (tu *TokenUpdate) SetLabel(s string) *TokenUpdate
- func (tu *TokenUpdate) SetLastAccessAt(t time.Time) *TokenUpdate
- func (tu *TokenUpdate) SetNillableCreatedAt(t *time.Time) *TokenUpdate
- func (tu *TokenUpdate) SetNillableHost(s *string) *TokenUpdate
- func (tu *TokenUpdate) SetNillableLabel(s *string) *TokenUpdate
- func (tu *TokenUpdate) SetNillableLastAccessAt(t *time.Time) *TokenUpdate
- func (tu *TokenUpdate) SetNillablePath(s *string) *TokenUpdate
- func (tu *TokenUpdate) SetNillableRequests(i *int64) *TokenUpdate
- func (tu *TokenUpdate) SetNillableUser(s *string) *TokenUpdate
- func (tu *TokenUpdate) SetPath(s string) *TokenUpdate
- func (tu *TokenUpdate) SetRequests(i int64) *TokenUpdate
- func (tu *TokenUpdate) SetUpdatedAt(t time.Time) *TokenUpdate
- func (tu *TokenUpdate) SetUser(s string) *TokenUpdate
- func (tu *TokenUpdate) Where(ps ...predicate.Token) *TokenUpdate
- type TokenUpdateOne
- func (tuo *TokenUpdateOne) AddRequests(i int64) *TokenUpdateOne
- func (tuo *TokenUpdateOne) AppendHeaders(t types.Headers) *TokenUpdateOne
- func (tuo *TokenUpdateOne) ClearHeaders() *TokenUpdateOne
- func (tuo *TokenUpdateOne) Exec(ctx context.Context) error
- func (tuo *TokenUpdateOne) ExecX(ctx context.Context)
- func (tuo *TokenUpdateOne) Mutation() *TokenMutation
- func (tuo *TokenUpdateOne) Save(ctx context.Context) (*Token, error)
- func (tuo *TokenUpdateOne) SaveX(ctx context.Context) *Token
- func (tuo *TokenUpdateOne) Select(field string, fields ...string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetCreatedAt(t time.Time) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetHash(b []byte) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetHeaders(t types.Headers) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetHost(s string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetKeyID(ti *types.KeyID) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetLabel(s string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetLastAccessAt(t time.Time) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetNillableCreatedAt(t *time.Time) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetNillableHost(s *string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetNillableLabel(s *string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetNillableLastAccessAt(t *time.Time) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetNillablePath(s *string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetNillableRequests(i *int64) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetNillableUser(s *string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetPath(s string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetRequests(i int64) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetUpdatedAt(t time.Time) *TokenUpdateOne
- func (tuo *TokenUpdateOne) SetUser(s string) *TokenUpdateOne
- func (tuo *TokenUpdateOne) Where(ps ...predicate.Token) *TokenUpdateOne
- type Tokens
- type TraverseFunc
- type Traverser
- 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. TypeToken = "Token" )
Variables ¶
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
ErrTxStarted is returned when trying to start a new transaction from a transactional client.
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
// Token is the client for interacting with the Token builders.
Token *TokenClient
// 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(). Token. Query(). Count(ctx)
func (*Client) Intercept ¶
func (c *Client) Intercept(interceptors ...Interceptor)
Intercept adds the query interceptors to all the entity clients. In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
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 InterceptFunc ¶
type InterceptFunc = ent.InterceptFunc
ent aliases to avoid import conflicts in user's code.
type Interceptor ¶
type Interceptor = ent.Interceptor
ent aliases to avoid import conflicts in user's code.
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 OrderFunc ¶
OrderFunc applies an ordering on the sql selector. Deprecated: Use Asc/Desc functions or the package builders instead.
type QuerierFunc ¶
type QuerierFunc = ent.QuerierFunc
ent aliases to avoid import conflicts in user's code.
type QueryContext ¶
type QueryContext = ent.QueryContext
ent aliases to avoid import conflicts in user's code.
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 Token ¶
type Token struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// KeyID holds the value of the "key_id" field.
KeyID *types.KeyID `json:"key_id,omitempty"`
// Hash holds the value of the "hash" field.
Hash []byte `json:"hash,omitempty"`
// User holds the value of the "user" field.
User string `json:"user,omitempty"`
// Label holds the value of the "label" field.
Label string `json:"label,omitempty"`
// Path holds the value of the "path" field.
Path string `json:"path,omitempty"`
// Host holds the value of the "host" field.
Host string `json:"host,omitempty"`
// Headers holds the value of the "headers" field.
Headers types.Headers `json:"headers,omitempty"`
// Requests holds the value of the "requests" field.
Requests int64 `json:"requests,omitempty"`
// LastAccessAt holds the value of the "last_access_at" field.
LastAccessAt time.Time `json:"last_access_at,omitempty"`
// contains filtered or unexported fields
}
Token is the model entity for the Token schema.
func (*Token) Unwrap ¶
Unwrap unwraps the Token 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 (*Token) Update ¶
func (t *Token) Update() *TokenUpdateOne
Update returns a builder for updating this Token. Note that you need to call Token.Unwrap() before calling this method if this Token was returned from a transaction, and the transaction was committed or rolled back.
type TokenClient ¶
type TokenClient struct {
// contains filtered or unexported fields
}
TokenClient is a client for the Token schema.
func NewTokenClient ¶
func NewTokenClient(c config) *TokenClient
NewTokenClient returns a client for the Token from the given config.
func (*TokenClient) Create ¶
func (c *TokenClient) Create() *TokenCreate
Create returns a builder for creating a Token entity.
func (*TokenClient) CreateBulk ¶
func (c *TokenClient) CreateBulk(builders ...*TokenCreate) *TokenCreateBulk
CreateBulk returns a builder for creating a bulk of Token entities.
func (*TokenClient) Delete ¶
func (c *TokenClient) Delete() *TokenDelete
Delete returns a delete builder for Token.
func (*TokenClient) DeleteOne ¶
func (c *TokenClient) DeleteOne(t *Token) *TokenDeleteOne
DeleteOne returns a builder for deleting the given entity.
func (*TokenClient) DeleteOneID ¶
func (c *TokenClient) DeleteOneID(id int) *TokenDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
func (*TokenClient) GetX ¶
func (c *TokenClient) GetX(ctx context.Context, id int) *Token
GetX is like Get, but panics if an error occurs.
func (*TokenClient) Intercept ¶
func (c *TokenClient) Intercept(interceptors ...Interceptor)
Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `token.Intercept(f(g(h())))`.
func (*TokenClient) Interceptors ¶
func (c *TokenClient) Interceptors() []Interceptor
Interceptors returns the client interceptors.
func (*TokenClient) MapCreateBulk ¶
func (c *TokenClient) MapCreateBulk(slice any, setFunc func(*TokenCreate, int)) *TokenCreateBulk
MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.
func (*TokenClient) Query ¶
func (c *TokenClient) Query() *TokenQuery
Query returns a query builder for Token.
func (*TokenClient) Update ¶
func (c *TokenClient) Update() *TokenUpdate
Update returns an update builder for Token.
func (*TokenClient) UpdateOne ¶
func (c *TokenClient) UpdateOne(t *Token) *TokenUpdateOne
UpdateOne returns an update builder for the given entity.
func (*TokenClient) UpdateOneID ¶
func (c *TokenClient) UpdateOneID(id int) *TokenUpdateOne
UpdateOneID returns an update builder for the given id.
func (*TokenClient) Use ¶
func (c *TokenClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `token.Hooks(f(g(h())))`.
type TokenCreate ¶
type TokenCreate struct {
// contains filtered or unexported fields
}
TokenCreate is the builder for creating a Token entity.
func (*TokenCreate) Exec ¶
func (tc *TokenCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*TokenCreate) ExecX ¶
func (tc *TokenCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*TokenCreate) Mutation ¶
func (tc *TokenCreate) Mutation() *TokenMutation
Mutation returns the TokenMutation object of the builder.
func (*TokenCreate) Save ¶
func (tc *TokenCreate) Save(ctx context.Context) (*Token, error)
Save creates the Token in the database.
func (*TokenCreate) SaveX ¶
func (tc *TokenCreate) SaveX(ctx context.Context) *Token
SaveX calls Save and panics if Save returns an error.
func (*TokenCreate) SetCreatedAt ¶
func (tc *TokenCreate) SetCreatedAt(t time.Time) *TokenCreate
SetCreatedAt sets the "created_at" field.
func (*TokenCreate) SetHash ¶
func (tc *TokenCreate) SetHash(b []byte) *TokenCreate
SetHash sets the "hash" field.
func (*TokenCreate) SetHeaders ¶
func (tc *TokenCreate) SetHeaders(t types.Headers) *TokenCreate
SetHeaders sets the "headers" field.
func (*TokenCreate) SetHost ¶
func (tc *TokenCreate) SetHost(s string) *TokenCreate
SetHost sets the "host" field.
func (*TokenCreate) SetID ¶
func (tc *TokenCreate) SetID(i int) *TokenCreate
SetID sets the "id" field.
func (*TokenCreate) SetKeyID ¶
func (tc *TokenCreate) SetKeyID(ti *types.KeyID) *TokenCreate
SetKeyID sets the "key_id" field.
func (*TokenCreate) SetLabel ¶
func (tc *TokenCreate) SetLabel(s string) *TokenCreate
SetLabel sets the "label" field.
func (*TokenCreate) SetLastAccessAt ¶
func (tc *TokenCreate) SetLastAccessAt(t time.Time) *TokenCreate
SetLastAccessAt sets the "last_access_at" field.
func (*TokenCreate) SetNillableCreatedAt ¶
func (tc *TokenCreate) SetNillableCreatedAt(t *time.Time) *TokenCreate
SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (*TokenCreate) SetNillableHost ¶
func (tc *TokenCreate) SetNillableHost(s *string) *TokenCreate
SetNillableHost sets the "host" field if the given value is not nil.
func (*TokenCreate) SetNillableLabel ¶
func (tc *TokenCreate) SetNillableLabel(s *string) *TokenCreate
SetNillableLabel sets the "label" field if the given value is not nil.
func (*TokenCreate) SetNillableLastAccessAt ¶
func (tc *TokenCreate) SetNillableLastAccessAt(t *time.Time) *TokenCreate
SetNillableLastAccessAt sets the "last_access_at" field if the given value is not nil.
func (*TokenCreate) SetNillablePath ¶
func (tc *TokenCreate) SetNillablePath(s *string) *TokenCreate
SetNillablePath sets the "path" field if the given value is not nil.
func (*TokenCreate) SetNillableRequests ¶
func (tc *TokenCreate) SetNillableRequests(i *int64) *TokenCreate
SetNillableRequests sets the "requests" field if the given value is not nil.
func (*TokenCreate) SetNillableUpdatedAt ¶
func (tc *TokenCreate) SetNillableUpdatedAt(t *time.Time) *TokenCreate
SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (*TokenCreate) SetPath ¶
func (tc *TokenCreate) SetPath(s string) *TokenCreate
SetPath sets the "path" field.
func (*TokenCreate) SetRequests ¶
func (tc *TokenCreate) SetRequests(i int64) *TokenCreate
SetRequests sets the "requests" field.
func (*TokenCreate) SetUpdatedAt ¶
func (tc *TokenCreate) SetUpdatedAt(t time.Time) *TokenCreate
SetUpdatedAt sets the "updated_at" field.
func (*TokenCreate) SetUser ¶
func (tc *TokenCreate) SetUser(s string) *TokenCreate
SetUser sets the "user" field.
type TokenCreateBulk ¶
type TokenCreateBulk struct {
// contains filtered or unexported fields
}
TokenCreateBulk is the builder for creating many Token entities in bulk.
func (*TokenCreateBulk) Exec ¶
func (tcb *TokenCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*TokenCreateBulk) ExecX ¶
func (tcb *TokenCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type TokenDelete ¶
type TokenDelete struct {
// contains filtered or unexported fields
}
TokenDelete is the builder for deleting a Token entity.
func (*TokenDelete) Exec ¶
func (td *TokenDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*TokenDelete) ExecX ¶
func (td *TokenDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*TokenDelete) Where ¶
func (td *TokenDelete) Where(ps ...predicate.Token) *TokenDelete
Where appends a list predicates to the TokenDelete builder.
type TokenDeleteOne ¶
type TokenDeleteOne struct {
// contains filtered or unexported fields
}
TokenDeleteOne is the builder for deleting a single Token entity.
func (*TokenDeleteOne) Exec ¶
func (tdo *TokenDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*TokenDeleteOne) ExecX ¶
func (tdo *TokenDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*TokenDeleteOne) Where ¶
func (tdo *TokenDeleteOne) Where(ps ...predicate.Token) *TokenDeleteOne
Where appends a list predicates to the TokenDelete builder.
type TokenGroupBy ¶
type TokenGroupBy struct {
// contains filtered or unexported fields
}
TokenGroupBy is the group-by builder for Token entities.
func (*TokenGroupBy) Aggregate ¶
func (tgb *TokenGroupBy) Aggregate(fns ...AggregateFunc) *TokenGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*TokenGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*TokenGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*TokenGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*TokenGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*TokenGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*TokenGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*TokenGroupBy) Scan ¶
func (tgb *TokenGroupBy) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*TokenGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type TokenMutation ¶
type TokenMutation struct {
// contains filtered or unexported fields
}
TokenMutation represents an operation that mutates the Token nodes in the graph.
func (*TokenMutation) AddField ¶
func (m *TokenMutation) 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 (*TokenMutation) AddRequests ¶
func (m *TokenMutation) AddRequests(i int64)
AddRequests adds i to the "requests" field.
func (*TokenMutation) AddedEdges ¶
func (m *TokenMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*TokenMutation) AddedField ¶
func (m *TokenMutation) 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 (*TokenMutation) AddedFields ¶
func (m *TokenMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*TokenMutation) AddedIDs ¶
func (m *TokenMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*TokenMutation) AddedRequests ¶
func (m *TokenMutation) AddedRequests() (r int64, exists bool)
AddedRequests returns the value that was added to the "requests" field in this mutation.
func (*TokenMutation) AppendHeaders ¶
func (m *TokenMutation) AppendHeaders(t types.Headers)
AppendHeaders adds t to the "headers" field.
func (*TokenMutation) AppendedHeaders ¶
func (m *TokenMutation) AppendedHeaders() (types.Headers, bool)
AppendedHeaders returns the list of values that were appended to the "headers" field in this mutation.
func (*TokenMutation) ClearEdge ¶
func (m *TokenMutation) 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 (*TokenMutation) ClearField ¶
func (m *TokenMutation) 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 (*TokenMutation) ClearHeaders ¶
func (m *TokenMutation) ClearHeaders()
ClearHeaders clears the value of the "headers" field.
func (*TokenMutation) ClearedEdges ¶
func (m *TokenMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*TokenMutation) ClearedFields ¶
func (m *TokenMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (TokenMutation) Client ¶
func (m TokenMutation) 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 (*TokenMutation) CreatedAt ¶
func (m *TokenMutation) CreatedAt() (r time.Time, exists bool)
CreatedAt returns the value of the "created_at" field in the mutation.
func (*TokenMutation) EdgeCleared ¶
func (m *TokenMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*TokenMutation) Field ¶
func (m *TokenMutation) 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 (*TokenMutation) FieldCleared ¶
func (m *TokenMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*TokenMutation) Fields ¶
func (m *TokenMutation) 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 (*TokenMutation) Hash ¶
func (m *TokenMutation) Hash() (r []byte, exists bool)
Hash returns the value of the "hash" field in the mutation.
func (*TokenMutation) Headers ¶
func (m *TokenMutation) Headers() (r types.Headers, exists bool)
Headers returns the value of the "headers" field in the mutation.
func (*TokenMutation) HeadersCleared ¶
func (m *TokenMutation) HeadersCleared() bool
HeadersCleared returns if the "headers" field was cleared in this mutation.
func (*TokenMutation) Host ¶
func (m *TokenMutation) Host() (r string, exists bool)
Host returns the value of the "host" field in the mutation.
func (*TokenMutation) ID ¶
func (m *TokenMutation) ID() (id int, exists bool)
ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.
func (*TokenMutation) IDs ¶
func (m *TokenMutation) IDs(ctx context.Context) ([]int, error)
IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.
func (*TokenMutation) KeyID ¶
func (m *TokenMutation) KeyID() (r *types.KeyID, exists bool)
KeyID returns the value of the "key_id" field in the mutation.
func (*TokenMutation) Label ¶
func (m *TokenMutation) Label() (r string, exists bool)
Label returns the value of the "label" field in the mutation.
func (*TokenMutation) LastAccessAt ¶
func (m *TokenMutation) LastAccessAt() (r time.Time, exists bool)
LastAccessAt returns the value of the "last_access_at" field in the mutation.
func (*TokenMutation) OldCreatedAt ¶
OldCreatedAt returns the old "created_at" field's value of the Token entity. If the Token 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 (*TokenMutation) 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 (*TokenMutation) OldHash ¶
func (m *TokenMutation) OldHash(ctx context.Context) (v []byte, err error)
OldHash returns the old "hash" field's value of the Token entity. If the Token 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 (*TokenMutation) OldHeaders ¶
OldHeaders returns the old "headers" field's value of the Token entity. If the Token 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 (*TokenMutation) OldHost ¶
func (m *TokenMutation) OldHost(ctx context.Context) (v string, err error)
OldHost returns the old "host" field's value of the Token entity. If the Token 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 (*TokenMutation) OldKeyID ¶
OldKeyID returns the old "key_id" field's value of the Token entity. If the Token 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 (*TokenMutation) OldLabel ¶
func (m *TokenMutation) OldLabel(ctx context.Context) (v string, err error)
OldLabel returns the old "label" field's value of the Token entity. If the Token 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 (*TokenMutation) OldLastAccessAt ¶
OldLastAccessAt returns the old "last_access_at" field's value of the Token entity. If the Token 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 (*TokenMutation) OldPath ¶
func (m *TokenMutation) OldPath(ctx context.Context) (v string, err error)
OldPath returns the old "path" field's value of the Token entity. If the Token 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 (*TokenMutation) OldRequests ¶
func (m *TokenMutation) OldRequests(ctx context.Context) (v int64, err error)
OldRequests returns the old "requests" field's value of the Token entity. If the Token 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 (*TokenMutation) OldUpdatedAt ¶
OldUpdatedAt returns the old "updated_at" field's value of the Token entity. If the Token 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 (*TokenMutation) OldUser ¶
func (m *TokenMutation) OldUser(ctx context.Context) (v string, err error)
OldUser returns the old "user" field's value of the Token entity. If the Token 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 (*TokenMutation) Path ¶
func (m *TokenMutation) Path() (r string, exists bool)
Path returns the value of the "path" field in the mutation.
func (*TokenMutation) RemovedEdges ¶
func (m *TokenMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*TokenMutation) RemovedIDs ¶
func (m *TokenMutation) 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 (*TokenMutation) Requests ¶
func (m *TokenMutation) Requests() (r int64, exists bool)
Requests returns the value of the "requests" field in the mutation.
func (*TokenMutation) ResetCreatedAt ¶
func (m *TokenMutation) ResetCreatedAt()
ResetCreatedAt resets all changes to the "created_at" field.
func (*TokenMutation) ResetEdge ¶
func (m *TokenMutation) 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 (*TokenMutation) ResetField ¶
func (m *TokenMutation) 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 (*TokenMutation) ResetHash ¶
func (m *TokenMutation) ResetHash()
ResetHash resets all changes to the "hash" field.
func (*TokenMutation) ResetHeaders ¶
func (m *TokenMutation) ResetHeaders()
ResetHeaders resets all changes to the "headers" field.
func (*TokenMutation) ResetHost ¶
func (m *TokenMutation) ResetHost()
ResetHost resets all changes to the "host" field.
func (*TokenMutation) ResetKeyID ¶
func (m *TokenMutation) ResetKeyID()
ResetKeyID resets all changes to the "key_id" field.
func (*TokenMutation) ResetLabel ¶
func (m *TokenMutation) ResetLabel()
ResetLabel resets all changes to the "label" field.
func (*TokenMutation) ResetLastAccessAt ¶
func (m *TokenMutation) ResetLastAccessAt()
ResetLastAccessAt resets all changes to the "last_access_at" field.
func (*TokenMutation) ResetPath ¶
func (m *TokenMutation) ResetPath()
ResetPath resets all changes to the "path" field.
func (*TokenMutation) ResetRequests ¶
func (m *TokenMutation) ResetRequests()
ResetRequests resets all changes to the "requests" field.
func (*TokenMutation) ResetUpdatedAt ¶
func (m *TokenMutation) ResetUpdatedAt()
ResetUpdatedAt resets all changes to the "updated_at" field.
func (*TokenMutation) ResetUser ¶
func (m *TokenMutation) ResetUser()
ResetUser resets all changes to the "user" field.
func (*TokenMutation) SetCreatedAt ¶
func (m *TokenMutation) SetCreatedAt(t time.Time)
SetCreatedAt sets the "created_at" field.
func (*TokenMutation) SetField ¶
func (m *TokenMutation) 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 (*TokenMutation) SetHash ¶
func (m *TokenMutation) SetHash(b []byte)
SetHash sets the "hash" field.
func (*TokenMutation) SetHeaders ¶
func (m *TokenMutation) SetHeaders(t types.Headers)
SetHeaders sets the "headers" field.
func (*TokenMutation) SetHost ¶
func (m *TokenMutation) SetHost(s string)
SetHost sets the "host" field.
func (*TokenMutation) SetID ¶
func (m *TokenMutation) SetID(id int)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Token entities.
func (*TokenMutation) SetKeyID ¶
func (m *TokenMutation) SetKeyID(ti *types.KeyID)
SetKeyID sets the "key_id" field.
func (*TokenMutation) SetLabel ¶
func (m *TokenMutation) SetLabel(s string)
SetLabel sets the "label" field.
func (*TokenMutation) SetLastAccessAt ¶
func (m *TokenMutation) SetLastAccessAt(t time.Time)
SetLastAccessAt sets the "last_access_at" field.
func (*TokenMutation) SetOp ¶
func (m *TokenMutation) SetOp(op Op)
SetOp allows setting the mutation operation.
func (*TokenMutation) SetPath ¶
func (m *TokenMutation) SetPath(s string)
SetPath sets the "path" field.
func (*TokenMutation) SetRequests ¶
func (m *TokenMutation) SetRequests(i int64)
SetRequests sets the "requests" field.
func (*TokenMutation) SetUpdatedAt ¶
func (m *TokenMutation) SetUpdatedAt(t time.Time)
SetUpdatedAt sets the "updated_at" field.
func (*TokenMutation) SetUser ¶
func (m *TokenMutation) SetUser(s string)
SetUser sets the "user" field.
func (TokenMutation) Tx ¶
func (m TokenMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*TokenMutation) Type ¶
func (m *TokenMutation) Type() string
Type returns the node type of this mutation (Token).
func (*TokenMutation) UpdatedAt ¶
func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool)
UpdatedAt returns the value of the "updated_at" field in the mutation.
func (*TokenMutation) User ¶
func (m *TokenMutation) User() (r string, exists bool)
User returns the value of the "user" field in the mutation.
func (*TokenMutation) Where ¶
func (m *TokenMutation) Where(ps ...predicate.Token)
Where appends a list predicates to the TokenMutation builder.
func (*TokenMutation) WhereP ¶
func (m *TokenMutation) WhereP(ps ...func(*sql.Selector))
WhereP appends storage-level predicates to the TokenMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.
type TokenQuery ¶
type TokenQuery struct {
// contains filtered or unexported fields
}
TokenQuery is the builder for querying Token entities.
func (*TokenQuery) Aggregate ¶
func (tq *TokenQuery) Aggregate(fns ...AggregateFunc) *TokenSelect
Aggregate returns a TokenSelect configured with the given aggregations.
func (*TokenQuery) All ¶
func (tq *TokenQuery) All(ctx context.Context) ([]*Token, error)
All executes the query and returns a list of Tokens.
func (*TokenQuery) AllX ¶
func (tq *TokenQuery) AllX(ctx context.Context) []*Token
AllX is like All, but panics if an error occurs.
func (*TokenQuery) Clone ¶
func (tq *TokenQuery) Clone() *TokenQuery
Clone returns a duplicate of the TokenQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*TokenQuery) Count ¶
func (tq *TokenQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*TokenQuery) CountX ¶
func (tq *TokenQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*TokenQuery) Exist ¶
func (tq *TokenQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*TokenQuery) ExistX ¶
func (tq *TokenQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*TokenQuery) First ¶
func (tq *TokenQuery) First(ctx context.Context) (*Token, error)
First returns the first Token entity from the query. Returns a *NotFoundError when no Token was found.
func (*TokenQuery) FirstID ¶
func (tq *TokenQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Token ID from the query. Returns a *NotFoundError when no Token ID was found.
func (*TokenQuery) FirstIDX ¶
func (tq *TokenQuery) FirstIDX(ctx context.Context) int
FirstIDX is like FirstID, but panics if an error occurs.
func (*TokenQuery) FirstX ¶
func (tq *TokenQuery) FirstX(ctx context.Context) *Token
FirstX is like First, but panics if an error occurs.
func (*TokenQuery) GroupBy ¶
func (tq *TokenQuery) GroupBy(field string, fields ...string) *TokenGroupBy
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 {
CreatedAt time.Time `json:"created_at,omitempty"`
Count int `json:"count,omitempty"`
}
client.Token.Query().
GroupBy(token.FieldCreatedAt).
Aggregate(ent.Count()).
Scan(ctx, &v)
func (*TokenQuery) IDs ¶
func (tq *TokenQuery) IDs(ctx context.Context) (ids []int, err error)
IDs executes the query and returns a list of Token IDs.
func (*TokenQuery) IDsX ¶
func (tq *TokenQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*TokenQuery) Limit ¶
func (tq *TokenQuery) Limit(limit int) *TokenQuery
Limit the number of records to be returned by this query.
func (*TokenQuery) Offset ¶
func (tq *TokenQuery) Offset(offset int) *TokenQuery
Offset to start from.
func (*TokenQuery) Only ¶
func (tq *TokenQuery) Only(ctx context.Context) (*Token, error)
Only returns a single Token entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Token entity is found. Returns a *NotFoundError when no Token entities are found.
func (*TokenQuery) OnlyID ¶
func (tq *TokenQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID is like Only, but returns the only Token ID in the query. Returns a *NotSingularError when more than one Token ID is found. Returns a *NotFoundError when no entities are found.
func (*TokenQuery) OnlyIDX ¶
func (tq *TokenQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*TokenQuery) OnlyX ¶
func (tq *TokenQuery) OnlyX(ctx context.Context) *Token
OnlyX is like Only, but panics if an error occurs.
func (*TokenQuery) Order ¶
func (tq *TokenQuery) Order(o ...token.OrderOption) *TokenQuery
Order specifies how the records should be ordered.
func (*TokenQuery) Select ¶
func (tq *TokenQuery) Select(fields ...string) *TokenSelect
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 {
CreatedAt time.Time `json:"created_at,omitempty"`
}
client.Token.Query().
Select(token.FieldCreatedAt).
Scan(ctx, &v)
func (*TokenQuery) Unique ¶
func (tq *TokenQuery) Unique(unique bool) *TokenQuery
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 (*TokenQuery) Where ¶
func (tq *TokenQuery) Where(ps ...predicate.Token) *TokenQuery
Where adds a new predicate for the TokenQuery builder.
type TokenSelect ¶
type TokenSelect struct {
*TokenQuery
// contains filtered or unexported fields
}
TokenSelect is the builder for selecting fields of Token entities.
func (*TokenSelect) Aggregate ¶
func (ts *TokenSelect) Aggregate(fns ...AggregateFunc) *TokenSelect
Aggregate adds the given aggregation functions to the selector query.
func (*TokenSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*TokenSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*TokenSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*TokenSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*TokenSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*TokenSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*TokenSelect) Scan ¶
func (ts *TokenSelect) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*TokenSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type TokenUpdate ¶
type TokenUpdate struct {
// contains filtered or unexported fields
}
TokenUpdate is the builder for updating Token entities.
func (*TokenUpdate) AddRequests ¶
func (tu *TokenUpdate) AddRequests(i int64) *TokenUpdate
AddRequests adds i to the "requests" field.
func (*TokenUpdate) AppendHeaders ¶
func (tu *TokenUpdate) AppendHeaders(t types.Headers) *TokenUpdate
AppendHeaders appends t to the "headers" field.
func (*TokenUpdate) ClearHeaders ¶
func (tu *TokenUpdate) ClearHeaders() *TokenUpdate
ClearHeaders clears the value of the "headers" field.
func (*TokenUpdate) Exec ¶
func (tu *TokenUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*TokenUpdate) ExecX ¶
func (tu *TokenUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*TokenUpdate) Mutation ¶
func (tu *TokenUpdate) Mutation() *TokenMutation
Mutation returns the TokenMutation object of the builder.
func (*TokenUpdate) Save ¶
func (tu *TokenUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*TokenUpdate) SaveX ¶
func (tu *TokenUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*TokenUpdate) SetCreatedAt ¶
func (tu *TokenUpdate) SetCreatedAt(t time.Time) *TokenUpdate
SetCreatedAt sets the "created_at" field.
func (*TokenUpdate) SetHash ¶
func (tu *TokenUpdate) SetHash(b []byte) *TokenUpdate
SetHash sets the "hash" field.
func (*TokenUpdate) SetHeaders ¶
func (tu *TokenUpdate) SetHeaders(t types.Headers) *TokenUpdate
SetHeaders sets the "headers" field.
func (*TokenUpdate) SetHost ¶
func (tu *TokenUpdate) SetHost(s string) *TokenUpdate
SetHost sets the "host" field.
func (*TokenUpdate) SetKeyID ¶
func (tu *TokenUpdate) SetKeyID(ti *types.KeyID) *TokenUpdate
SetKeyID sets the "key_id" field.
func (*TokenUpdate) SetLabel ¶
func (tu *TokenUpdate) SetLabel(s string) *TokenUpdate
SetLabel sets the "label" field.
func (*TokenUpdate) SetLastAccessAt ¶
func (tu *TokenUpdate) SetLastAccessAt(t time.Time) *TokenUpdate
SetLastAccessAt sets the "last_access_at" field.
func (*TokenUpdate) SetNillableCreatedAt ¶
func (tu *TokenUpdate) SetNillableCreatedAt(t *time.Time) *TokenUpdate
SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (*TokenUpdate) SetNillableHost ¶
func (tu *TokenUpdate) SetNillableHost(s *string) *TokenUpdate
SetNillableHost sets the "host" field if the given value is not nil.
func (*TokenUpdate) SetNillableLabel ¶
func (tu *TokenUpdate) SetNillableLabel(s *string) *TokenUpdate
SetNillableLabel sets the "label" field if the given value is not nil.
func (*TokenUpdate) SetNillableLastAccessAt ¶
func (tu *TokenUpdate) SetNillableLastAccessAt(t *time.Time) *TokenUpdate
SetNillableLastAccessAt sets the "last_access_at" field if the given value is not nil.
func (*TokenUpdate) SetNillablePath ¶
func (tu *TokenUpdate) SetNillablePath(s *string) *TokenUpdate
SetNillablePath sets the "path" field if the given value is not nil.
func (*TokenUpdate) SetNillableRequests ¶
func (tu *TokenUpdate) SetNillableRequests(i *int64) *TokenUpdate
SetNillableRequests sets the "requests" field if the given value is not nil.
func (*TokenUpdate) SetNillableUser ¶
func (tu *TokenUpdate) SetNillableUser(s *string) *TokenUpdate
SetNillableUser sets the "user" field if the given value is not nil.
func (*TokenUpdate) SetPath ¶
func (tu *TokenUpdate) SetPath(s string) *TokenUpdate
SetPath sets the "path" field.
func (*TokenUpdate) SetRequests ¶
func (tu *TokenUpdate) SetRequests(i int64) *TokenUpdate
SetRequests sets the "requests" field.
func (*TokenUpdate) SetUpdatedAt ¶
func (tu *TokenUpdate) SetUpdatedAt(t time.Time) *TokenUpdate
SetUpdatedAt sets the "updated_at" field.
func (*TokenUpdate) SetUser ¶
func (tu *TokenUpdate) SetUser(s string) *TokenUpdate
SetUser sets the "user" field.
func (*TokenUpdate) Where ¶
func (tu *TokenUpdate) Where(ps ...predicate.Token) *TokenUpdate
Where appends a list predicates to the TokenUpdate builder.
type TokenUpdateOne ¶
type TokenUpdateOne struct {
// contains filtered or unexported fields
}
TokenUpdateOne is the builder for updating a single Token entity.
func (*TokenUpdateOne) AddRequests ¶
func (tuo *TokenUpdateOne) AddRequests(i int64) *TokenUpdateOne
AddRequests adds i to the "requests" field.
func (*TokenUpdateOne) AppendHeaders ¶
func (tuo *TokenUpdateOne) AppendHeaders(t types.Headers) *TokenUpdateOne
AppendHeaders appends t to the "headers" field.
func (*TokenUpdateOne) ClearHeaders ¶
func (tuo *TokenUpdateOne) ClearHeaders() *TokenUpdateOne
ClearHeaders clears the value of the "headers" field.
func (*TokenUpdateOne) Exec ¶
func (tuo *TokenUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*TokenUpdateOne) ExecX ¶
func (tuo *TokenUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*TokenUpdateOne) Mutation ¶
func (tuo *TokenUpdateOne) Mutation() *TokenMutation
Mutation returns the TokenMutation object of the builder.
func (*TokenUpdateOne) Save ¶
func (tuo *TokenUpdateOne) Save(ctx context.Context) (*Token, error)
Save executes the query and returns the updated Token entity.
func (*TokenUpdateOne) SaveX ¶
func (tuo *TokenUpdateOne) SaveX(ctx context.Context) *Token
SaveX is like Save, but panics if an error occurs.
func (*TokenUpdateOne) Select ¶
func (tuo *TokenUpdateOne) Select(field string, fields ...string) *TokenUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*TokenUpdateOne) SetCreatedAt ¶
func (tuo *TokenUpdateOne) SetCreatedAt(t time.Time) *TokenUpdateOne
SetCreatedAt sets the "created_at" field.
func (*TokenUpdateOne) SetHash ¶
func (tuo *TokenUpdateOne) SetHash(b []byte) *TokenUpdateOne
SetHash sets the "hash" field.
func (*TokenUpdateOne) SetHeaders ¶
func (tuo *TokenUpdateOne) SetHeaders(t types.Headers) *TokenUpdateOne
SetHeaders sets the "headers" field.
func (*TokenUpdateOne) SetHost ¶
func (tuo *TokenUpdateOne) SetHost(s string) *TokenUpdateOne
SetHost sets the "host" field.
func (*TokenUpdateOne) SetKeyID ¶
func (tuo *TokenUpdateOne) SetKeyID(ti *types.KeyID) *TokenUpdateOne
SetKeyID sets the "key_id" field.
func (*TokenUpdateOne) SetLabel ¶
func (tuo *TokenUpdateOne) SetLabel(s string) *TokenUpdateOne
SetLabel sets the "label" field.
func (*TokenUpdateOne) SetLastAccessAt ¶
func (tuo *TokenUpdateOne) SetLastAccessAt(t time.Time) *TokenUpdateOne
SetLastAccessAt sets the "last_access_at" field.
func (*TokenUpdateOne) SetNillableCreatedAt ¶
func (tuo *TokenUpdateOne) SetNillableCreatedAt(t *time.Time) *TokenUpdateOne
SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (*TokenUpdateOne) SetNillableHost ¶
func (tuo *TokenUpdateOne) SetNillableHost(s *string) *TokenUpdateOne
SetNillableHost sets the "host" field if the given value is not nil.
func (*TokenUpdateOne) SetNillableLabel ¶
func (tuo *TokenUpdateOne) SetNillableLabel(s *string) *TokenUpdateOne
SetNillableLabel sets the "label" field if the given value is not nil.
func (*TokenUpdateOne) SetNillableLastAccessAt ¶
func (tuo *TokenUpdateOne) SetNillableLastAccessAt(t *time.Time) *TokenUpdateOne
SetNillableLastAccessAt sets the "last_access_at" field if the given value is not nil.
func (*TokenUpdateOne) SetNillablePath ¶
func (tuo *TokenUpdateOne) SetNillablePath(s *string) *TokenUpdateOne
SetNillablePath sets the "path" field if the given value is not nil.
func (*TokenUpdateOne) SetNillableRequests ¶
func (tuo *TokenUpdateOne) SetNillableRequests(i *int64) *TokenUpdateOne
SetNillableRequests sets the "requests" field if the given value is not nil.
func (*TokenUpdateOne) SetNillableUser ¶
func (tuo *TokenUpdateOne) SetNillableUser(s *string) *TokenUpdateOne
SetNillableUser sets the "user" field if the given value is not nil.
func (*TokenUpdateOne) SetPath ¶
func (tuo *TokenUpdateOne) SetPath(s string) *TokenUpdateOne
SetPath sets the "path" field.
func (*TokenUpdateOne) SetRequests ¶
func (tuo *TokenUpdateOne) SetRequests(i int64) *TokenUpdateOne
SetRequests sets the "requests" field.
func (*TokenUpdateOne) SetUpdatedAt ¶
func (tuo *TokenUpdateOne) SetUpdatedAt(t time.Time) *TokenUpdateOne
SetUpdatedAt sets the "updated_at" field.
func (*TokenUpdateOne) SetUser ¶
func (tuo *TokenUpdateOne) SetUser(s string) *TokenUpdateOne
SetUser sets the "user" field.
func (*TokenUpdateOne) Where ¶
func (tuo *TokenUpdateOne) Where(ps ...predicate.Token) *TokenUpdateOne
Where appends a list predicates to the TokenUpdate builder.
type TraverseFunc ¶
type TraverseFunc = ent.TraverseFunc
ent aliases to avoid import conflicts in user's code.
type Tx ¶
type Tx struct {
// Token is the client for interacting with the Token builders.
Token *TokenClient
// 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.