Documentation
¶
Index ¶
- Constants
- Variables
- func AccountOrder(r entapi.ListRequest) ([]account.OrderOption, error)
- func AccountPatchRequestTags() []string
- func Asc(fields ...string) func(*sql.Selector)
- func DeleteAccount(ctx context.Context, db *Client, id int) error
- func DeleteBatchAccounts(ctx context.Context, db *Client, ids []int) (int, error)
- 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 ListAccounts(ctx context.Context, db *Client, f *AccountFilter, r entapi.ListRequest) (*entapi.Page[AccountResponse], error)
- func MaskNotFound(err error) error
- func NewContext(parent context.Context, c *Client) context.Context
- func NewTxContext(parent context.Context, tx *Tx) context.Context
- type APIHandler
- func (h *APIHandler) DeleteAccountEndpoint() entapi.Endpoint
- func (h *APIHandler) Endpoints() []entapi.Endpoint
- func (h *APIHandler) GetAccountEndpoint() entapi.Endpoint
- func (h *APIHandler) ListAccountsEndpoint() entapi.Endpoint
- func (h *APIHandler) Mount(mux *http.ServeMux)
- func (h *APIHandler) OpenAPIEndpoint() entapi.Endpoint
- func (h *APIHandler) PatchAccountEndpoint() entapi.Endpoint
- func (h *APIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) With(opts ...APIOption) *APIHandler
- type APIOption
- type Account
- type AccountClient
- func (c *AccountClient) Create() *AccountCreate
- func (c *AccountClient) CreateBulk(builders ...*AccountCreate) *AccountCreateBulk
- func (c *AccountClient) Delete() *AccountDelete
- func (c *AccountClient) DeleteOne(a *Account) *AccountDeleteOne
- func (c *AccountClient) DeleteOneID(id int) *AccountDeleteOne
- func (c *AccountClient) Get(ctx context.Context, id int) (*Account, error)
- func (c *AccountClient) GetX(ctx context.Context, id int) *Account
- func (c *AccountClient) Hooks() []Hook
- func (c *AccountClient) Intercept(interceptors ...Interceptor)
- func (c *AccountClient) Interceptors() []Interceptor
- func (c *AccountClient) MapCreateBulk(slice any, setFunc func(*AccountCreate, int)) *AccountCreateBulk
- func (c *AccountClient) Query() *AccountQuery
- func (c *AccountClient) Update() *AccountUpdate
- func (c *AccountClient) UpdateOne(a *Account) *AccountUpdateOne
- func (c *AccountClient) UpdateOneID(id int) *AccountUpdateOne
- func (c *AccountClient) Use(hooks ...Hook)
- type AccountCreate
- func (ac *AccountCreate) Exec(ctx context.Context) error
- func (ac *AccountCreate) ExecX(ctx context.Context)
- func (ac *AccountCreate) Mutation() *AccountMutation
- func (ac *AccountCreate) Save(ctx context.Context) (*Account, error)
- func (ac *AccountCreate) SaveX(ctx context.Context) *Account
- func (ac *AccountCreate) SetName(s string) *AccountCreate
- func (ac *AccountCreate) SetSecret(s string) *AccountCreate
- type AccountCreateBulk
- type AccountDelete
- type AccountDeleteOne
- type AccountFilter
- type AccountGroupBy
- func (agb *AccountGroupBy) Aggregate(fns ...AggregateFunc) *AccountGroupBy
- func (s *AccountGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *AccountGroupBy) BoolX(ctx context.Context) bool
- func (s *AccountGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *AccountGroupBy) BoolsX(ctx context.Context) []bool
- func (s *AccountGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *AccountGroupBy) Float64X(ctx context.Context) float64
- func (s *AccountGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *AccountGroupBy) Float64sX(ctx context.Context) []float64
- func (s *AccountGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *AccountGroupBy) IntX(ctx context.Context) int
- func (s *AccountGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *AccountGroupBy) IntsX(ctx context.Context) []int
- func (agb *AccountGroupBy) Scan(ctx context.Context, v any) error
- func (s *AccountGroupBy) ScanX(ctx context.Context, v any)
- func (s *AccountGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *AccountGroupBy) StringX(ctx context.Context) string
- func (s *AccountGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *AccountGroupBy) StringsX(ctx context.Context) []string
- type AccountListResponse
- type AccountMutation
- func (m *AccountMutation) AddField(name string, value ent.Value) error
- func (m *AccountMutation) AddedEdges() []string
- func (m *AccountMutation) AddedField(name string) (ent.Value, bool)
- func (m *AccountMutation) AddedFields() []string
- func (m *AccountMutation) AddedIDs(name string) []ent.Value
- func (m *AccountMutation) ClearEdge(name string) error
- func (m *AccountMutation) ClearField(name string) error
- func (m *AccountMutation) ClearedEdges() []string
- func (m *AccountMutation) ClearedFields() []string
- func (m AccountMutation) Client() *Client
- func (m *AccountMutation) EdgeCleared(name string) bool
- func (m *AccountMutation) Field(name string) (ent.Value, bool)
- func (m *AccountMutation) FieldCleared(name string) bool
- func (m *AccountMutation) Fields() []string
- func (m *AccountMutation) ID() (id int, exists bool)
- func (m *AccountMutation) IDs(ctx context.Context) ([]int, error)
- func (m *AccountMutation) Name() (r string, exists bool)
- func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *AccountMutation) OldName(ctx context.Context) (v string, err error)
- func (m *AccountMutation) OldSecret(ctx context.Context) (v string, err error)
- func (m *AccountMutation) Op() Op
- func (m *AccountMutation) RemovedEdges() []string
- func (m *AccountMutation) RemovedIDs(name string) []ent.Value
- func (m *AccountMutation) ResetEdge(name string) error
- func (m *AccountMutation) ResetField(name string) error
- func (m *AccountMutation) ResetName()
- func (m *AccountMutation) ResetSecret()
- func (m *AccountMutation) Secret() (r string, exists bool)
- func (m *AccountMutation) SetField(name string, value ent.Value) error
- func (m *AccountMutation) SetName(s string)
- func (m *AccountMutation) SetOp(op Op)
- func (m *AccountMutation) SetSecret(s string)
- func (m AccountMutation) Tx() (*Tx, error)
- func (m *AccountMutation) Type() string
- func (m *AccountMutation) Where(ps ...predicate.Account)
- func (m *AccountMutation) WhereP(ps ...func(*sql.Selector))
- type AccountPatchRequest
- type AccountQuery
- func (aq *AccountQuery) Aggregate(fns ...AggregateFunc) *AccountSelect
- func (aq *AccountQuery) All(ctx context.Context) ([]*Account, error)
- func (aq *AccountQuery) AllX(ctx context.Context) []*Account
- func (aq *AccountQuery) Clone() *AccountQuery
- func (aq *AccountQuery) Count(ctx context.Context) (int, error)
- func (aq *AccountQuery) CountX(ctx context.Context) int
- func (aq *AccountQuery) Exist(ctx context.Context) (bool, error)
- func (aq *AccountQuery) ExistX(ctx context.Context) bool
- func (aq *AccountQuery) First(ctx context.Context) (*Account, error)
- func (aq *AccountQuery) FirstID(ctx context.Context) (id int, err error)
- func (aq *AccountQuery) FirstIDX(ctx context.Context) int
- func (aq *AccountQuery) FirstX(ctx context.Context) *Account
- func (aq *AccountQuery) GroupBy(field string, fields ...string) *AccountGroupBy
- func (aq *AccountQuery) IDs(ctx context.Context) (ids []int, err error)
- func (aq *AccountQuery) IDsX(ctx context.Context) []int
- func (aq *AccountQuery) Limit(limit int) *AccountQuery
- func (aq *AccountQuery) Offset(offset int) *AccountQuery
- func (aq *AccountQuery) Only(ctx context.Context) (*Account, error)
- func (aq *AccountQuery) OnlyID(ctx context.Context) (id int, err error)
- func (aq *AccountQuery) OnlyIDX(ctx context.Context) int
- func (aq *AccountQuery) OnlyX(ctx context.Context) *Account
- func (aq *AccountQuery) Order(o ...account.OrderOption) *AccountQuery
- func (aq *AccountQuery) Select(fields ...string) *AccountSelect
- func (aq *AccountQuery) Unique(unique bool) *AccountQuery
- func (aq *AccountQuery) Where(ps ...predicate.Account) *AccountQuery
- type AccountResponse
- type AccountSelect
- func (as *AccountSelect) Aggregate(fns ...AggregateFunc) *AccountSelect
- func (s *AccountSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *AccountSelect) BoolX(ctx context.Context) bool
- func (s *AccountSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *AccountSelect) BoolsX(ctx context.Context) []bool
- func (s *AccountSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *AccountSelect) Float64X(ctx context.Context) float64
- func (s *AccountSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *AccountSelect) Float64sX(ctx context.Context) []float64
- func (s *AccountSelect) Int(ctx context.Context) (_ int, err error)
- func (s *AccountSelect) IntX(ctx context.Context) int
- func (s *AccountSelect) Ints(ctx context.Context) ([]int, error)
- func (s *AccountSelect) IntsX(ctx context.Context) []int
- func (as *AccountSelect) Scan(ctx context.Context, v any) error
- func (s *AccountSelect) ScanX(ctx context.Context, v any)
- func (s *AccountSelect) String(ctx context.Context) (_ string, err error)
- func (s *AccountSelect) StringX(ctx context.Context) string
- func (s *AccountSelect) Strings(ctx context.Context) ([]string, error)
- func (s *AccountSelect) StringsX(ctx context.Context) []string
- type AccountSummary
- type AccountUpdate
- func (au *AccountUpdate) Exec(ctx context.Context) error
- func (au *AccountUpdate) ExecX(ctx context.Context)
- func (au *AccountUpdate) Mutation() *AccountMutation
- func (au *AccountUpdate) Save(ctx context.Context) (int, error)
- func (au *AccountUpdate) SaveX(ctx context.Context) int
- func (au *AccountUpdate) SetName(s string) *AccountUpdate
- func (au *AccountUpdate) SetNillableName(s *string) *AccountUpdate
- func (au *AccountUpdate) SetNillableSecret(s *string) *AccountUpdate
- func (au *AccountUpdate) SetSecret(s string) *AccountUpdate
- func (au *AccountUpdate) Where(ps ...predicate.Account) *AccountUpdate
- type AccountUpdateOne
- func (auo *AccountUpdateOne) Exec(ctx context.Context) error
- func (auo *AccountUpdateOne) ExecX(ctx context.Context)
- func (auo *AccountUpdateOne) Mutation() *AccountMutation
- func (auo *AccountUpdateOne) Save(ctx context.Context) (*Account, error)
- func (auo *AccountUpdateOne) SaveX(ctx context.Context) *Account
- func (auo *AccountUpdateOne) Select(field string, fields ...string) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetName(s string) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetNillableName(s *string) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetNillableSecret(s *string) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetSecret(s string) *AccountUpdateOne
- func (auo *AccountUpdateOne) Where(ps ...predicate.Account) *AccountUpdateOne
- type Accounts
- 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 DeleteAccountFn
- type GetAccountFn
- type Hook
- type InterceptFunc
- type Interceptor
- type ListAccountsFn
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- type PatchAccountFn
- type Policy
- type Querier
- type QuerierFunc
- type Query
- type QueryContext
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- type TraverseFunc
- type Traverser
- type Tx
- type ValidAccountPatchRequest
- 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. TypeAccount = "Account" )
Variables ¶
var AccountSortKeys = []string{
"id",
}
AccountSortKeys is the complete sort allow-list. The primary key is naturally Sortable; every other key requires api.Sortable().
var ErrTxStarted = errors.New("createexceptedent: cannot start a transaction within a transaction")
ErrTxStarted is returned when trying to start a new transaction from a transactional client.
var ErrorMap = entapi.NewErrorMapper(IsNotFound, IsConstraintError). WithValidation(IsValidationError, func(err error) (string, bool) { var ve *ValidationError if errors.As(err, &ve) { return ve.Name, true } return "", false })
ErrorMap is the classifier every generated wiring function passes its error through before returning it.
One variable for the whole package, rather than a parameter on each operation. That is what makes entapi.IsNotFound answer the same way whichever function produced the error: a mapper threaded through as an argument would hold that property only for as long as every call site kept passing the same one, and there is no way to check that from here.
IsNotFound, IsConstraintError and IsValidationError are ent's own, generated into THIS package. The framework does not export them and cannot: ent generates NotFoundError and ConstraintError per project. That is why the runtime takes its classification as function values and never names an ent type — see entapi.ErrorMapper.
ValidationError is generated in this package too. The extractor keeps that type out of the stdlib-only runtime while preserving its field name for an RFC 9457 response.
API installs the runtime determination for the client's dialect unless the consumer already supplied one. ErrorMap is an ordinary package-level variable and carries no synchronisation of its own; configure overrides while building the client, before serving requests.
Functions ¶
func AccountOrder ¶
func AccountOrder(r entapi.ListRequest) ([]account.OrderOption, error)
AccountOrder is the single sort allow-list seam.
func AccountPatchRequestTags ¶
func AccountPatchRequestTags() []string
AccountPatchRequestTags returns the canonical JSON key of every field on AccountPatchRequest, in declaration order. Generated handlers compare raw request keys against this data to reject unknown keys.
Like Endpoints(), it returns a fresh copy on every call: slices are mutable, so exporting the variable would let any consumer mutate validation data that every generated handler in the process reads. The unexported variable remains the source of truth; this accessor is for consumers that decline the generated handler and write their own bind step.
func DeleteAccount ¶
DeleteAccount removes one Account.
No runtime routine is involved: ent's own builder is already the single line, and there is nothing to convert. What "delete" means for an entity with a soft-delete column is decided by an ent interceptor or mixin, not by a filename convention read out of the schema.
func DeleteBatchAccounts ¶
DeleteBatchAccounts removes several Accounts in one statement and returns how many rows it deleted.
The count is returned rather than discarded because ent computes it and the caller cannot recover it afterwards: a batch delete reports no error for an id that matched nothing, so "how many of the ids existed" is answerable here and nowhere else.
An empty list deletes nothing. That is ent's own reading of IDIn with no arguments, not a guard written here — a guard would be a second place for the rule to live, and the failure it protects against is unrecoverable.
An id that matched nothing is not an error here, so this operation never produces a not-found — but it can still fail a foreign-key check, which is exactly the case the mapping must NOT report as already-exists.
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 ListAccounts ¶
func ListAccounts(ctx context.Context, db *Client, f *AccountFilter, r entapi.ListRequest) (*entapi.Page[AccountResponse], error)
ListAccounts runs a filtered, ordered, paginated query.
This is the one operation whose body is not a single call, and the reason is worth stating rather than hiding: AccountOrder can fail, because a sort key outside AccountSortKeys has no correct answer and serving a differently-ordered page instead is worse than refusing. entapi.ListPage takes resolved order options, not a fallible producer of them, so the check happens here.
A nil filter contributes no predicates, so a caller with nothing to filter by does not need a branch of its own.
The sort-key failure returns before the mapping. It is already an entapi.ErrValidation and never reached the database, so there is nothing for a persistence-layer classifier to say about it.
func NewContext ¶
NewContext returns a new context with the given Client attached.
Types ¶
type APIHandler ¶
type APIHandler struct {
// contains filtered or unexported fields
}
APIHandler is the generated CRUD HTTP surface.
func API ¶
func API(client *Client) *APIHandler
API builds the generated CRUD HTTP surface for client.
func (*APIHandler) DeleteAccountEndpoint ¶
func (h *APIHandler) DeleteAccountEndpoint() entapi.Endpoint
DeleteAccountEndpoint returns the generated DELETE /accounts/{id} endpoint.
func (*APIHandler) Endpoints ¶
func (h *APIHandler) Endpoints() []entapi.Endpoint
Endpoints returns the generated endpoint manifest in deterministic registration order. It is data to compose into a router of your choosing; ServeHTTP and Mount are the convenience built from the same manifest.
It is the batch half of the composition surface. The per-operation accessors below are the take-one-by-name half: this slice is built by calling them, so the two cannot describe different endpoints, and every handler reads the current implementation through h, so a With after the call still takes effect. Endpoint values are not comparable; to skip or deduplicate rows, key on Method plus Path, or on Op. Except removes the method along with the endpoint, so naming an operation that is not exposed is a compile error.
func (*APIHandler) GetAccountEndpoint ¶
func (h *APIHandler) GetAccountEndpoint() entapi.Endpoint
GetAccountEndpoint returns the generated GET /accounts/{id} endpoint.
func (*APIHandler) ListAccountsEndpoint ¶
func (h *APIHandler) ListAccountsEndpoint() entapi.Endpoint
ListAccountsEndpoint returns the generated GET /accounts endpoint.
func (*APIHandler) Mount ¶
func (h *APIHandler) Mount(mux *http.ServeMux)
Mount registers every generated endpoint on mux.
func (*APIHandler) OpenAPIEndpoint ¶
func (h *APIHandler) OpenAPIEndpoint() entapi.Endpoint
OpenAPIEndpoint returns the generated GET /openapi.yaml endpoint serving the generated document. It is the manifest's one entry with no Entity and no Op: it describes the resource surface rather than belonging to it.
func (*APIHandler) PatchAccountEndpoint ¶
func (h *APIHandler) PatchAccountEndpoint() entapi.Endpoint
PatchAccountEndpoint returns the generated PATCH /accounts/{id} endpoint.
func (*APIHandler) ServeHTTP ¶
func (h *APIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves every generated endpoint through the internal mux.
func (*APIHandler) With ¶
func (h *APIHandler) With(opts ...APIOption) *APIHandler
With replaces generated operation implementations before serving begins.
type APIOption ¶
type APIOption interface {
// contains filtered or unexported methods
}
APIOption replaces one generated operation implementation.
type Account ¶
type Account struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Secret holds the value of the "secret" field.
Secret string `json:"secret,omitempty"`
// contains filtered or unexported fields
}
Account is the model entity for the Account schema.
func (*Account) Unwrap ¶
Unwrap unwraps the Account 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 (*Account) Update ¶
func (a *Account) Update() *AccountUpdateOne
Update returns a builder for updating this Account. Note that you need to call Account.Unwrap() before calling this method if this Account was returned from a transaction, and the transaction was committed or rolled back.
type AccountClient ¶
type AccountClient struct {
// contains filtered or unexported fields
}
AccountClient is a client for the Account schema.
func NewAccountClient ¶
func NewAccountClient(c config) *AccountClient
NewAccountClient returns a client for the Account from the given config.
func (*AccountClient) Create ¶
func (c *AccountClient) Create() *AccountCreate
Create returns a builder for creating a Account entity.
func (*AccountClient) CreateBulk ¶
func (c *AccountClient) CreateBulk(builders ...*AccountCreate) *AccountCreateBulk
CreateBulk returns a builder for creating a bulk of Account entities.
func (*AccountClient) Delete ¶
func (c *AccountClient) Delete() *AccountDelete
Delete returns a delete builder for Account.
func (*AccountClient) DeleteOne ¶
func (c *AccountClient) DeleteOne(a *Account) *AccountDeleteOne
DeleteOne returns a builder for deleting the given entity.
func (*AccountClient) DeleteOneID ¶
func (c *AccountClient) DeleteOneID(id int) *AccountDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
func (*AccountClient) GetX ¶
func (c *AccountClient) GetX(ctx context.Context, id int) *Account
GetX is like Get, but panics if an error occurs.
func (*AccountClient) Hooks ¶
func (c *AccountClient) Hooks() []Hook
Hooks returns the client hooks.
func (*AccountClient) Intercept ¶
func (c *AccountClient) Intercept(interceptors ...Interceptor)
Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `account.Intercept(f(g(h())))`.
func (*AccountClient) Interceptors ¶
func (c *AccountClient) Interceptors() []Interceptor
Interceptors returns the client interceptors.
func (*AccountClient) MapCreateBulk ¶
func (c *AccountClient) MapCreateBulk(slice any, setFunc func(*AccountCreate, int)) *AccountCreateBulk
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 (*AccountClient) Query ¶
func (c *AccountClient) Query() *AccountQuery
Query returns a query builder for Account.
func (*AccountClient) Update ¶
func (c *AccountClient) Update() *AccountUpdate
Update returns an update builder for Account.
func (*AccountClient) UpdateOne ¶
func (c *AccountClient) UpdateOne(a *Account) *AccountUpdateOne
UpdateOne returns an update builder for the given entity.
func (*AccountClient) UpdateOneID ¶
func (c *AccountClient) UpdateOneID(id int) *AccountUpdateOne
UpdateOneID returns an update builder for the given id.
func (*AccountClient) Use ¶
func (c *AccountClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `account.Hooks(f(g(h())))`.
type AccountCreate ¶
type AccountCreate struct {
// contains filtered or unexported fields
}
AccountCreate is the builder for creating a Account entity.
func (*AccountCreate) Exec ¶
func (ac *AccountCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*AccountCreate) ExecX ¶
func (ac *AccountCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*AccountCreate) Mutation ¶
func (ac *AccountCreate) Mutation() *AccountMutation
Mutation returns the AccountMutation object of the builder.
func (*AccountCreate) Save ¶
func (ac *AccountCreate) Save(ctx context.Context) (*Account, error)
Save creates the Account in the database.
func (*AccountCreate) SaveX ¶
func (ac *AccountCreate) SaveX(ctx context.Context) *Account
SaveX calls Save and panics if Save returns an error.
func (*AccountCreate) SetName ¶
func (ac *AccountCreate) SetName(s string) *AccountCreate
SetName sets the "name" field.
func (*AccountCreate) SetSecret ¶
func (ac *AccountCreate) SetSecret(s string) *AccountCreate
SetSecret sets the "secret" field.
type AccountCreateBulk ¶
type AccountCreateBulk struct {
// contains filtered or unexported fields
}
AccountCreateBulk is the builder for creating many Account entities in bulk.
func (*AccountCreateBulk) Exec ¶
func (acb *AccountCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*AccountCreateBulk) ExecX ¶
func (acb *AccountCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type AccountDelete ¶
type AccountDelete struct {
// contains filtered or unexported fields
}
AccountDelete is the builder for deleting a Account entity.
func (*AccountDelete) Exec ¶
func (ad *AccountDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*AccountDelete) ExecX ¶
func (ad *AccountDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*AccountDelete) Where ¶
func (ad *AccountDelete) Where(ps ...predicate.Account) *AccountDelete
Where appends a list predicates to the AccountDelete builder.
type AccountDeleteOne ¶
type AccountDeleteOne struct {
// contains filtered or unexported fields
}
AccountDeleteOne is the builder for deleting a single Account entity.
func (*AccountDeleteOne) Exec ¶
func (ado *AccountDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*AccountDeleteOne) ExecX ¶
func (ado *AccountDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*AccountDeleteOne) Where ¶
func (ado *AccountDeleteOne) Where(ps ...predicate.Account) *AccountDeleteOne
Where appends a list predicates to the AccountDelete builder.
type AccountFilter ¶
type AccountFilter struct {
// id: int
ID []int `json:"id,omitempty"`
IDNEQ []int `json:"id_neq,omitempty"`
IDIn [][]int `json:"id_in,omitempty"`
IDNotIn [][]int `json:"id_not_in,omitempty"`
IDGT []int `json:"id_gt,omitempty"`
IDGTE []int `json:"id_gte,omitempty"`
IDLT []int `json:"id_lt,omitempty"`
IDLTE []int `json:"id_lte,omitempty"`
}
AccountFilter is the typed query representation for Account. Repeated URL parameters occupy repeated slots and Predicates ANDs them.
func ParseAccountQuery ¶
func ParseAccountQuery(q url.Values) (*AccountFilter, entapi.ListRequest, error)
ParseAccountQuery parses the complete URL query contract in sorted-key order. Runtime code owns lexical grammar; the generated operator tables own the field-local operator set, conversion and predicate slots.
func (*AccountFilter) Predicates ¶
func (f *AccountFilter) Predicates() []predicate.Account
Predicates converts the typed filter into conjunctive ent predicates.
type AccountGroupBy ¶
type AccountGroupBy struct {
// contains filtered or unexported fields
}
AccountGroupBy is the group-by builder for Account entities.
func (*AccountGroupBy) Aggregate ¶
func (agb *AccountGroupBy) Aggregate(fns ...AggregateFunc) *AccountGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*AccountGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*AccountGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*AccountGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*AccountGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*AccountGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*AccountGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*AccountGroupBy) Scan ¶
func (agb *AccountGroupBy) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*AccountGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type AccountListResponse ¶
type AccountListResponse struct {
Data []*AccountResponse `json:"data"`
Total int `json:"total"`
Page int `json:"page"`
Size int `json:"size"`
}
AccountListResponse is the NAMED, non-generic shape of one list page — for OpenAPI/swaggo-class annotation tooling, which cannot express the generic entapi.Page[AccountResponse] that ListAccounts returns. Convert at the handler boundary with NewAccountListResponse. (A fifth field, PageInfo, carried cursor metadata until #6 removed it.)
func NewAccountListResponse ¶
func NewAccountListResponse(p *entapi.Page[AccountResponse]) *AccountListResponse
NewAccountListResponse converts the page ListAccounts returns into the named list shape. The conversion expression is the shape contract: if AccountListResponse and entapi.Page ever diverge in field set, type or order, this line stops compiling in every generated package. JSON tags are outside what a conversion checks; the wire-format golden test in the basic fixture guards those.
type AccountMutation ¶
type AccountMutation struct {
// contains filtered or unexported fields
}
AccountMutation represents an operation that mutates the Account nodes in the graph.
func (*AccountMutation) AddField ¶
func (m *AccountMutation) 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 (*AccountMutation) AddedEdges ¶
func (m *AccountMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*AccountMutation) AddedField ¶
func (m *AccountMutation) 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 (*AccountMutation) AddedFields ¶
func (m *AccountMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*AccountMutation) AddedIDs ¶
func (m *AccountMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*AccountMutation) ClearEdge ¶
func (m *AccountMutation) 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 (*AccountMutation) ClearField ¶
func (m *AccountMutation) 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 (*AccountMutation) ClearedEdges ¶
func (m *AccountMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*AccountMutation) ClearedFields ¶
func (m *AccountMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (AccountMutation) Client ¶
func (m AccountMutation) 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 (*AccountMutation) EdgeCleared ¶
func (m *AccountMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*AccountMutation) Field ¶
func (m *AccountMutation) 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 (*AccountMutation) FieldCleared ¶
func (m *AccountMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*AccountMutation) Fields ¶
func (m *AccountMutation) 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 (*AccountMutation) ID ¶
func (m *AccountMutation) 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 (*AccountMutation) IDs ¶
func (m *AccountMutation) 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 (*AccountMutation) Name ¶
func (m *AccountMutation) Name() (r string, exists bool)
Name returns the value of the "name" field in the mutation.
func (*AccountMutation) 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 (*AccountMutation) OldName ¶
func (m *AccountMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old "name" field's value of the Account entity. If the Account 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 (*AccountMutation) OldSecret ¶
func (m *AccountMutation) OldSecret(ctx context.Context) (v string, err error)
OldSecret returns the old "secret" field's value of the Account entity. If the Account 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 (*AccountMutation) RemovedEdges ¶
func (m *AccountMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*AccountMutation) RemovedIDs ¶
func (m *AccountMutation) 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 (*AccountMutation) ResetEdge ¶
func (m *AccountMutation) 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 (*AccountMutation) ResetField ¶
func (m *AccountMutation) 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 (*AccountMutation) ResetName ¶
func (m *AccountMutation) ResetName()
ResetName resets all changes to the "name" field.
func (*AccountMutation) ResetSecret ¶
func (m *AccountMutation) ResetSecret()
ResetSecret resets all changes to the "secret" field.
func (*AccountMutation) Secret ¶
func (m *AccountMutation) Secret() (r string, exists bool)
Secret returns the value of the "secret" field in the mutation.
func (*AccountMutation) SetField ¶
func (m *AccountMutation) 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 (*AccountMutation) SetName ¶
func (m *AccountMutation) SetName(s string)
SetName sets the "name" field.
func (*AccountMutation) SetOp ¶
func (m *AccountMutation) SetOp(op Op)
SetOp allows setting the mutation operation.
func (*AccountMutation) SetSecret ¶
func (m *AccountMutation) SetSecret(s string)
SetSecret sets the "secret" field.
func (AccountMutation) Tx ¶
func (m AccountMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*AccountMutation) Type ¶
func (m *AccountMutation) Type() string
Type returns the node type of this mutation (Account).
func (*AccountMutation) Where ¶
func (m *AccountMutation) Where(ps ...predicate.Account)
Where appends a list predicates to the AccountMutation builder.
func (*AccountMutation) WhereP ¶
func (m *AccountMutation) WhereP(ps ...func(*sql.Selector))
WhereP appends storage-level predicates to the AccountMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.
type AccountPatchRequest ¶
type AccountPatchRequest struct {
Name *string `json:"name,omitempty"`
// contains filtered or unexported fields
}
AccountPatchRequest is the partial-update request for Account.
Every field is a pointer and presence is recorded separately, which is what separates the three states a PATCH has to express: absent means "leave it alone", an explicit null means "clear it", and a value means "set it". With bare pointers the first two are the same value, and clearing a field cannot be expressed at all.
A field the ent schema marks Immutable() is absent from this struct, because ent's update builders iterate MutableFields and generate no setter for one. encoding/json discards the key before any validator can see it, so a caller who sends it gets silence — rejecting that needs DisallowUnknownFields, which belongs to the consumer's handler.
func (*AccountPatchRequest) HasName ¶
func (r *AccountPatchRequest) HasName() bool
HasName reports whether the payload carried "name".
func (*AccountPatchRequest) UnmarshalJSON ¶
func (r *AccountPatchRequest) UnmarshalJSON(b []byte) error
UnmarshalJSON records which keys the payload carried, including the ones whose value was null — that is the whole point here, and the difference from the create request, where a null has nothing to clear.
A key that case-folds to a canonical tag without matching it exactly is rejected (#58, ADR-0001). The patch side is where that mattered most: a case-variant key decoded into the field while Has<Field>() stayed false, so Apply wrote nothing and the update reported success having changed no row — and a payload carrying BOTH spellings could clear a field the exact key had just set. The check runs after raw decodes and BEFORE the alias decode, so a rejected request leaves the receiver untouched.
func (*AccountPatchRequest) Validate ¶
func (r *AccountPatchRequest) Validate() (*ValidAccountPatchRequest, error)
Validate rejects an explicit null on a field that cannot be cleared.
ent emits Clear<Field>() for Optional fields and for no others, so a null on anything else has no correct translation: the column is NOT NULL and there is no method to call. The field is named in the error, because "invalid request" tells the caller nothing about which key to fix.
type AccountQuery ¶
type AccountQuery struct {
// contains filtered or unexported fields
}
AccountQuery is the builder for querying Account entities.
func AccountQueryWithResponseEdges ¶
func AccountQueryWithResponseEdges(q *AccountQuery) *AccountQuery
AccountQueryWithResponseEdges applies the eager-load plan for AccountResponse.
The plan is generated from the response type's own edge set, so no individual edge can be omitted from it. Generated wiring always routes through this function.
For a hand-written query, using this function is a convention the type system does not enforce. An entity loaded without this plan makes NewAccountResponse return a not-loaded-edge error at run time. It fails loudly; it never silently narrows the response.
With no expanded edges, this function is the identity function. It exists so every entity has the same call shape.
func (*AccountQuery) Aggregate ¶
func (aq *AccountQuery) Aggregate(fns ...AggregateFunc) *AccountSelect
Aggregate returns a AccountSelect configured with the given aggregations.
func (*AccountQuery) All ¶
func (aq *AccountQuery) All(ctx context.Context) ([]*Account, error)
All executes the query and returns a list of Accounts.
func (*AccountQuery) AllX ¶
func (aq *AccountQuery) AllX(ctx context.Context) []*Account
AllX is like All, but panics if an error occurs.
func (*AccountQuery) Clone ¶
func (aq *AccountQuery) Clone() *AccountQuery
Clone returns a duplicate of the AccountQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*AccountQuery) Count ¶
func (aq *AccountQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*AccountQuery) CountX ¶
func (aq *AccountQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*AccountQuery) Exist ¶
func (aq *AccountQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*AccountQuery) ExistX ¶
func (aq *AccountQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*AccountQuery) First ¶
func (aq *AccountQuery) First(ctx context.Context) (*Account, error)
First returns the first Account entity from the query. Returns a *NotFoundError when no Account was found.
func (*AccountQuery) FirstID ¶
func (aq *AccountQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Account ID from the query. Returns a *NotFoundError when no Account ID was found.
func (*AccountQuery) FirstIDX ¶
func (aq *AccountQuery) FirstIDX(ctx context.Context) int
FirstIDX is like FirstID, but panics if an error occurs.
func (*AccountQuery) FirstX ¶
func (aq *AccountQuery) FirstX(ctx context.Context) *Account
FirstX is like First, but panics if an error occurs.
func (*AccountQuery) GroupBy ¶
func (aq *AccountQuery) GroupBy(field string, fields ...string) *AccountGroupBy
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.Account.Query().
GroupBy(account.FieldName).
Aggregate(createexceptedent.Count()).
Scan(ctx, &v)
func (*AccountQuery) IDs ¶
func (aq *AccountQuery) IDs(ctx context.Context) (ids []int, err error)
IDs executes the query and returns a list of Account IDs.
func (*AccountQuery) IDsX ¶
func (aq *AccountQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*AccountQuery) Limit ¶
func (aq *AccountQuery) Limit(limit int) *AccountQuery
Limit the number of records to be returned by this query.
func (*AccountQuery) Offset ¶
func (aq *AccountQuery) Offset(offset int) *AccountQuery
Offset to start from.
func (*AccountQuery) Only ¶
func (aq *AccountQuery) Only(ctx context.Context) (*Account, error)
Only returns a single Account entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Account entity is found. Returns a *NotFoundError when no Account entities are found.
func (*AccountQuery) OnlyID ¶
func (aq *AccountQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID is like Only, but returns the only Account ID in the query. Returns a *NotSingularError when more than one Account ID is found. Returns a *NotFoundError when no entities are found.
func (*AccountQuery) OnlyIDX ¶
func (aq *AccountQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*AccountQuery) OnlyX ¶
func (aq *AccountQuery) OnlyX(ctx context.Context) *Account
OnlyX is like Only, but panics if an error occurs.
func (*AccountQuery) Order ¶
func (aq *AccountQuery) Order(o ...account.OrderOption) *AccountQuery
Order specifies how the records should be ordered.
func (*AccountQuery) Select ¶
func (aq *AccountQuery) Select(fields ...string) *AccountSelect
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.Account.Query().
Select(account.FieldName).
Scan(ctx, &v)
func (*AccountQuery) Unique ¶
func (aq *AccountQuery) Unique(unique bool) *AccountQuery
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 (*AccountQuery) Where ¶
func (aq *AccountQuery) Where(ps ...predicate.Account) *AccountQuery
Where adds a new predicate for the AccountQuery builder.
type AccountResponse ¶
type AccountResponse struct {
// ID field is always included in responses
ID int `json:"id"`
Name string `json:"name"`
}
AccountResponse represents the response for Account.
It is emitted unconditionally: an entity whose every scalar field is Sensitive still has a meaningful response carrying its ID, and AccountListResponse below refers to this type either way.
func GetAccount ¶
GetAccount reads one Account and converts it to its response.
func NewAccountResponse ¶
func NewAccountResponse(e *Account) (*AccountResponse, error)
NewAccountResponse converts an entity to its response DTO.
This entity declares no response edges, so the error is always nil. The signature is kept uniform so callers do not need two shapes.
func PatchAccount ¶
func PatchAccount(ctx context.Context, db *Client, id int, v *ValidAccountPatchRequest) (*AccountResponse, error)
PatchAccount applies a validated patch to one Account.
Fields the patch did not carry are not written at all, so a partial update stays partial — that property belongs to Apply, and this function does not re-decide it.
type AccountSelect ¶
type AccountSelect struct {
*AccountQuery
// contains filtered or unexported fields
}
AccountSelect is the builder for selecting fields of Account entities.
func (*AccountSelect) Aggregate ¶
func (as *AccountSelect) Aggregate(fns ...AggregateFunc) *AccountSelect
Aggregate adds the given aggregation functions to the selector query.
func (*AccountSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*AccountSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*AccountSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*AccountSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*AccountSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*AccountSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*AccountSelect) Scan ¶
func (as *AccountSelect) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*AccountSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type AccountSummary ¶
type AccountSummary struct {
// ID field is always included in summaries
ID int `json:"id"`
Name string `json:"name"`
}
AccountSummary is the shape Account takes on another entity's response.
It carries the same scalar fields as AccountResponse and no edges at all. That is what bounds expansion: NewAccountResponse calls summary constructors, and a summary constructor calls nothing, so there is no second level for a cycle to close through and no runtime depth counter is needed.
The cost is real rather than hidden: a three-level tree comes back one level deep, and a deeper one needs another round trip per level.
func NewAccountSummary ¶
func NewAccountSummary(e *Account) *AccountSummary
NewAccountSummary converts an entity to its summary DTO. It cannot fail: a summary reads no edges.
type AccountUpdate ¶
type AccountUpdate struct {
// contains filtered or unexported fields
}
AccountUpdate is the builder for updating Account entities.
func (*AccountUpdate) Exec ¶
func (au *AccountUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*AccountUpdate) ExecX ¶
func (au *AccountUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*AccountUpdate) Mutation ¶
func (au *AccountUpdate) Mutation() *AccountMutation
Mutation returns the AccountMutation object of the builder.
func (*AccountUpdate) Save ¶
func (au *AccountUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*AccountUpdate) SaveX ¶
func (au *AccountUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*AccountUpdate) SetName ¶
func (au *AccountUpdate) SetName(s string) *AccountUpdate
SetName sets the "name" field.
func (*AccountUpdate) SetNillableName ¶
func (au *AccountUpdate) SetNillableName(s *string) *AccountUpdate
SetNillableName sets the "name" field if the given value is not nil.
func (*AccountUpdate) SetNillableSecret ¶
func (au *AccountUpdate) SetNillableSecret(s *string) *AccountUpdate
SetNillableSecret sets the "secret" field if the given value is not nil.
func (*AccountUpdate) SetSecret ¶
func (au *AccountUpdate) SetSecret(s string) *AccountUpdate
SetSecret sets the "secret" field.
func (*AccountUpdate) Where ¶
func (au *AccountUpdate) Where(ps ...predicate.Account) *AccountUpdate
Where appends a list predicates to the AccountUpdate builder.
type AccountUpdateOne ¶
type AccountUpdateOne struct {
// contains filtered or unexported fields
}
AccountUpdateOne is the builder for updating a single Account entity.
func (*AccountUpdateOne) Exec ¶
func (auo *AccountUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*AccountUpdateOne) ExecX ¶
func (auo *AccountUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*AccountUpdateOne) Mutation ¶
func (auo *AccountUpdateOne) Mutation() *AccountMutation
Mutation returns the AccountMutation object of the builder.
func (*AccountUpdateOne) Save ¶
func (auo *AccountUpdateOne) Save(ctx context.Context) (*Account, error)
Save executes the query and returns the updated Account entity.
func (*AccountUpdateOne) SaveX ¶
func (auo *AccountUpdateOne) SaveX(ctx context.Context) *Account
SaveX is like Save, but panics if an error occurs.
func (*AccountUpdateOne) Select ¶
func (auo *AccountUpdateOne) Select(field string, fields ...string) *AccountUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*AccountUpdateOne) SetName ¶
func (auo *AccountUpdateOne) SetName(s string) *AccountUpdateOne
SetName sets the "name" field.
func (*AccountUpdateOne) SetNillableName ¶
func (auo *AccountUpdateOne) SetNillableName(s *string) *AccountUpdateOne
SetNillableName sets the "name" field if the given value is not nil.
func (*AccountUpdateOne) SetNillableSecret ¶
func (auo *AccountUpdateOne) SetNillableSecret(s *string) *AccountUpdateOne
SetNillableSecret sets the "secret" field if the given value is not nil.
func (*AccountUpdateOne) SetSecret ¶
func (auo *AccountUpdateOne) SetSecret(s string) *AccountUpdateOne
SetSecret sets the "secret" field.
func (*AccountUpdateOne) Where ¶
func (auo *AccountUpdateOne) Where(ps ...predicate.Account) *AccountUpdateOne
Where appends a list predicates to the AccountUpdate builder.
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(createexceptedent.As(createexceptedent.Sum(field1), "sum_field1"), (createexceptedent.As(createexceptedent.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
// Account is the client for interacting with the Account builders.
Account *AccountClient
// 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(). Account. 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 DeleteAccountFn ¶
DeleteAccountFn is byte-identical to DeleteAccount.
type GetAccountFn ¶
GetAccountFn is byte-identical to GetAccount.
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 ListAccountsFn ¶
type ListAccountsFn func(context.Context, *Client, *AccountFilter, entapi.ListRequest) (*entapi.Page[AccountResponse], error)
ListAccountsFn is byte-identical to ListAccounts.
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 PatchAccountFn ¶
type PatchAccountFn func(context.Context, *Client, int, *ValidAccountPatchRequest) (*AccountResponse, error)
PatchAccountFn is byte-identical to PatchAccount.
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 TraverseFunc ¶
type TraverseFunc = ent.TraverseFunc
ent aliases to avoid import conflicts in user's code.
type Tx ¶
type Tx struct {
// Account is the client for interacting with the Account builders.
Account *AccountClient
// 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 ValidAccountPatchRequest ¶
type ValidAccountPatchRequest struct {
// contains filtered or unexported fields
}
ValidAccountPatchRequest wraps a AccountPatchRequest that has passed Validate. It is the only type Apply is defined on.
func (*ValidAccountPatchRequest) Apply ¶
func (v *ValidAccountPatchRequest) Apply(b *AccountUpdateOne) *AccountUpdateOne
Apply writes the request onto an update builder. Absent fields are not touched; the rest are set, or cleared when the caller sent an explicit null.
func (*ValidAccountPatchRequest) HasName ¶
func (v *ValidAccountPatchRequest) HasName() bool
HasName reports whether the payload carried "name".
A custom implementation receives only the validated type, so without this forwarder the patch's presence — the one thing that distinguishes "clear it" from "leave it alone" — is unreachable from the customization point that is supposed to act on it.
func (*ValidAccountPatchRequest) Name ¶
func (v *ValidAccountPatchRequest) Name() (string, bool)
Name reports the value the payload carried for "name", and whether Apply will Set it.
Presence is two of the three states a PATCH field has; this reads the third. Paired with HasName(), which is "present" below:
ok the payload carried a value; Apply will Set it
!ok, present the payload carried an explicit null; Apply will
Clear it. Reachable only for a clearable field —
Validate refuses a null on anything else
!ok, absent the key was not in the payload; Apply writes nothing
Without it a cross-field rule cannot tell "clear this" from "set this", and the customization point is forced to allocate an update builder it never executes, Apply the request to it and read back Mutation() (#113).
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.