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
- func OpenTxFromContext(ctx context.Context) (context.Context, driver.Tx, error)
- 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) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error)
- func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]Noder, error)
- func (c *Client) OpenTx(ctx context.Context) (context.Context, driver.Tx, 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 Cursor
- type Hook
- type InterceptFunc
- type Interceptor
- type MutateFunc
- type Mutation
- type Mutator
- type NodeOption
- type Noder
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderDirection
- type OrderFunc
- type PageInfo
- type Policy
- type Querier
- type QuerierFunc
- type Query
- type QueryContext
- type Resource
- type ResourceClient
- func (c *ResourceClient) Create() *ResourceCreate
- func (c *ResourceClient) CreateBulk(builders ...*ResourceCreate) *ResourceCreateBulk
- func (c *ResourceClient) Delete() *ResourceDelete
- func (c *ResourceClient) DeleteOne(r *Resource) *ResourceDeleteOne
- func (c *ResourceClient) DeleteOneID(id int) *ResourceDeleteOne
- func (c *ResourceClient) Get(ctx context.Context, id int) (*Resource, error)
- func (c *ResourceClient) GetX(ctx context.Context, id int) *Resource
- func (c *ResourceClient) Hooks() []Hook
- func (c *ResourceClient) Intercept(interceptors ...Interceptor)
- func (c *ResourceClient) Interceptors() []Interceptor
- func (c *ResourceClient) Query() *ResourceQuery
- func (c *ResourceClient) Update() *ResourceUpdate
- func (c *ResourceClient) UpdateOne(r *Resource) *ResourceUpdateOne
- func (c *ResourceClient) UpdateOneID(id int) *ResourceUpdateOne
- func (c *ResourceClient) Use(hooks ...Hook)
- type ResourceConnection
- type ResourceCreate
- func (rc *ResourceCreate) Exec(ctx context.Context) error
- func (rc *ResourceCreate) ExecX(ctx context.Context)
- func (rc *ResourceCreate) Mutation() *ResourceMutation
- func (rc *ResourceCreate) Save(ctx context.Context) (*Resource, error)
- func (rc *ResourceCreate) SaveX(ctx context.Context) *Resource
- func (rc *ResourceCreate) SetDescription(s string) *ResourceCreate
- func (rc *ResourceCreate) SetName(s string) *ResourceCreate
- func (rc *ResourceCreate) SetNillableDescription(s *string) *ResourceCreate
- func (rc *ResourceCreate) SetNillableTenantID(s *string) *ResourceCreate
- func (rc *ResourceCreate) SetTenantID(s string) *ResourceCreate
- type ResourceCreateBulk
- type ResourceDelete
- type ResourceDeleteOne
- type ResourceEdge
- type ResourceGroupBy
- func (rgb *ResourceGroupBy) Aggregate(fns ...AggregateFunc) *ResourceGroupBy
- func (s *ResourceGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *ResourceGroupBy) BoolX(ctx context.Context) bool
- func (s *ResourceGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *ResourceGroupBy) BoolsX(ctx context.Context) []bool
- func (s *ResourceGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *ResourceGroupBy) Float64X(ctx context.Context) float64
- func (s *ResourceGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *ResourceGroupBy) Float64sX(ctx context.Context) []float64
- func (s *ResourceGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *ResourceGroupBy) IntX(ctx context.Context) int
- func (s *ResourceGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *ResourceGroupBy) IntsX(ctx context.Context) []int
- func (rgb *ResourceGroupBy) Scan(ctx context.Context, v any) error
- func (s *ResourceGroupBy) ScanX(ctx context.Context, v any)
- func (s *ResourceGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *ResourceGroupBy) StringX(ctx context.Context) string
- func (s *ResourceGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *ResourceGroupBy) StringsX(ctx context.Context) []string
- type ResourceMutation
- func (m *ResourceMutation) AddField(name string, value ent.Value) error
- func (m *ResourceMutation) AddedEdges() []string
- func (m *ResourceMutation) AddedField(name string) (ent.Value, bool)
- func (m *ResourceMutation) AddedFields() []string
- func (m *ResourceMutation) AddedIDs(name string) []ent.Value
- func (m *ResourceMutation) ClearDescription()
- func (m *ResourceMutation) ClearEdge(name string) error
- func (m *ResourceMutation) ClearField(name string) error
- func (m *ResourceMutation) ClearTenantID()
- func (m *ResourceMutation) ClearedEdges() []string
- func (m *ResourceMutation) ClearedFields() []string
- func (m ResourceMutation) Client() *Client
- func (m *ResourceMutation) Description() (r string, exists bool)
- func (m *ResourceMutation) DescriptionCleared() bool
- func (m *ResourceMutation) EdgeCleared(name string) bool
- func (m *ResourceMutation) Field(name string) (ent.Value, bool)
- func (m *ResourceMutation) FieldCleared(name string) bool
- func (m *ResourceMutation) Fields() []string
- func (m *ResourceMutation) ID() (id int, exists bool)
- func (m *ResourceMutation) IDs(ctx context.Context) ([]int, error)
- func (m *ResourceMutation) Name() (r string, exists bool)
- func (m *ResourceMutation) OldDescription(ctx context.Context) (v string, err error)
- func (m *ResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *ResourceMutation) OldName(ctx context.Context) (v string, err error)
- func (m *ResourceMutation) OldTenantID(ctx context.Context) (v string, err error)
- func (m *ResourceMutation) Op() Op
- func (m *ResourceMutation) RemovedEdges() []string
- func (m *ResourceMutation) RemovedIDs(name string) []ent.Value
- func (m *ResourceMutation) ResetDescription()
- func (m *ResourceMutation) ResetEdge(name string) error
- func (m *ResourceMutation) ResetField(name string) error
- func (m *ResourceMutation) ResetName()
- func (m *ResourceMutation) ResetTenantID()
- func (m *ResourceMutation) SetDescription(s string)
- func (m *ResourceMutation) SetField(name string, value ent.Value) error
- func (m *ResourceMutation) SetName(s string)
- func (m *ResourceMutation) SetOp(op Op)
- func (m *ResourceMutation) SetTenantID(s string)
- func (m *ResourceMutation) TenantID() (r string, exists bool)
- func (m *ResourceMutation) TenantIDCleared() bool
- func (m ResourceMutation) Tx() (*Tx, error)
- func (m *ResourceMutation) Type() string
- func (m *ResourceMutation) Where(ps ...predicate.Resource)
- func (m *ResourceMutation) WhereP(ps ...func(*sql.Selector))
- type ResourceOrder
- type ResourceOrderField
- type ResourcePaginateOption
- type ResourceQuery
- func (rq *ResourceQuery) Aggregate(fns ...AggregateFunc) *ResourceSelect
- func (rq *ResourceQuery) All(ctx context.Context) ([]*Resource, error)
- func (rq *ResourceQuery) AllX(ctx context.Context) []*Resource
- func (rq *ResourceQuery) Clone() *ResourceQuery
- func (r *ResourceQuery) CollectFields(ctx context.Context, satisfies ...string) (*ResourceQuery, error)
- func (rq *ResourceQuery) Count(ctx context.Context) (int, error)
- func (rq *ResourceQuery) CountX(ctx context.Context) int
- func (rq *ResourceQuery) Exist(ctx context.Context) (bool, error)
- func (rq *ResourceQuery) ExistX(ctx context.Context) bool
- func (rq *ResourceQuery) First(ctx context.Context) (*Resource, error)
- func (rq *ResourceQuery) FirstID(ctx context.Context) (id int, err error)
- func (rq *ResourceQuery) FirstIDX(ctx context.Context) int
- func (rq *ResourceQuery) FirstX(ctx context.Context) *Resource
- func (rq *ResourceQuery) GroupBy(field string, fields ...string) *ResourceGroupBy
- func (rq *ResourceQuery) IDs(ctx context.Context) (ids []int, err error)
- func (rq *ResourceQuery) IDsX(ctx context.Context) []int
- func (rq *ResourceQuery) Limit(limit int) *ResourceQuery
- func (rq *ResourceQuery) Offset(offset int) *ResourceQuery
- func (rq *ResourceQuery) Only(ctx context.Context) (*Resource, error)
- func (rq *ResourceQuery) OnlyID(ctx context.Context) (id int, err error)
- func (rq *ResourceQuery) OnlyIDX(ctx context.Context) int
- func (rq *ResourceQuery) OnlyX(ctx context.Context) *Resource
- func (rq *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery
- func (r *ResourceQuery) Paginate(ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, ...) (*ResourceConnection, error)
- func (rq *ResourceQuery) Select(fields ...string) *ResourceSelect
- func (rq *ResourceQuery) Unique(unique bool) *ResourceQuery
- func (rq *ResourceQuery) Where(ps ...predicate.Resource) *ResourceQuery
- type ResourceSelect
- func (rs *ResourceSelect) Aggregate(fns ...AggregateFunc) *ResourceSelect
- func (s *ResourceSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *ResourceSelect) BoolX(ctx context.Context) bool
- func (s *ResourceSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *ResourceSelect) BoolsX(ctx context.Context) []bool
- func (s *ResourceSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *ResourceSelect) Float64X(ctx context.Context) float64
- func (s *ResourceSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *ResourceSelect) Float64sX(ctx context.Context) []float64
- func (s *ResourceSelect) Int(ctx context.Context) (_ int, err error)
- func (s *ResourceSelect) IntX(ctx context.Context) int
- func (s *ResourceSelect) Ints(ctx context.Context) ([]int, error)
- func (s *ResourceSelect) IntsX(ctx context.Context) []int
- func (rs *ResourceSelect) Scan(ctx context.Context, v any) error
- func (s *ResourceSelect) ScanX(ctx context.Context, v any)
- func (s *ResourceSelect) String(ctx context.Context) (_ string, err error)
- func (s *ResourceSelect) StringX(ctx context.Context) string
- func (s *ResourceSelect) Strings(ctx context.Context) ([]string, error)
- func (s *ResourceSelect) StringsX(ctx context.Context) []string
- type ResourceUpdate
- func (ru *ResourceUpdate) ClearDescription() *ResourceUpdate
- func (ru *ResourceUpdate) ClearTenantID() *ResourceUpdate
- func (ru *ResourceUpdate) Exec(ctx context.Context) error
- func (ru *ResourceUpdate) ExecX(ctx context.Context)
- func (ru *ResourceUpdate) Mutation() *ResourceMutation
- func (ru *ResourceUpdate) Save(ctx context.Context) (int, error)
- func (ru *ResourceUpdate) SaveX(ctx context.Context) int
- func (ru *ResourceUpdate) SetDescription(s string) *ResourceUpdate
- func (ru *ResourceUpdate) SetName(s string) *ResourceUpdate
- func (ru *ResourceUpdate) SetNillableDescription(s *string) *ResourceUpdate
- func (ru *ResourceUpdate) SetNillableTenantID(s *string) *ResourceUpdate
- func (ru *ResourceUpdate) SetTenantID(s string) *ResourceUpdate
- func (ru *ResourceUpdate) Where(ps ...predicate.Resource) *ResourceUpdate
- type ResourceUpdateOne
- func (ruo *ResourceUpdateOne) ClearDescription() *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) ClearTenantID() *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) Exec(ctx context.Context) error
- func (ruo *ResourceUpdateOne) ExecX(ctx context.Context)
- func (ruo *ResourceUpdateOne) Mutation() *ResourceMutation
- func (ruo *ResourceUpdateOne) Save(ctx context.Context) (*Resource, error)
- func (ruo *ResourceUpdateOne) SaveX(ctx context.Context) *Resource
- func (ruo *ResourceUpdateOne) Select(field string, fields ...string) *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) SetDescription(s string) *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) SetName(s string) *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) SetNillableDescription(s *string) *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) SetNillableTenantID(s *string) *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) SetTenantID(s string) *ResourceUpdateOne
- func (ruo *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne
- type ResourceWhereInput
- type Resources
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- 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. TypeResource = "Resource" )
Variables ¶
var DefaultResourceOrder = &ResourceOrder{ Direction: entgql.OrderDirectionAsc, Field: &ResourceOrderField{ Value: func(r *Resource) (ent.Value, error) { return r.ID, nil }, column: resource.FieldID, toTerm: resource.ByID, toCursor: func(r *Resource) Cursor { return Cursor{ID: r.ID} }, }, }
DefaultResourceOrder is the default ordering of Resource.
var ErrEmptyResourceWhereInput = errors.New("ent: empty predicate ResourceWhereInput")
ErrEmptyResourceWhereInput is returned in case the ResourceWhereInput is empty.
Functions ¶
func IsConstraintError ¶
IsConstraintError returns a boolean indicating whether the error is a constraint failure.
func IsNotFound ¶
IsNotFound returns a boolean indicating whether the error is a not found error.
func IsNotLoaded ¶
IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
func IsNotSingular ¶
IsNotSingular returns a boolean indicating whether the error is a not singular error.
func IsValidationError ¶
IsValidationError returns a boolean indicating whether the error is a validation error.
func NewContext ¶
NewContext returns a new context with the given Client attached.
func NewTxContext ¶
NewTxContext returns a new context with the given Tx 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 // Resource is the client for interacting with the Resource builders. Resource *ResourceClient // 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(). Resource. 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(...)`.
func (*Client) Noder ¶
Noder returns a Node by its id. If the NodeType was not provided, it will be derived from the id value according to the universal-id configuration.
c.Noder(ctx, id) c.Noder(ctx, id, ent.WithNodeType(typeResolver))
func (*Client) OpenTx ¶
OpenTx opens a transaction and returns a transactional context along with the created transaction.
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 NodeOption ¶
type NodeOption func(*nodeOptions)
NodeOption allows configuring the Noder execution using functional options.
func WithFixedNodeType ¶
func WithFixedNodeType(t string) NodeOption
WithFixedNodeType sets the Type of the node to a fixed value.
func WithNodeType ¶
WithNodeType sets the node Type resolver function (i.e. the table to query). If was not provided, the table will be derived from the universal-id configuration as described in: https://entgo.io/docs/migrate/#universal-ids.
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 Resource ¶
type Resource struct { // ID of the ent. ID int `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // TenantID holds the value of the "tenant_id" field. TenantID string `json:"tenant_id,omitempty"` // contains filtered or unexported fields }
Resource is the model entity for the Resource schema.
func (*Resource) IsNode ¶
func (n *Resource) IsNode()
IsNode implements the Node interface check for GQLGen.
func (*Resource) ToEdge ¶
func (r *Resource) ToEdge(order *ResourceOrder) *ResourceEdge
ToEdge converts Resource into ResourceEdge.
func (*Resource) Unwrap ¶
Unwrap unwraps the Resource 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 (*Resource) Update ¶
func (r *Resource) Update() *ResourceUpdateOne
Update returns a builder for updating this Resource. Note that you need to call Resource.Unwrap() before calling this method if this Resource was returned from a transaction, and the transaction was committed or rolled back.
type ResourceClient ¶
type ResourceClient struct {
// contains filtered or unexported fields
}
ResourceClient is a client for the Resource schema.
func NewResourceClient ¶
func NewResourceClient(c config) *ResourceClient
NewResourceClient returns a client for the Resource from the given config.
func (*ResourceClient) Create ¶
func (c *ResourceClient) Create() *ResourceCreate
Create returns a builder for creating a Resource entity.
func (*ResourceClient) CreateBulk ¶
func (c *ResourceClient) CreateBulk(builders ...*ResourceCreate) *ResourceCreateBulk
CreateBulk returns a builder for creating a bulk of Resource entities.
func (*ResourceClient) Delete ¶
func (c *ResourceClient) Delete() *ResourceDelete
Delete returns a delete builder for Resource.
func (*ResourceClient) DeleteOne ¶
func (c *ResourceClient) DeleteOne(r *Resource) *ResourceDeleteOne
DeleteOne returns a builder for deleting the given entity.
func (*ResourceClient) DeleteOneID ¶
func (c *ResourceClient) DeleteOneID(id int) *ResourceDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
func (*ResourceClient) GetX ¶
func (c *ResourceClient) GetX(ctx context.Context, id int) *Resource
GetX is like Get, but panics if an error occurs.
func (*ResourceClient) Hooks ¶
func (c *ResourceClient) Hooks() []Hook
Hooks returns the client hooks.
func (*ResourceClient) Intercept ¶
func (c *ResourceClient) Intercept(interceptors ...Interceptor)
Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `resource.Intercept(f(g(h())))`.
func (*ResourceClient) Interceptors ¶
func (c *ResourceClient) Interceptors() []Interceptor
Interceptors returns the client interceptors.
func (*ResourceClient) Query ¶
func (c *ResourceClient) Query() *ResourceQuery
Query returns a query builder for Resource.
func (*ResourceClient) Update ¶
func (c *ResourceClient) Update() *ResourceUpdate
Update returns an update builder for Resource.
func (*ResourceClient) UpdateOne ¶
func (c *ResourceClient) UpdateOne(r *Resource) *ResourceUpdateOne
UpdateOne returns an update builder for the given entity.
func (*ResourceClient) UpdateOneID ¶
func (c *ResourceClient) UpdateOneID(id int) *ResourceUpdateOne
UpdateOneID returns an update builder for the given id.
func (*ResourceClient) Use ¶
func (c *ResourceClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `resource.Hooks(f(g(h())))`.
type ResourceConnection ¶
type ResourceConnection struct { Edges []*ResourceEdge `json:"edges"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` }
ResourceConnection is the connection containing edges to Resource.
type ResourceCreate ¶
type ResourceCreate struct {
// contains filtered or unexported fields
}
ResourceCreate is the builder for creating a Resource entity.
func (*ResourceCreate) Exec ¶
func (rc *ResourceCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*ResourceCreate) ExecX ¶
func (rc *ResourceCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*ResourceCreate) Mutation ¶
func (rc *ResourceCreate) Mutation() *ResourceMutation
Mutation returns the ResourceMutation object of the builder.
func (*ResourceCreate) Save ¶
func (rc *ResourceCreate) Save(ctx context.Context) (*Resource, error)
Save creates the Resource in the database.
func (*ResourceCreate) SaveX ¶
func (rc *ResourceCreate) SaveX(ctx context.Context) *Resource
SaveX calls Save and panics if Save returns an error.
func (*ResourceCreate) SetDescription ¶
func (rc *ResourceCreate) SetDescription(s string) *ResourceCreate
SetDescription sets the "description" field.
func (*ResourceCreate) SetName ¶
func (rc *ResourceCreate) SetName(s string) *ResourceCreate
SetName sets the "name" field.
func (*ResourceCreate) SetNillableDescription ¶
func (rc *ResourceCreate) SetNillableDescription(s *string) *ResourceCreate
SetNillableDescription sets the "description" field if the given value is not nil.
func (*ResourceCreate) SetNillableTenantID ¶
func (rc *ResourceCreate) SetNillableTenantID(s *string) *ResourceCreate
SetNillableTenantID sets the "tenant_id" field if the given value is not nil.
func (*ResourceCreate) SetTenantID ¶
func (rc *ResourceCreate) SetTenantID(s string) *ResourceCreate
SetTenantID sets the "tenant_id" field.
type ResourceCreateBulk ¶
type ResourceCreateBulk struct {
// contains filtered or unexported fields
}
ResourceCreateBulk is the builder for creating many Resource entities in bulk.
func (*ResourceCreateBulk) Exec ¶
func (rcb *ResourceCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*ResourceCreateBulk) ExecX ¶
func (rcb *ResourceCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type ResourceDelete ¶
type ResourceDelete struct {
// contains filtered or unexported fields
}
ResourceDelete is the builder for deleting a Resource entity.
func (*ResourceDelete) Exec ¶
func (rd *ResourceDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*ResourceDelete) ExecX ¶
func (rd *ResourceDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*ResourceDelete) Where ¶
func (rd *ResourceDelete) Where(ps ...predicate.Resource) *ResourceDelete
Where appends a list predicates to the ResourceDelete builder.
type ResourceDeleteOne ¶
type ResourceDeleteOne struct {
// contains filtered or unexported fields
}
ResourceDeleteOne is the builder for deleting a single Resource entity.
func (*ResourceDeleteOne) Exec ¶
func (rdo *ResourceDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*ResourceDeleteOne) ExecX ¶
func (rdo *ResourceDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*ResourceDeleteOne) Where ¶
func (rdo *ResourceDeleteOne) Where(ps ...predicate.Resource) *ResourceDeleteOne
Where appends a list predicates to the ResourceDelete builder.
type ResourceEdge ¶
ResourceEdge is the edge representation of Resource.
type ResourceGroupBy ¶
type ResourceGroupBy struct {
// contains filtered or unexported fields
}
ResourceGroupBy is the group-by builder for Resource entities.
func (*ResourceGroupBy) Aggregate ¶
func (rgb *ResourceGroupBy) Aggregate(fns ...AggregateFunc) *ResourceGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*ResourceGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*ResourceGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*ResourceGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*ResourceGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*ResourceGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*ResourceGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*ResourceGroupBy) Scan ¶
func (rgb *ResourceGroupBy) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*ResourceGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type ResourceMutation ¶
type ResourceMutation struct {
// contains filtered or unexported fields
}
ResourceMutation represents an operation that mutates the Resource nodes in the graph.
func (*ResourceMutation) AddField ¶
func (m *ResourceMutation) 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 (*ResourceMutation) AddedEdges ¶
func (m *ResourceMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*ResourceMutation) AddedField ¶
func (m *ResourceMutation) 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 (*ResourceMutation) AddedFields ¶
func (m *ResourceMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*ResourceMutation) AddedIDs ¶
func (m *ResourceMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*ResourceMutation) ClearDescription ¶
func (m *ResourceMutation) ClearDescription()
ClearDescription clears the value of the "description" field.
func (*ResourceMutation) ClearEdge ¶
func (m *ResourceMutation) 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 (*ResourceMutation) ClearField ¶
func (m *ResourceMutation) 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 (*ResourceMutation) ClearTenantID ¶
func (m *ResourceMutation) ClearTenantID()
ClearTenantID clears the value of the "tenant_id" field.
func (*ResourceMutation) ClearedEdges ¶
func (m *ResourceMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*ResourceMutation) ClearedFields ¶
func (m *ResourceMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (ResourceMutation) Client ¶
func (m ResourceMutation) 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 (*ResourceMutation) Description ¶
func (m *ResourceMutation) Description() (r string, exists bool)
Description returns the value of the "description" field in the mutation.
func (*ResourceMutation) DescriptionCleared ¶
func (m *ResourceMutation) DescriptionCleared() bool
DescriptionCleared returns if the "description" field was cleared in this mutation.
func (*ResourceMutation) EdgeCleared ¶
func (m *ResourceMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*ResourceMutation) Field ¶
func (m *ResourceMutation) 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 (*ResourceMutation) FieldCleared ¶
func (m *ResourceMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*ResourceMutation) Fields ¶
func (m *ResourceMutation) 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 (*ResourceMutation) ID ¶
func (m *ResourceMutation) 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 (*ResourceMutation) IDs ¶
func (m *ResourceMutation) 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 (*ResourceMutation) Name ¶
func (m *ResourceMutation) Name() (r string, exists bool)
Name returns the value of the "name" field in the mutation.
func (*ResourceMutation) OldDescription ¶
func (m *ResourceMutation) OldDescription(ctx context.Context) (v string, err error)
OldDescription returns the old "description" field's value of the Resource entity. If the Resource 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 (*ResourceMutation) 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 (*ResourceMutation) OldName ¶
func (m *ResourceMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old "name" field's value of the Resource entity. If the Resource 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 (*ResourceMutation) OldTenantID ¶
func (m *ResourceMutation) OldTenantID(ctx context.Context) (v string, err error)
OldTenantID returns the old "tenant_id" field's value of the Resource entity. If the Resource 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 (*ResourceMutation) RemovedEdges ¶
func (m *ResourceMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*ResourceMutation) RemovedIDs ¶
func (m *ResourceMutation) 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 (*ResourceMutation) ResetDescription ¶
func (m *ResourceMutation) ResetDescription()
ResetDescription resets all changes to the "description" field.
func (*ResourceMutation) ResetEdge ¶
func (m *ResourceMutation) 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 (*ResourceMutation) ResetField ¶
func (m *ResourceMutation) 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 (*ResourceMutation) ResetName ¶
func (m *ResourceMutation) ResetName()
ResetName resets all changes to the "name" field.
func (*ResourceMutation) ResetTenantID ¶
func (m *ResourceMutation) ResetTenantID()
ResetTenantID resets all changes to the "tenant_id" field.
func (*ResourceMutation) SetDescription ¶
func (m *ResourceMutation) SetDescription(s string)
SetDescription sets the "description" field.
func (*ResourceMutation) SetField ¶
func (m *ResourceMutation) 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 (*ResourceMutation) SetName ¶
func (m *ResourceMutation) SetName(s string)
SetName sets the "name" field.
func (*ResourceMutation) SetOp ¶
func (m *ResourceMutation) SetOp(op Op)
SetOp allows setting the mutation operation.
func (*ResourceMutation) SetTenantID ¶
func (m *ResourceMutation) SetTenantID(s string)
SetTenantID sets the "tenant_id" field.
func (*ResourceMutation) TenantID ¶
func (m *ResourceMutation) TenantID() (r string, exists bool)
TenantID returns the value of the "tenant_id" field in the mutation.
func (*ResourceMutation) TenantIDCleared ¶
func (m *ResourceMutation) TenantIDCleared() bool
TenantIDCleared returns if the "tenant_id" field was cleared in this mutation.
func (ResourceMutation) Tx ¶
func (m ResourceMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*ResourceMutation) Type ¶
func (m *ResourceMutation) Type() string
Type returns the node type of this mutation (Resource).
func (*ResourceMutation) Where ¶
func (m *ResourceMutation) Where(ps ...predicate.Resource)
Where appends a list predicates to the ResourceMutation builder.
func (*ResourceMutation) WhereP ¶
func (m *ResourceMutation) WhereP(ps ...func(*sql.Selector))
WhereP appends storage-level predicates to the ResourceMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.
type ResourceOrder ¶
type ResourceOrder struct { Direction OrderDirection `json:"direction"` Field *ResourceOrderField `json:"field"` }
ResourceOrder defines the ordering of Resource.
type ResourceOrderField ¶
type ResourceOrderField struct { // Value extracts the ordering value from the given Resource. Value func(*Resource) (ent.Value, error) // contains filtered or unexported fields }
ResourceOrderField defines the ordering field of Resource.
type ResourcePaginateOption ¶
type ResourcePaginateOption func(*resourcePager) error
ResourcePaginateOption enables pagination customization.
func WithResourceFilter ¶
func WithResourceFilter(filter func(*ResourceQuery) (*ResourceQuery, error)) ResourcePaginateOption
WithResourceFilter configures pagination filter.
func WithResourceOrder ¶
func WithResourceOrder(order *ResourceOrder) ResourcePaginateOption
WithResourceOrder configures pagination ordering.
type ResourceQuery ¶
type ResourceQuery struct {
// contains filtered or unexported fields
}
ResourceQuery is the builder for querying Resource entities.
func (*ResourceQuery) Aggregate ¶
func (rq *ResourceQuery) Aggregate(fns ...AggregateFunc) *ResourceSelect
Aggregate returns a ResourceSelect configured with the given aggregations.
func (*ResourceQuery) All ¶
func (rq *ResourceQuery) All(ctx context.Context) ([]*Resource, error)
All executes the query and returns a list of Resources.
func (*ResourceQuery) AllX ¶
func (rq *ResourceQuery) AllX(ctx context.Context) []*Resource
AllX is like All, but panics if an error occurs.
func (*ResourceQuery) Clone ¶
func (rq *ResourceQuery) Clone() *ResourceQuery
Clone returns a duplicate of the ResourceQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*ResourceQuery) CollectFields ¶
func (r *ResourceQuery) CollectFields(ctx context.Context, satisfies ...string) (*ResourceQuery, error)
CollectFields tells the query-builder to eagerly load connected nodes by resolver context.
func (*ResourceQuery) Count ¶
func (rq *ResourceQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*ResourceQuery) CountX ¶
func (rq *ResourceQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*ResourceQuery) Exist ¶
func (rq *ResourceQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*ResourceQuery) ExistX ¶
func (rq *ResourceQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*ResourceQuery) First ¶
func (rq *ResourceQuery) First(ctx context.Context) (*Resource, error)
First returns the first Resource entity from the query. Returns a *NotFoundError when no Resource was found.
func (*ResourceQuery) FirstID ¶
func (rq *ResourceQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Resource ID from the query. Returns a *NotFoundError when no Resource ID was found.
func (*ResourceQuery) FirstIDX ¶
func (rq *ResourceQuery) FirstIDX(ctx context.Context) int
FirstIDX is like FirstID, but panics if an error occurs.
func (*ResourceQuery) FirstX ¶
func (rq *ResourceQuery) FirstX(ctx context.Context) *Resource
FirstX is like First, but panics if an error occurs.
func (*ResourceQuery) GroupBy ¶
func (rq *ResourceQuery) GroupBy(field string, fields ...string) *ResourceGroupBy
GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.
Example:
var v []struct { Name string `json:"name,omitempty"` Count int `json:"count,omitempty"` } client.Resource.Query(). GroupBy(resource.FieldName). Aggregate(ent.Count()). Scan(ctx, &v)
func (*ResourceQuery) IDs ¶
func (rq *ResourceQuery) IDs(ctx context.Context) (ids []int, err error)
IDs executes the query and returns a list of Resource IDs.
func (*ResourceQuery) IDsX ¶
func (rq *ResourceQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*ResourceQuery) Limit ¶
func (rq *ResourceQuery) Limit(limit int) *ResourceQuery
Limit the number of records to be returned by this query.
func (*ResourceQuery) Offset ¶
func (rq *ResourceQuery) Offset(offset int) *ResourceQuery
Offset to start from.
func (*ResourceQuery) Only ¶
func (rq *ResourceQuery) Only(ctx context.Context) (*Resource, error)
Only returns a single Resource entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Resource entity is found. Returns a *NotFoundError when no Resource entities are found.
func (*ResourceQuery) OnlyID ¶
func (rq *ResourceQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID is like Only, but returns the only Resource ID in the query. Returns a *NotSingularError when more than one Resource ID is found. Returns a *NotFoundError when no entities are found.
func (*ResourceQuery) OnlyIDX ¶
func (rq *ResourceQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*ResourceQuery) OnlyX ¶
func (rq *ResourceQuery) OnlyX(ctx context.Context) *Resource
OnlyX is like Only, but panics if an error occurs.
func (*ResourceQuery) Order ¶
func (rq *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery
Order specifies how the records should be ordered.
func (*ResourceQuery) Paginate ¶
func (r *ResourceQuery) Paginate( ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, opts ...ResourcePaginateOption, ) (*ResourceConnection, error)
Paginate executes the query and returns a relay based cursor connection to Resource.
func (*ResourceQuery) Select ¶
func (rq *ResourceQuery) Select(fields ...string) *ResourceSelect
Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.
Example:
var v []struct { Name string `json:"name,omitempty"` } client.Resource.Query(). Select(resource.FieldName). Scan(ctx, &v)
func (*ResourceQuery) Unique ¶
func (rq *ResourceQuery) Unique(unique bool) *ResourceQuery
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 (*ResourceQuery) Where ¶
func (rq *ResourceQuery) Where(ps ...predicate.Resource) *ResourceQuery
Where adds a new predicate for the ResourceQuery builder.
type ResourceSelect ¶
type ResourceSelect struct { *ResourceQuery // contains filtered or unexported fields }
ResourceSelect is the builder for selecting fields of Resource entities.
func (*ResourceSelect) Aggregate ¶
func (rs *ResourceSelect) Aggregate(fns ...AggregateFunc) *ResourceSelect
Aggregate adds the given aggregation functions to the selector query.
func (*ResourceSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*ResourceSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*ResourceSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*ResourceSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*ResourceSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*ResourceSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*ResourceSelect) Scan ¶
func (rs *ResourceSelect) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*ResourceSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type ResourceUpdate ¶
type ResourceUpdate struct {
// contains filtered or unexported fields
}
ResourceUpdate is the builder for updating Resource entities.
func (*ResourceUpdate) ClearDescription ¶
func (ru *ResourceUpdate) ClearDescription() *ResourceUpdate
ClearDescription clears the value of the "description" field.
func (*ResourceUpdate) ClearTenantID ¶
func (ru *ResourceUpdate) ClearTenantID() *ResourceUpdate
ClearTenantID clears the value of the "tenant_id" field.
func (*ResourceUpdate) Exec ¶
func (ru *ResourceUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*ResourceUpdate) ExecX ¶
func (ru *ResourceUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*ResourceUpdate) Mutation ¶
func (ru *ResourceUpdate) Mutation() *ResourceMutation
Mutation returns the ResourceMutation object of the builder.
func (*ResourceUpdate) Save ¶
func (ru *ResourceUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*ResourceUpdate) SaveX ¶
func (ru *ResourceUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*ResourceUpdate) SetDescription ¶
func (ru *ResourceUpdate) SetDescription(s string) *ResourceUpdate
SetDescription sets the "description" field.
func (*ResourceUpdate) SetName ¶
func (ru *ResourceUpdate) SetName(s string) *ResourceUpdate
SetName sets the "name" field.
func (*ResourceUpdate) SetNillableDescription ¶
func (ru *ResourceUpdate) SetNillableDescription(s *string) *ResourceUpdate
SetNillableDescription sets the "description" field if the given value is not nil.
func (*ResourceUpdate) SetNillableTenantID ¶
func (ru *ResourceUpdate) SetNillableTenantID(s *string) *ResourceUpdate
SetNillableTenantID sets the "tenant_id" field if the given value is not nil.
func (*ResourceUpdate) SetTenantID ¶
func (ru *ResourceUpdate) SetTenantID(s string) *ResourceUpdate
SetTenantID sets the "tenant_id" field.
func (*ResourceUpdate) Where ¶
func (ru *ResourceUpdate) Where(ps ...predicate.Resource) *ResourceUpdate
Where appends a list predicates to the ResourceUpdate builder.
type ResourceUpdateOne ¶
type ResourceUpdateOne struct {
// contains filtered or unexported fields
}
ResourceUpdateOne is the builder for updating a single Resource entity.
func (*ResourceUpdateOne) ClearDescription ¶
func (ruo *ResourceUpdateOne) ClearDescription() *ResourceUpdateOne
ClearDescription clears the value of the "description" field.
func (*ResourceUpdateOne) ClearTenantID ¶
func (ruo *ResourceUpdateOne) ClearTenantID() *ResourceUpdateOne
ClearTenantID clears the value of the "tenant_id" field.
func (*ResourceUpdateOne) Exec ¶
func (ruo *ResourceUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*ResourceUpdateOne) ExecX ¶
func (ruo *ResourceUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*ResourceUpdateOne) Mutation ¶
func (ruo *ResourceUpdateOne) Mutation() *ResourceMutation
Mutation returns the ResourceMutation object of the builder.
func (*ResourceUpdateOne) Save ¶
func (ruo *ResourceUpdateOne) Save(ctx context.Context) (*Resource, error)
Save executes the query and returns the updated Resource entity.
func (*ResourceUpdateOne) SaveX ¶
func (ruo *ResourceUpdateOne) SaveX(ctx context.Context) *Resource
SaveX is like Save, but panics if an error occurs.
func (*ResourceUpdateOne) Select ¶
func (ruo *ResourceUpdateOne) Select(field string, fields ...string) *ResourceUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*ResourceUpdateOne) SetDescription ¶
func (ruo *ResourceUpdateOne) SetDescription(s string) *ResourceUpdateOne
SetDescription sets the "description" field.
func (*ResourceUpdateOne) SetName ¶
func (ruo *ResourceUpdateOne) SetName(s string) *ResourceUpdateOne
SetName sets the "name" field.
func (*ResourceUpdateOne) SetNillableDescription ¶
func (ruo *ResourceUpdateOne) SetNillableDescription(s *string) *ResourceUpdateOne
SetNillableDescription sets the "description" field if the given value is not nil.
func (*ResourceUpdateOne) SetNillableTenantID ¶
func (ruo *ResourceUpdateOne) SetNillableTenantID(s *string) *ResourceUpdateOne
SetNillableTenantID sets the "tenant_id" field if the given value is not nil.
func (*ResourceUpdateOne) SetTenantID ¶
func (ruo *ResourceUpdateOne) SetTenantID(s string) *ResourceUpdateOne
SetTenantID sets the "tenant_id" field.
func (*ResourceUpdateOne) Where ¶
func (ruo *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne
Where appends a list predicates to the ResourceUpdate builder.
type ResourceWhereInput ¶
type ResourceWhereInput struct { Predicates []predicate.Resource `json:"-"` Not *ResourceWhereInput `json:"not,omitempty"` Or []*ResourceWhereInput `json:"or,omitempty"` And []*ResourceWhereInput `json:"and,omitempty"` // "id" field predicates. ID *int `json:"id,omitempty"` IDNEQ *int `json:"idNEQ,omitempty"` IDIn []int `json:"idIn,omitempty"` IDNotIn []int `json:"idNotIn,omitempty"` IDGT *int `json:"idGT,omitempty"` IDGTE *int `json:"idGTE,omitempty"` IDLT *int `json:"idLT,omitempty"` IDLTE *int `json:"idLTE,omitempty"` // "name" field predicates. Name *string `json:"name,omitempty"` NameNEQ *string `json:"nameNEQ,omitempty"` NameIn []string `json:"nameIn,omitempty"` NameNotIn []string `json:"nameNotIn,omitempty"` NameGT *string `json:"nameGT,omitempty"` NameGTE *string `json:"nameGTE,omitempty"` NameLT *string `json:"nameLT,omitempty"` NameLTE *string `json:"nameLTE,omitempty"` NameContains *string `json:"nameContains,omitempty"` NameHasPrefix *string `json:"nameHasPrefix,omitempty"` NameHasSuffix *string `json:"nameHasSuffix,omitempty"` NameEqualFold *string `json:"nameEqualFold,omitempty"` NameContainsFold *string `json:"nameContainsFold,omitempty"` // "description" field predicates. Description *string `json:"description,omitempty"` DescriptionNEQ *string `json:"descriptionNEQ,omitempty"` DescriptionIn []string `json:"descriptionIn,omitempty"` DescriptionNotIn []string `json:"descriptionNotIn,omitempty"` DescriptionGT *string `json:"descriptionGT,omitempty"` DescriptionGTE *string `json:"descriptionGTE,omitempty"` DescriptionLT *string `json:"descriptionLT,omitempty"` DescriptionLTE *string `json:"descriptionLTE,omitempty"` DescriptionContains *string `json:"descriptionContains,omitempty"` DescriptionHasPrefix *string `json:"descriptionHasPrefix,omitempty"` DescriptionHasSuffix *string `json:"descriptionHasSuffix,omitempty"` DescriptionIsNil bool `json:"descriptionIsNil,omitempty"` DescriptionNotNil bool `json:"descriptionNotNil,omitempty"` DescriptionEqualFold *string `json:"descriptionEqualFold,omitempty"` DescriptionContainsFold *string `json:"descriptionContainsFold,omitempty"` // "tenant_id" field predicates. TenantID *string `json:"tenantID,omitempty"` TenantIDNEQ *string `json:"tenantIDNEQ,omitempty"` TenantIDIn []string `json:"tenantIDIn,omitempty"` TenantIDNotIn []string `json:"tenantIDNotIn,omitempty"` TenantIDGT *string `json:"tenantIDGT,omitempty"` TenantIDGTE *string `json:"tenantIDGTE,omitempty"` TenantIDLT *string `json:"tenantIDLT,omitempty"` TenantIDLTE *string `json:"tenantIDLTE,omitempty"` TenantIDContains *string `json:"tenantIDContains,omitempty"` TenantIDHasPrefix *string `json:"tenantIDHasPrefix,omitempty"` TenantIDHasSuffix *string `json:"tenantIDHasSuffix,omitempty"` TenantIDIsNil bool `json:"tenantIDIsNil,omitempty"` TenantIDNotNil bool `json:"tenantIDNotNil,omitempty"` TenantIDEqualFold *string `json:"tenantIDEqualFold,omitempty"` TenantIDContainsFold *string `json:"tenantIDContainsFold,omitempty"` }
ResourceWhereInput represents a where input for filtering Resource queries.
func (*ResourceWhereInput) AddPredicates ¶
func (i *ResourceWhereInput) AddPredicates(predicates ...predicate.Resource)
AddPredicates adds custom predicates to the where input to be used during the filtering phase.
func (*ResourceWhereInput) Filter ¶
func (i *ResourceWhereInput) Filter(q *ResourceQuery) (*ResourceQuery, error)
Filter applies the ResourceWhereInput filter on the ResourceQuery builder.
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 TraverseFunc ¶
type TraverseFunc = ent.TraverseFunc
ent aliases to avoid import conflicts in user's code.
type Tx ¶
type Tx struct { // Resource is the client for interacting with the Resource builders. Resource *ResourceClient // 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.