Documentation
¶
Index ¶
- Constants
- Variables
- func AccountCreateRequestTags() []string
- 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 uuid.UUID) error
- func DeleteBatchAccounts(ctx context.Context, db *Client, ids []uuid.UUID) (int, error)
- func DeleteBatchSessions(ctx context.Context, db *Client, ids []uuid.UUID) (int, error)
- func DeleteSession(ctx context.Context, db *Client, id uuid.UUID) 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 ListSessions(ctx context.Context, db *Client, f *SessionFilter, r entapi.ListRequest) (*entapi.Page[SessionResponse], error)
- func MaskNotFound(err error) error
- func NewContext(parent context.Context, c *Client) context.Context
- func NewTxContext(parent context.Context, tx *Tx) context.Context
- func SessionCreateRequestTags() []string
- func SessionOrder(r entapi.ListRequest) ([]session.OrderOption, error)
- func SessionPatchRequestTags() []string
- type APIHandler
- func (h *APIHandler) CreateAccountEndpoint() entapi.Endpoint
- func (h *APIHandler) CreateSessionEndpoint() entapi.Endpoint
- func (h *APIHandler) DeleteAccountEndpoint() entapi.Endpoint
- func (h *APIHandler) DeleteSessionEndpoint() entapi.Endpoint
- func (h *APIHandler) Endpoints() []entapi.Endpoint
- func (h *APIHandler) GetAccountEndpoint() entapi.Endpoint
- func (h *APIHandler) GetSessionEndpoint() entapi.Endpoint
- func (h *APIHandler) ListAccountsEndpoint() entapi.Endpoint
- func (h *APIHandler) ListSessionsEndpoint() entapi.Endpoint
- func (h *APIHandler) Mount(mux *http.ServeMux)
- func (h *APIHandler) OpenAPIEndpoint() entapi.Endpoint
- func (h *APIHandler) PatchAccountEndpoint() entapi.Endpoint
- func (h *APIHandler) PatchSessionEndpoint() 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 uuid.UUID) *AccountDeleteOne
- func (c *AccountClient) Get(ctx context.Context, id uuid.UUID) (*Account, error)
- func (c *AccountClient) GetX(ctx context.Context, id uuid.UUID) *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 uuid.UUID) *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) SetID(u uuid.UUID) *AccountCreate
- func (ac *AccountCreate) SetLoginWindow(t []time.Time) *AccountCreate
- func (ac *AccountCreate) SetName(s string) *AccountCreate
- func (ac *AccountCreate) SetNillableID(u *uuid.UUID) *AccountCreate
- func (ac *AccountCreate) SetPasswordHash(s string) *AccountCreate
- type AccountCreateBulk
- type AccountCreateRequest
- 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) AppendLoginWindow(t []time.Time)
- func (m *AccountMutation) AppendedLoginWindow() ([]time.Time, bool)
- 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 uuid.UUID, exists bool)
- func (m *AccountMutation) IDs(ctx context.Context) ([]uuid.UUID, error)
- func (m *AccountMutation) LoginWindow() (r []time.Time, exists bool)
- func (m *AccountMutation) Name() (r string, exists bool)
- func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *AccountMutation) OldLoginWindow(ctx context.Context) (v []time.Time, err error)
- func (m *AccountMutation) OldName(ctx context.Context) (v string, err error)
- func (m *AccountMutation) OldPasswordHash(ctx context.Context) (v string, err error)
- func (m *AccountMutation) Op() Op
- func (m *AccountMutation) PasswordHash() (r string, exists bool)
- 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) ResetLoginWindow()
- func (m *AccountMutation) ResetName()
- func (m *AccountMutation) ResetPasswordHash()
- func (m *AccountMutation) SetField(name string, value ent.Value) error
- func (m *AccountMutation) SetID(id uuid.UUID)
- func (m *AccountMutation) SetLoginWindow(t []time.Time)
- func (m *AccountMutation) SetName(s string)
- func (m *AccountMutation) SetOp(op Op)
- func (m *AccountMutation) SetPasswordHash(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 uuid.UUID, err error)
- func (aq *AccountQuery) FirstIDX(ctx context.Context) uuid.UUID
- 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 []uuid.UUID, err error)
- func (aq *AccountQuery) IDsX(ctx context.Context) []uuid.UUID
- 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 uuid.UUID, err error)
- func (aq *AccountQuery) OnlyIDX(ctx context.Context) uuid.UUID
- 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
- func CreateAccount(ctx context.Context, db *Client, v *ValidAccountCreateRequest) (*AccountResponse, error)
- func GetAccount(ctx context.Context, db *Client, id uuid.UUID) (*AccountResponse, error)
- func NewAccountResponse(e *Account) (*AccountResponse, error)
- func PatchAccount(ctx context.Context, db *Client, id uuid.UUID, v *ValidAccountPatchRequest) (*AccountResponse, error)
- 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) AppendLoginWindow(t []time.Time) *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) SetLoginWindow(t []time.Time) *AccountUpdate
- func (au *AccountUpdate) SetName(s string) *AccountUpdate
- func (au *AccountUpdate) SetNillableName(s *string) *AccountUpdate
- func (au *AccountUpdate) SetNillablePasswordHash(s *string) *AccountUpdate
- func (au *AccountUpdate) SetPasswordHash(s string) *AccountUpdate
- func (au *AccountUpdate) Where(ps ...predicate.Account) *AccountUpdate
- type AccountUpdateOne
- func (auo *AccountUpdateOne) AppendLoginWindow(t []time.Time) *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) SetLoginWindow(t []time.Time) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetName(s string) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetNillableName(s *string) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetNillablePasswordHash(s *string) *AccountUpdateOne
- func (auo *AccountUpdateOne) SetPasswordHash(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 CreateAccountFn
- type CreateSessionFn
- type DeleteAccountFn
- type DeleteSessionFn
- type GetAccountFn
- type GetSessionFn
- type Hook
- type InterceptFunc
- type Interceptor
- type ListAccountsFn
- type ListSessionsFn
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- type PatchAccountFn
- type PatchSessionFn
- type Policy
- type Querier
- type QuerierFunc
- type Query
- type QueryContext
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- type Session
- type SessionClient
- func (c *SessionClient) Create() *SessionCreate
- func (c *SessionClient) CreateBulk(builders ...*SessionCreate) *SessionCreateBulk
- func (c *SessionClient) Delete() *SessionDelete
- func (c *SessionClient) DeleteOne(s *Session) *SessionDeleteOne
- func (c *SessionClient) DeleteOneID(id uuid.UUID) *SessionDeleteOne
- func (c *SessionClient) Get(ctx context.Context, id uuid.UUID) (*Session, error)
- func (c *SessionClient) GetX(ctx context.Context, id uuid.UUID) *Session
- func (c *SessionClient) Hooks() []Hook
- func (c *SessionClient) Intercept(interceptors ...Interceptor)
- func (c *SessionClient) Interceptors() []Interceptor
- func (c *SessionClient) MapCreateBulk(slice any, setFunc func(*SessionCreate, int)) *SessionCreateBulk
- func (c *SessionClient) Query() *SessionQuery
- func (c *SessionClient) QueryAccount(s *Session) *AccountQuery
- func (c *SessionClient) Update() *SessionUpdate
- func (c *SessionClient) UpdateOne(s *Session) *SessionUpdateOne
- func (c *SessionClient) UpdateOneID(id uuid.UUID) *SessionUpdateOne
- func (c *SessionClient) Use(hooks ...Hook)
- type SessionCreate
- func (sc *SessionCreate) Exec(ctx context.Context) error
- func (sc *SessionCreate) ExecX(ctx context.Context)
- func (sc *SessionCreate) Mutation() *SessionMutation
- func (sc *SessionCreate) Save(ctx context.Context) (*Session, error)
- func (sc *SessionCreate) SaveX(ctx context.Context) *Session
- func (sc *SessionCreate) SetAccount(a *Account) *SessionCreate
- func (sc *SessionCreate) SetAccountID(id uuid.UUID) *SessionCreate
- func (sc *SessionCreate) SetID(u uuid.UUID) *SessionCreate
- func (sc *SessionCreate) SetNillableAccountID(id *uuid.UUID) *SessionCreate
- func (sc *SessionCreate) SetNillableID(u *uuid.UUID) *SessionCreate
- func (sc *SessionCreate) SetUserAgent(s string) *SessionCreate
- type SessionCreateBulk
- type SessionCreateRequest
- type SessionDelete
- type SessionDeleteOne
- type SessionEdges
- type SessionFilter
- type SessionGroupBy
- func (sgb *SessionGroupBy) Aggregate(fns ...AggregateFunc) *SessionGroupBy
- func (s *SessionGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *SessionGroupBy) BoolX(ctx context.Context) bool
- func (s *SessionGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *SessionGroupBy) BoolsX(ctx context.Context) []bool
- func (s *SessionGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *SessionGroupBy) Float64X(ctx context.Context) float64
- func (s *SessionGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *SessionGroupBy) Float64sX(ctx context.Context) []float64
- func (s *SessionGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *SessionGroupBy) IntX(ctx context.Context) int
- func (s *SessionGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *SessionGroupBy) IntsX(ctx context.Context) []int
- func (sgb *SessionGroupBy) Scan(ctx context.Context, v any) error
- func (s *SessionGroupBy) ScanX(ctx context.Context, v any)
- func (s *SessionGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *SessionGroupBy) StringX(ctx context.Context) string
- func (s *SessionGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *SessionGroupBy) StringsX(ctx context.Context) []string
- type SessionListResponse
- type SessionMutation
- func (m *SessionMutation) AccountCleared() bool
- func (m *SessionMutation) AccountID() (id uuid.UUID, exists bool)
- func (m *SessionMutation) AccountIDs() (ids []uuid.UUID)
- func (m *SessionMutation) AddField(name string, value ent.Value) error
- func (m *SessionMutation) AddedEdges() []string
- func (m *SessionMutation) AddedField(name string) (ent.Value, bool)
- func (m *SessionMutation) AddedFields() []string
- func (m *SessionMutation) AddedIDs(name string) []ent.Value
- func (m *SessionMutation) ClearAccount()
- func (m *SessionMutation) ClearEdge(name string) error
- func (m *SessionMutation) ClearField(name string) error
- func (m *SessionMutation) ClearedEdges() []string
- func (m *SessionMutation) ClearedFields() []string
- func (m SessionMutation) Client() *Client
- func (m *SessionMutation) EdgeCleared(name string) bool
- func (m *SessionMutation) Field(name string) (ent.Value, bool)
- func (m *SessionMutation) FieldCleared(name string) bool
- func (m *SessionMutation) Fields() []string
- func (m *SessionMutation) ID() (id uuid.UUID, exists bool)
- func (m *SessionMutation) IDs(ctx context.Context) ([]uuid.UUID, error)
- func (m *SessionMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *SessionMutation) OldUserAgent(ctx context.Context) (v string, err error)
- func (m *SessionMutation) Op() Op
- func (m *SessionMutation) RemovedEdges() []string
- func (m *SessionMutation) RemovedIDs(name string) []ent.Value
- func (m *SessionMutation) ResetAccount()
- func (m *SessionMutation) ResetEdge(name string) error
- func (m *SessionMutation) ResetField(name string) error
- func (m *SessionMutation) ResetUserAgent()
- func (m *SessionMutation) SetAccountID(id uuid.UUID)
- func (m *SessionMutation) SetField(name string, value ent.Value) error
- func (m *SessionMutation) SetID(id uuid.UUID)
- func (m *SessionMutation) SetOp(op Op)
- func (m *SessionMutation) SetUserAgent(s string)
- func (m SessionMutation) Tx() (*Tx, error)
- func (m *SessionMutation) Type() string
- func (m *SessionMutation) UserAgent() (r string, exists bool)
- func (m *SessionMutation) Where(ps ...predicate.Session)
- func (m *SessionMutation) WhereP(ps ...func(*sql.Selector))
- type SessionPatchRequest
- type SessionQuery
- func (sq *SessionQuery) Aggregate(fns ...AggregateFunc) *SessionSelect
- func (sq *SessionQuery) All(ctx context.Context) ([]*Session, error)
- func (sq *SessionQuery) AllX(ctx context.Context) []*Session
- func (sq *SessionQuery) Clone() *SessionQuery
- func (sq *SessionQuery) Count(ctx context.Context) (int, error)
- func (sq *SessionQuery) CountX(ctx context.Context) int
- func (sq *SessionQuery) Exist(ctx context.Context) (bool, error)
- func (sq *SessionQuery) ExistX(ctx context.Context) bool
- func (sq *SessionQuery) First(ctx context.Context) (*Session, error)
- func (sq *SessionQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)
- func (sq *SessionQuery) FirstIDX(ctx context.Context) uuid.UUID
- func (sq *SessionQuery) FirstX(ctx context.Context) *Session
- func (sq *SessionQuery) GroupBy(field string, fields ...string) *SessionGroupBy
- func (sq *SessionQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error)
- func (sq *SessionQuery) IDsX(ctx context.Context) []uuid.UUID
- func (sq *SessionQuery) Limit(limit int) *SessionQuery
- func (sq *SessionQuery) Offset(offset int) *SessionQuery
- func (sq *SessionQuery) Only(ctx context.Context) (*Session, error)
- func (sq *SessionQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)
- func (sq *SessionQuery) OnlyIDX(ctx context.Context) uuid.UUID
- func (sq *SessionQuery) OnlyX(ctx context.Context) *Session
- func (sq *SessionQuery) Order(o ...session.OrderOption) *SessionQuery
- func (sq *SessionQuery) QueryAccount() *AccountQuery
- func (sq *SessionQuery) Select(fields ...string) *SessionSelect
- func (sq *SessionQuery) Unique(unique bool) *SessionQuery
- func (sq *SessionQuery) Where(ps ...predicate.Session) *SessionQuery
- func (sq *SessionQuery) WithAccount(opts ...func(*AccountQuery)) *SessionQuery
- type SessionResponse
- func CreateSession(ctx context.Context, db *Client, v *ValidSessionCreateRequest) (*SessionResponse, error)
- func GetSession(ctx context.Context, db *Client, id uuid.UUID) (*SessionResponse, error)
- func NewSessionResponse(e *Session) (*SessionResponse, error)
- func PatchSession(ctx context.Context, db *Client, id uuid.UUID, v *ValidSessionPatchRequest) (*SessionResponse, error)
- type SessionSelect
- func (ss *SessionSelect) Aggregate(fns ...AggregateFunc) *SessionSelect
- func (s *SessionSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *SessionSelect) BoolX(ctx context.Context) bool
- func (s *SessionSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *SessionSelect) BoolsX(ctx context.Context) []bool
- func (s *SessionSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *SessionSelect) Float64X(ctx context.Context) float64
- func (s *SessionSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *SessionSelect) Float64sX(ctx context.Context) []float64
- func (s *SessionSelect) Int(ctx context.Context) (_ int, err error)
- func (s *SessionSelect) IntX(ctx context.Context) int
- func (s *SessionSelect) Ints(ctx context.Context) ([]int, error)
- func (s *SessionSelect) IntsX(ctx context.Context) []int
- func (ss *SessionSelect) Scan(ctx context.Context, v any) error
- func (s *SessionSelect) ScanX(ctx context.Context, v any)
- func (s *SessionSelect) String(ctx context.Context) (_ string, err error)
- func (s *SessionSelect) StringX(ctx context.Context) string
- func (s *SessionSelect) Strings(ctx context.Context) ([]string, error)
- func (s *SessionSelect) StringsX(ctx context.Context) []string
- type SessionSummary
- type SessionUpdate
- func (su *SessionUpdate) ClearAccount() *SessionUpdate
- func (su *SessionUpdate) Exec(ctx context.Context) error
- func (su *SessionUpdate) ExecX(ctx context.Context)
- func (su *SessionUpdate) Mutation() *SessionMutation
- func (su *SessionUpdate) Save(ctx context.Context) (int, error)
- func (su *SessionUpdate) SaveX(ctx context.Context) int
- func (su *SessionUpdate) SetAccount(a *Account) *SessionUpdate
- func (su *SessionUpdate) SetAccountID(id uuid.UUID) *SessionUpdate
- func (su *SessionUpdate) SetNillableAccountID(id *uuid.UUID) *SessionUpdate
- func (su *SessionUpdate) SetNillableUserAgent(s *string) *SessionUpdate
- func (su *SessionUpdate) SetUserAgent(s string) *SessionUpdate
- func (su *SessionUpdate) Where(ps ...predicate.Session) *SessionUpdate
- type SessionUpdateOne
- func (suo *SessionUpdateOne) ClearAccount() *SessionUpdateOne
- func (suo *SessionUpdateOne) Exec(ctx context.Context) error
- func (suo *SessionUpdateOne) ExecX(ctx context.Context)
- func (suo *SessionUpdateOne) Mutation() *SessionMutation
- func (suo *SessionUpdateOne) Save(ctx context.Context) (*Session, error)
- func (suo *SessionUpdateOne) SaveX(ctx context.Context) *Session
- func (suo *SessionUpdateOne) Select(field string, fields ...string) *SessionUpdateOne
- func (suo *SessionUpdateOne) SetAccount(a *Account) *SessionUpdateOne
- func (suo *SessionUpdateOne) SetAccountID(id uuid.UUID) *SessionUpdateOne
- func (suo *SessionUpdateOne) SetNillableAccountID(id *uuid.UUID) *SessionUpdateOne
- func (suo *SessionUpdateOne) SetNillableUserAgent(s *string) *SessionUpdateOne
- func (suo *SessionUpdateOne) SetUserAgent(s string) *SessionUpdateOne
- func (suo *SessionUpdateOne) Where(ps ...predicate.Session) *SessionUpdateOne
- type Sessions
- type TraverseFunc
- type Traverser
- type Tx
- type ValidAccountCreateRequest
- type ValidAccountPatchRequest
- func (v *ValidAccountPatchRequest) Apply(b *AccountUpdateOne) *AccountUpdateOne
- func (v *ValidAccountPatchRequest) HasLoginWindow() bool
- func (v *ValidAccountPatchRequest) HasName() bool
- func (v *ValidAccountPatchRequest) HasPasswordHash() bool
- func (v *ValidAccountPatchRequest) LoginWindow() ([]time.Time, bool)
- func (v *ValidAccountPatchRequest) Name() (string, bool)
- func (v *ValidAccountPatchRequest) PasswordHash() (string, bool)
- type ValidSessionCreateRequest
- type ValidSessionPatchRequest
- 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" TypeSession = "Session" )
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("sensitiveent: 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.
var SessionSortKeys = []string{
"id",
}
SessionSortKeys is the complete sort allow-list. The primary key is naturally Sortable; every other key requires api.Sortable().
Functions ¶
func AccountCreateRequestTags ¶
func AccountCreateRequestTags() []string
AccountCreateRequestTags returns the canonical JSON key of every field on AccountCreateRequest, 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 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 DeleteBatchSessions ¶
DeleteBatchSessions removes several Sessions 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 DeleteSession ¶
DeleteSession removes one Session.
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 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 ListSessions ¶
func ListSessions(ctx context.Context, db *Client, f *SessionFilter, r entapi.ListRequest) (*entapi.Page[SessionResponse], error)
ListSessions 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: SessionOrder can fail, because a sort key outside SessionSortKeys 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.
func NewTxContext ¶
NewTxContext returns a new context with the given Tx attached.
func SessionCreateRequestTags ¶
func SessionCreateRequestTags() []string
SessionCreateRequestTags returns the canonical JSON key of every field on SessionCreateRequest, 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 SessionOrder ¶
func SessionOrder(r entapi.ListRequest) ([]session.OrderOption, error)
SessionOrder is the single sort allow-list seam.
func SessionPatchRequestTags ¶
func SessionPatchRequestTags() []string
SessionPatchRequestTags returns the canonical JSON key of every field on SessionPatchRequest, 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.
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) CreateAccountEndpoint ¶
func (h *APIHandler) CreateAccountEndpoint() entapi.Endpoint
CreateAccountEndpoint returns the generated POST /accounts endpoint.
func (*APIHandler) CreateSessionEndpoint ¶
func (h *APIHandler) CreateSessionEndpoint() entapi.Endpoint
CreateSessionEndpoint returns the generated POST /sessions endpoint.
func (*APIHandler) DeleteAccountEndpoint ¶
func (h *APIHandler) DeleteAccountEndpoint() entapi.Endpoint
DeleteAccountEndpoint returns the generated DELETE /accounts/{id} endpoint.
func (*APIHandler) DeleteSessionEndpoint ¶
func (h *APIHandler) DeleteSessionEndpoint() entapi.Endpoint
DeleteSessionEndpoint returns the generated DELETE /sessions/{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) GetSessionEndpoint ¶
func (h *APIHandler) GetSessionEndpoint() entapi.Endpoint
GetSessionEndpoint returns the generated GET /sessions/{id} endpoint.
func (*APIHandler) ListAccountsEndpoint ¶
func (h *APIHandler) ListAccountsEndpoint() entapi.Endpoint
ListAccountsEndpoint returns the generated GET /accounts endpoint.
func (*APIHandler) ListSessionsEndpoint ¶
func (h *APIHandler) ListSessionsEndpoint() entapi.Endpoint
ListSessionsEndpoint returns the generated GET /sessions 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) PatchSessionEndpoint ¶
func (h *APIHandler) PatchSessionEndpoint() entapi.Endpoint
PatchSessionEndpoint returns the generated PATCH /sessions/{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 uuid.UUID `json:"id,omitempty"`
// PasswordHash holds the value of the "password_hash" field.
PasswordHash string `json:"-"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// LoginWindow holds the value of the "login_window" field.
LoginWindow []time.Time `json:"-"`
// 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 uuid.UUID) *AccountDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
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 uuid.UUID) *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) SetID ¶
func (ac *AccountCreate) SetID(u uuid.UUID) *AccountCreate
SetID sets the "id" field.
func (*AccountCreate) SetLoginWindow ¶
func (ac *AccountCreate) SetLoginWindow(t []time.Time) *AccountCreate
SetLoginWindow sets the "login_window" field.
func (*AccountCreate) SetName ¶
func (ac *AccountCreate) SetName(s string) *AccountCreate
SetName sets the "name" field.
func (*AccountCreate) SetNillableID ¶
func (ac *AccountCreate) SetNillableID(u *uuid.UUID) *AccountCreate
SetNillableID sets the "id" field if the given value is not nil.
func (*AccountCreate) SetPasswordHash ¶
func (ac *AccountCreate) SetPasswordHash(s string) *AccountCreate
SetPasswordHash sets the "password_hash" 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 AccountCreateRequest ¶
type AccountCreateRequest struct {
PasswordHash string `json:"password_hash"`
Name string `json:"name"`
LoginWindow []time.Time `json:"login_window"`
// contains filtered or unexported fields
}
AccountCreateRequest is the create request for Account.
Field shape follows ent's schema rather than a parallel set of booleans. A field ent can fill by itself — Optional, or carrying a Default() — is a pointer here and is written to the builder only when the caller supplied a value, so an omitted key leaves the schema's default in effect. A field ent requires and cannot default is a value type and is always written.
func (*AccountCreateRequest) HasLoginWindow ¶
func (r *AccountCreateRequest) HasLoginWindow() bool
HasLoginWindow reports whether the payload carried "login_window".
func (*AccountCreateRequest) HasName ¶
func (r *AccountCreateRequest) HasName() bool
HasName reports whether the payload carried "name".
func (*AccountCreateRequest) HasPasswordHash ¶
func (r *AccountCreateRequest) HasPasswordHash() bool
HasPasswordHash reports whether the payload carried "password_hash".
func (*AccountCreateRequest) UnmarshalJSON ¶
func (r *AccountCreateRequest) UnmarshalJSON(b []byte) error
UnmarshalJSON records presence, then decodes normally.
The wire format is unchanged: every exported field keeps its ordinary type and tag, so marshalling, form binders, validators and spec generators all see the struct they saw before. That is the property a generic Optional[T] wrapper could not keep.
A key that case-folds to a canonical tag without matching it exactly is rejected (#58, ADR-0001): encoding/json would fill the field from it while presence — recorded by raw key — would not, so the value decoded and then went unwritten. The check runs after raw decodes and BEFORE the alias decode, so a rejected request leaves the receiver untouched. A key that folds to no tag keeps its old behaviour and is ignored; refusing those is DisallowUnknownFields, which stays the consumer handler's decision.
func (*AccountCreateRequest) Validate ¶
func (r *AccountCreateRequest) Validate() (*ValidAccountCreateRequest, error)
Validate checks the request and returns the only type Apply accepts.
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: uuid.UUID
ID []uuid.UUID `json:"id,omitempty"`
IDNEQ []uuid.UUID `json:"id_neq,omitempty"`
IDIn [][]uuid.UUID `json:"id_in,omitempty"`
IDNotIn [][]uuid.UUID `json:"id_not_in,omitempty"`
IDGT []uuid.UUID `json:"id_gt,omitempty"`
IDGTE []uuid.UUID `json:"id_gte,omitempty"`
IDLT []uuid.UUID `json:"id_lt,omitempty"`
IDLTE []uuid.UUID `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) AppendLoginWindow ¶
func (m *AccountMutation) AppendLoginWindow(t []time.Time)
AppendLoginWindow adds t to the "login_window" field.
func (*AccountMutation) AppendedLoginWindow ¶
func (m *AccountMutation) AppendedLoginWindow() ([]time.Time, bool)
AppendedLoginWindow returns the list of values that were appended to the "login_window" field 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 uuid.UUID, 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 ¶
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) LoginWindow ¶
func (m *AccountMutation) LoginWindow() (r []time.Time, exists bool)
LoginWindow returns the value of the "login_window" field in 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) OldLoginWindow ¶
OldLoginWindow returns the old "login_window" 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) 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) OldPasswordHash ¶
func (m *AccountMutation) OldPasswordHash(ctx context.Context) (v string, err error)
OldPasswordHash returns the old "password_hash" 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) PasswordHash ¶
func (m *AccountMutation) PasswordHash() (r string, exists bool)
PasswordHash returns the value of the "password_hash" field in the mutation.
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) ResetLoginWindow ¶
func (m *AccountMutation) ResetLoginWindow()
ResetLoginWindow resets all changes to the "login_window" field.
func (*AccountMutation) ResetName ¶
func (m *AccountMutation) ResetName()
ResetName resets all changes to the "name" field.
func (*AccountMutation) ResetPasswordHash ¶
func (m *AccountMutation) ResetPasswordHash()
ResetPasswordHash resets all changes to the "password_hash" field.
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) SetID ¶
func (m *AccountMutation) SetID(id uuid.UUID)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Account entities.
func (*AccountMutation) SetLoginWindow ¶
func (m *AccountMutation) SetLoginWindow(t []time.Time)
SetLoginWindow sets the "login_window" field.
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) SetPasswordHash ¶
func (m *AccountMutation) SetPasswordHash(s string)
SetPasswordHash sets the "password_hash" 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 {
PasswordHash *string `json:"password_hash,omitempty"`
Name *string `json:"name,omitempty"`
LoginWindow *[]time.Time `json:"login_window,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) HasLoginWindow ¶
func (r *AccountPatchRequest) HasLoginWindow() bool
HasLoginWindow reports whether the payload carried "login_window".
func (*AccountPatchRequest) HasName ¶
func (r *AccountPatchRequest) HasName() bool
HasName reports whether the payload carried "name".
func (*AccountPatchRequest) HasPasswordHash ¶
func (r *AccountPatchRequest) HasPasswordHash() bool
HasPasswordHash reports whether the payload carried "password_hash".
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 ¶
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) uuid.UUID
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 {
PasswordHash string `json:"password_hash,omitempty"`
Count int `json:"count,omitempty"`
}
client.Account.Query().
GroupBy(account.FieldPasswordHash).
Aggregate(sensitiveent.Count()).
Scan(ctx, &v)
func (*AccountQuery) IDsX ¶
func (aq *AccountQuery) IDsX(ctx context.Context) []uuid.UUID
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 ¶
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) uuid.UUID
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 {
PasswordHash string `json:"password_hash,omitempty"`
}
client.Account.Query().
Select(account.FieldPasswordHash).
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 uuid.UUID `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 CreateAccount ¶
func CreateAccount(ctx context.Context, db *Client, v *ValidAccountCreateRequest) (*AccountResponse, error)
CreateAccount inserts one Account and returns its response.
It takes the VALIDATED request. Apply is defined on that type and nowhere else, so validation is a compile-time requirement here rather than a step this function could forget on the caller's behalf.
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 uuid.UUID, 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 uuid.UUID `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) AppendLoginWindow ¶
func (au *AccountUpdate) AppendLoginWindow(t []time.Time) *AccountUpdate
AppendLoginWindow appends t to the "login_window" field.
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) SetLoginWindow ¶
func (au *AccountUpdate) SetLoginWindow(t []time.Time) *AccountUpdate
SetLoginWindow sets the "login_window" field.
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) SetNillablePasswordHash ¶
func (au *AccountUpdate) SetNillablePasswordHash(s *string) *AccountUpdate
SetNillablePasswordHash sets the "password_hash" field if the given value is not nil.
func (*AccountUpdate) SetPasswordHash ¶
func (au *AccountUpdate) SetPasswordHash(s string) *AccountUpdate
SetPasswordHash sets the "password_hash" 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) AppendLoginWindow ¶
func (auo *AccountUpdateOne) AppendLoginWindow(t []time.Time) *AccountUpdateOne
AppendLoginWindow appends t to the "login_window" field.
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) SetLoginWindow ¶
func (auo *AccountUpdateOne) SetLoginWindow(t []time.Time) *AccountUpdateOne
SetLoginWindow sets the "login_window" field.
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) SetNillablePasswordHash ¶
func (auo *AccountUpdateOne) SetNillablePasswordHash(s *string) *AccountUpdateOne
SetNillablePasswordHash sets the "password_hash" field if the given value is not nil.
func (*AccountUpdateOne) SetPasswordHash ¶
func (auo *AccountUpdateOne) SetPasswordHash(s string) *AccountUpdateOne
SetPasswordHash sets the "password_hash" 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(sensitiveent.As(sensitiveent.Sum(field1), "sum_field1"), (sensitiveent.As(sensitiveent.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
// Session is the client for interacting with the Session builders.
Session *SessionClient
// 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 CreateAccountFn ¶
type CreateAccountFn func(context.Context, *Client, *ValidAccountCreateRequest) (*AccountResponse, error)
CreateAccountFn is byte-identical to CreateAccount.
type CreateSessionFn ¶
type CreateSessionFn func(context.Context, *Client, *ValidSessionCreateRequest) (*SessionResponse, error)
CreateSessionFn is byte-identical to CreateSession.
type DeleteAccountFn ¶
DeleteAccountFn is byte-identical to DeleteAccount.
type DeleteSessionFn ¶
DeleteSessionFn is byte-identical to DeleteSession.
type GetAccountFn ¶
GetAccountFn is byte-identical to GetAccount.
type GetSessionFn ¶
GetSessionFn is byte-identical to GetSession.
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 ListSessionsFn ¶
type ListSessionsFn func(context.Context, *Client, *SessionFilter, entapi.ListRequest) (*entapi.Page[SessionResponse], error)
ListSessionsFn is byte-identical to ListSessions.
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, uuid.UUID, *ValidAccountPatchRequest) (*AccountResponse, error)
PatchAccountFn is byte-identical to PatchAccount.
type PatchSessionFn ¶
type PatchSessionFn func(context.Context, *Client, uuid.UUID, *ValidSessionPatchRequest) (*SessionResponse, error)
PatchSessionFn is byte-identical to PatchSession.
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 Session ¶
type Session struct {
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
// UserAgent holds the value of the "user_agent" field.
UserAgent string `json:"user_agent,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the SessionQuery when eager-loading is set.
Edges SessionEdges `json:"edges"`
// contains filtered or unexported fields
}
Session is the model entity for the Session schema.
func (*Session) QueryAccount ¶
func (s *Session) QueryAccount() *AccountQuery
QueryAccount queries the "account" edge of the Session entity.
func (*Session) Unwrap ¶
Unwrap unwraps the Session 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 (*Session) Update ¶
func (s *Session) Update() *SessionUpdateOne
Update returns a builder for updating this Session. Note that you need to call Session.Unwrap() before calling this method if this Session was returned from a transaction, and the transaction was committed or rolled back.
type SessionClient ¶
type SessionClient struct {
// contains filtered or unexported fields
}
SessionClient is a client for the Session schema.
func NewSessionClient ¶
func NewSessionClient(c config) *SessionClient
NewSessionClient returns a client for the Session from the given config.
func (*SessionClient) Create ¶
func (c *SessionClient) Create() *SessionCreate
Create returns a builder for creating a Session entity.
func (*SessionClient) CreateBulk ¶
func (c *SessionClient) CreateBulk(builders ...*SessionCreate) *SessionCreateBulk
CreateBulk returns a builder for creating a bulk of Session entities.
func (*SessionClient) Delete ¶
func (c *SessionClient) Delete() *SessionDelete
Delete returns a delete builder for Session.
func (*SessionClient) DeleteOne ¶
func (c *SessionClient) DeleteOne(s *Session) *SessionDeleteOne
DeleteOne returns a builder for deleting the given entity.
func (*SessionClient) DeleteOneID ¶
func (c *SessionClient) DeleteOneID(id uuid.UUID) *SessionDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
func (*SessionClient) Hooks ¶
func (c *SessionClient) Hooks() []Hook
Hooks returns the client hooks.
func (*SessionClient) Intercept ¶
func (c *SessionClient) Intercept(interceptors ...Interceptor)
Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `session.Intercept(f(g(h())))`.
func (*SessionClient) Interceptors ¶
func (c *SessionClient) Interceptors() []Interceptor
Interceptors returns the client interceptors.
func (*SessionClient) MapCreateBulk ¶
func (c *SessionClient) MapCreateBulk(slice any, setFunc func(*SessionCreate, int)) *SessionCreateBulk
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 (*SessionClient) Query ¶
func (c *SessionClient) Query() *SessionQuery
Query returns a query builder for Session.
func (*SessionClient) QueryAccount ¶
func (c *SessionClient) QueryAccount(s *Session) *AccountQuery
QueryAccount queries the account edge of a Session.
func (*SessionClient) Update ¶
func (c *SessionClient) Update() *SessionUpdate
Update returns an update builder for Session.
func (*SessionClient) UpdateOne ¶
func (c *SessionClient) UpdateOne(s *Session) *SessionUpdateOne
UpdateOne returns an update builder for the given entity.
func (*SessionClient) UpdateOneID ¶
func (c *SessionClient) UpdateOneID(id uuid.UUID) *SessionUpdateOne
UpdateOneID returns an update builder for the given id.
func (*SessionClient) Use ¶
func (c *SessionClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `session.Hooks(f(g(h())))`.
type SessionCreate ¶
type SessionCreate struct {
// contains filtered or unexported fields
}
SessionCreate is the builder for creating a Session entity.
func (*SessionCreate) Exec ¶
func (sc *SessionCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*SessionCreate) ExecX ¶
func (sc *SessionCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*SessionCreate) Mutation ¶
func (sc *SessionCreate) Mutation() *SessionMutation
Mutation returns the SessionMutation object of the builder.
func (*SessionCreate) Save ¶
func (sc *SessionCreate) Save(ctx context.Context) (*Session, error)
Save creates the Session in the database.
func (*SessionCreate) SaveX ¶
func (sc *SessionCreate) SaveX(ctx context.Context) *Session
SaveX calls Save and panics if Save returns an error.
func (*SessionCreate) SetAccount ¶
func (sc *SessionCreate) SetAccount(a *Account) *SessionCreate
SetAccount sets the "account" edge to the Account entity.
func (*SessionCreate) SetAccountID ¶
func (sc *SessionCreate) SetAccountID(id uuid.UUID) *SessionCreate
SetAccountID sets the "account" edge to the Account entity by ID.
func (*SessionCreate) SetID ¶
func (sc *SessionCreate) SetID(u uuid.UUID) *SessionCreate
SetID sets the "id" field.
func (*SessionCreate) SetNillableAccountID ¶
func (sc *SessionCreate) SetNillableAccountID(id *uuid.UUID) *SessionCreate
SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
func (*SessionCreate) SetNillableID ¶
func (sc *SessionCreate) SetNillableID(u *uuid.UUID) *SessionCreate
SetNillableID sets the "id" field if the given value is not nil.
func (*SessionCreate) SetUserAgent ¶
func (sc *SessionCreate) SetUserAgent(s string) *SessionCreate
SetUserAgent sets the "user_agent" field.
type SessionCreateBulk ¶
type SessionCreateBulk struct {
// contains filtered or unexported fields
}
SessionCreateBulk is the builder for creating many Session entities in bulk.
func (*SessionCreateBulk) Exec ¶
func (scb *SessionCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*SessionCreateBulk) ExecX ¶
func (scb *SessionCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type SessionCreateRequest ¶
type SessionCreateRequest struct {
UserAgent string `json:"user_agent"`
// contains filtered or unexported fields
}
SessionCreateRequest is the create request for Session.
Field shape follows ent's schema rather than a parallel set of booleans. A field ent can fill by itself — Optional, or carrying a Default() — is a pointer here and is written to the builder only when the caller supplied a value, so an omitted key leaves the schema's default in effect. A field ent requires and cannot default is a value type and is always written.
func (*SessionCreateRequest) HasUserAgent ¶
func (r *SessionCreateRequest) HasUserAgent() bool
HasUserAgent reports whether the payload carried "user_agent".
func (*SessionCreateRequest) UnmarshalJSON ¶
func (r *SessionCreateRequest) UnmarshalJSON(b []byte) error
UnmarshalJSON records presence, then decodes normally.
The wire format is unchanged: every exported field keeps its ordinary type and tag, so marshalling, form binders, validators and spec generators all see the struct they saw before. That is the property a generic Optional[T] wrapper could not keep.
A key that case-folds to a canonical tag without matching it exactly is rejected (#58, ADR-0001): encoding/json would fill the field from it while presence — recorded by raw key — would not, so the value decoded and then went unwritten. The check runs after raw decodes and BEFORE the alias decode, so a rejected request leaves the receiver untouched. A key that folds to no tag keeps its old behaviour and is ignored; refusing those is DisallowUnknownFields, which stays the consumer handler's decision.
func (*SessionCreateRequest) Validate ¶
func (r *SessionCreateRequest) Validate() (*ValidSessionCreateRequest, error)
Validate checks the request and returns the only type Apply accepts.
type SessionDelete ¶
type SessionDelete struct {
// contains filtered or unexported fields
}
SessionDelete is the builder for deleting a Session entity.
func (*SessionDelete) Exec ¶
func (sd *SessionDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*SessionDelete) ExecX ¶
func (sd *SessionDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*SessionDelete) Where ¶
func (sd *SessionDelete) Where(ps ...predicate.Session) *SessionDelete
Where appends a list predicates to the SessionDelete builder.
type SessionDeleteOne ¶
type SessionDeleteOne struct {
// contains filtered or unexported fields
}
SessionDeleteOne is the builder for deleting a single Session entity.
func (*SessionDeleteOne) Exec ¶
func (sdo *SessionDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*SessionDeleteOne) ExecX ¶
func (sdo *SessionDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*SessionDeleteOne) Where ¶
func (sdo *SessionDeleteOne) Where(ps ...predicate.Session) *SessionDeleteOne
Where appends a list predicates to the SessionDelete builder.
type SessionEdges ¶
type SessionEdges struct {
// Account holds the value of the account edge.
Account *Account `json:"account,omitempty"`
// contains filtered or unexported fields
}
SessionEdges holds the relations/edges for other nodes in the graph.
func (SessionEdges) AccountOrErr ¶
func (e SessionEdges) AccountOrErr() (*Account, error)
AccountOrErr returns the Account value or an error if the edge was not loaded in eager-loading, or loaded but was not found.
type SessionFilter ¶
type SessionFilter struct {
// id: uuid.UUID
ID []uuid.UUID `json:"id,omitempty"`
IDNEQ []uuid.UUID `json:"id_neq,omitempty"`
IDIn [][]uuid.UUID `json:"id_in,omitempty"`
IDNotIn [][]uuid.UUID `json:"id_not_in,omitempty"`
IDGT []uuid.UUID `json:"id_gt,omitempty"`
IDGTE []uuid.UUID `json:"id_gte,omitempty"`
IDLT []uuid.UUID `json:"id_lt,omitempty"`
IDLTE []uuid.UUID `json:"id_lte,omitempty"`
}
SessionFilter is the typed query representation for Session. Repeated URL parameters occupy repeated slots and Predicates ANDs them.
func ParseSessionQuery ¶
func ParseSessionQuery(q url.Values) (*SessionFilter, entapi.ListRequest, error)
ParseSessionQuery 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 (*SessionFilter) Predicates ¶
func (f *SessionFilter) Predicates() []predicate.Session
Predicates converts the typed filter into conjunctive ent predicates.
type SessionGroupBy ¶
type SessionGroupBy struct {
// contains filtered or unexported fields
}
SessionGroupBy is the group-by builder for Session entities.
func (*SessionGroupBy) Aggregate ¶
func (sgb *SessionGroupBy) Aggregate(fns ...AggregateFunc) *SessionGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*SessionGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*SessionGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*SessionGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*SessionGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*SessionGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*SessionGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*SessionGroupBy) Scan ¶
func (sgb *SessionGroupBy) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*SessionGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type SessionListResponse ¶
type SessionListResponse struct {
Data []*SessionResponse `json:"data"`
Total int `json:"total"`
Page int `json:"page"`
Size int `json:"size"`
}
SessionListResponse is the NAMED, non-generic shape of one list page — for OpenAPI/swaggo-class annotation tooling, which cannot express the generic entapi.Page[SessionResponse] that ListSessions returns. Convert at the handler boundary with NewSessionListResponse. (A fifth field, PageInfo, carried cursor metadata until #6 removed it.)
func NewSessionListResponse ¶
func NewSessionListResponse(p *entapi.Page[SessionResponse]) *SessionListResponse
NewSessionListResponse converts the page ListSessions returns into the named list shape. The conversion expression is the shape contract: if SessionListResponse 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 SessionMutation ¶
type SessionMutation struct {
// contains filtered or unexported fields
}
SessionMutation represents an operation that mutates the Session nodes in the graph.
func (*SessionMutation) AccountCleared ¶
func (m *SessionMutation) AccountCleared() bool
AccountCleared reports if the "account" edge to the Account entity was cleared.
func (*SessionMutation) AccountID ¶
func (m *SessionMutation) AccountID() (id uuid.UUID, exists bool)
AccountID returns the "account" edge ID in the mutation.
func (*SessionMutation) AccountIDs ¶
func (m *SessionMutation) AccountIDs() (ids []uuid.UUID)
AccountIDs returns the "account" edge IDs in the mutation. Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use AccountID instead. It exists only for internal usage by the builders.
func (*SessionMutation) AddField ¶
func (m *SessionMutation) 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 (*SessionMutation) AddedEdges ¶
func (m *SessionMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*SessionMutation) AddedField ¶
func (m *SessionMutation) 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 (*SessionMutation) AddedFields ¶
func (m *SessionMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*SessionMutation) AddedIDs ¶
func (m *SessionMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*SessionMutation) ClearAccount ¶
func (m *SessionMutation) ClearAccount()
ClearAccount clears the "account" edge to the Account entity.
func (*SessionMutation) ClearEdge ¶
func (m *SessionMutation) 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 (*SessionMutation) ClearField ¶
func (m *SessionMutation) 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 (*SessionMutation) ClearedEdges ¶
func (m *SessionMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*SessionMutation) ClearedFields ¶
func (m *SessionMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (SessionMutation) Client ¶
func (m SessionMutation) 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 (*SessionMutation) EdgeCleared ¶
func (m *SessionMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*SessionMutation) Field ¶
func (m *SessionMutation) 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 (*SessionMutation) FieldCleared ¶
func (m *SessionMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*SessionMutation) Fields ¶
func (m *SessionMutation) 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 (*SessionMutation) ID ¶
func (m *SessionMutation) ID() (id uuid.UUID, 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 (*SessionMutation) IDs ¶
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 (*SessionMutation) 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 (*SessionMutation) OldUserAgent ¶
func (m *SessionMutation) OldUserAgent(ctx context.Context) (v string, err error)
OldUserAgent returns the old "user_agent" field's value of the Session entity. If the Session 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 (*SessionMutation) RemovedEdges ¶
func (m *SessionMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*SessionMutation) RemovedIDs ¶
func (m *SessionMutation) 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 (*SessionMutation) ResetAccount ¶
func (m *SessionMutation) ResetAccount()
ResetAccount resets all changes to the "account" edge.
func (*SessionMutation) ResetEdge ¶
func (m *SessionMutation) 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 (*SessionMutation) ResetField ¶
func (m *SessionMutation) 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 (*SessionMutation) ResetUserAgent ¶
func (m *SessionMutation) ResetUserAgent()
ResetUserAgent resets all changes to the "user_agent" field.
func (*SessionMutation) SetAccountID ¶
func (m *SessionMutation) SetAccountID(id uuid.UUID)
SetAccountID sets the "account" edge to the Account entity by id.
func (*SessionMutation) SetField ¶
func (m *SessionMutation) 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 (*SessionMutation) SetID ¶
func (m *SessionMutation) SetID(id uuid.UUID)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Session entities.
func (*SessionMutation) SetOp ¶
func (m *SessionMutation) SetOp(op Op)
SetOp allows setting the mutation operation.
func (*SessionMutation) SetUserAgent ¶
func (m *SessionMutation) SetUserAgent(s string)
SetUserAgent sets the "user_agent" field.
func (SessionMutation) Tx ¶
func (m SessionMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*SessionMutation) Type ¶
func (m *SessionMutation) Type() string
Type returns the node type of this mutation (Session).
func (*SessionMutation) UserAgent ¶
func (m *SessionMutation) UserAgent() (r string, exists bool)
UserAgent returns the value of the "user_agent" field in the mutation.
func (*SessionMutation) Where ¶
func (m *SessionMutation) Where(ps ...predicate.Session)
Where appends a list predicates to the SessionMutation builder.
func (*SessionMutation) WhereP ¶
func (m *SessionMutation) WhereP(ps ...func(*sql.Selector))
WhereP appends storage-level predicates to the SessionMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.
type SessionPatchRequest ¶
type SessionPatchRequest struct {
UserAgent *string `json:"user_agent,omitempty"`
// contains filtered or unexported fields
}
SessionPatchRequest is the partial-update request for Session.
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 (*SessionPatchRequest) HasUserAgent ¶
func (r *SessionPatchRequest) HasUserAgent() bool
HasUserAgent reports whether the payload carried "user_agent".
func (*SessionPatchRequest) UnmarshalJSON ¶
func (r *SessionPatchRequest) 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 (*SessionPatchRequest) Validate ¶
func (r *SessionPatchRequest) Validate() (*ValidSessionPatchRequest, 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 SessionQuery ¶
type SessionQuery struct {
// contains filtered or unexported fields
}
SessionQuery is the builder for querying Session entities.
func SessionQueryWithResponseEdges ¶
func SessionQueryWithResponseEdges(q *SessionQuery) *SessionQuery
SessionQueryWithResponseEdges applies the eager-load plan for SessionResponse.
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 NewSessionResponse return a not-loaded-edge error at run time. It fails loudly; it never silently narrows the response.
SessionClient.Get loads no edges and therefore cannot serve this response type. Wiring for Session must go through Query with this plan applied.
func (*SessionQuery) Aggregate ¶
func (sq *SessionQuery) Aggregate(fns ...AggregateFunc) *SessionSelect
Aggregate returns a SessionSelect configured with the given aggregations.
func (*SessionQuery) All ¶
func (sq *SessionQuery) All(ctx context.Context) ([]*Session, error)
All executes the query and returns a list of Sessions.
func (*SessionQuery) AllX ¶
func (sq *SessionQuery) AllX(ctx context.Context) []*Session
AllX is like All, but panics if an error occurs.
func (*SessionQuery) Clone ¶
func (sq *SessionQuery) Clone() *SessionQuery
Clone returns a duplicate of the SessionQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*SessionQuery) Count ¶
func (sq *SessionQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*SessionQuery) CountX ¶
func (sq *SessionQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*SessionQuery) Exist ¶
func (sq *SessionQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*SessionQuery) ExistX ¶
func (sq *SessionQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*SessionQuery) First ¶
func (sq *SessionQuery) First(ctx context.Context) (*Session, error)
First returns the first Session entity from the query. Returns a *NotFoundError when no Session was found.
func (*SessionQuery) FirstID ¶
FirstID returns the first Session ID from the query. Returns a *NotFoundError when no Session ID was found.
func (*SessionQuery) FirstIDX ¶
func (sq *SessionQuery) FirstIDX(ctx context.Context) uuid.UUID
FirstIDX is like FirstID, but panics if an error occurs.
func (*SessionQuery) FirstX ¶
func (sq *SessionQuery) FirstX(ctx context.Context) *Session
FirstX is like First, but panics if an error occurs.
func (*SessionQuery) GroupBy ¶
func (sq *SessionQuery) GroupBy(field string, fields ...string) *SessionGroupBy
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 {
UserAgent string `json:"user_agent,omitempty"`
Count int `json:"count,omitempty"`
}
client.Session.Query().
GroupBy(session.FieldUserAgent).
Aggregate(sensitiveent.Count()).
Scan(ctx, &v)
func (*SessionQuery) IDsX ¶
func (sq *SessionQuery) IDsX(ctx context.Context) []uuid.UUID
IDsX is like IDs, but panics if an error occurs.
func (*SessionQuery) Limit ¶
func (sq *SessionQuery) Limit(limit int) *SessionQuery
Limit the number of records to be returned by this query.
func (*SessionQuery) Offset ¶
func (sq *SessionQuery) Offset(offset int) *SessionQuery
Offset to start from.
func (*SessionQuery) Only ¶
func (sq *SessionQuery) Only(ctx context.Context) (*Session, error)
Only returns a single Session entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Session entity is found. Returns a *NotFoundError when no Session entities are found.
func (*SessionQuery) OnlyID ¶
OnlyID is like Only, but returns the only Session ID in the query. Returns a *NotSingularError when more than one Session ID is found. Returns a *NotFoundError when no entities are found.
func (*SessionQuery) OnlyIDX ¶
func (sq *SessionQuery) OnlyIDX(ctx context.Context) uuid.UUID
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*SessionQuery) OnlyX ¶
func (sq *SessionQuery) OnlyX(ctx context.Context) *Session
OnlyX is like Only, but panics if an error occurs.
func (*SessionQuery) Order ¶
func (sq *SessionQuery) Order(o ...session.OrderOption) *SessionQuery
Order specifies how the records should be ordered.
func (*SessionQuery) QueryAccount ¶
func (sq *SessionQuery) QueryAccount() *AccountQuery
QueryAccount chains the current query on the "account" edge.
func (*SessionQuery) Select ¶
func (sq *SessionQuery) Select(fields ...string) *SessionSelect
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 {
UserAgent string `json:"user_agent,omitempty"`
}
client.Session.Query().
Select(session.FieldUserAgent).
Scan(ctx, &v)
func (*SessionQuery) Unique ¶
func (sq *SessionQuery) Unique(unique bool) *SessionQuery
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 (*SessionQuery) Where ¶
func (sq *SessionQuery) Where(ps ...predicate.Session) *SessionQuery
Where adds a new predicate for the SessionQuery builder.
func (*SessionQuery) WithAccount ¶
func (sq *SessionQuery) WithAccount(opts ...func(*AccountQuery)) *SessionQuery
WithAccount tells the query-builder to eager-load the nodes that are connected to the "account" edge. The optional arguments are used to configure the query builder of the edge.
type SessionResponse ¶
type SessionResponse struct {
// ID field is always included in responses
ID uuid.UUID `json:"id"`
UserAgent string `json:"user_agent"`
Account *AccountSummary `json:"account"`
}
SessionResponse represents the response for Session.
It is emitted unconditionally: an entity whose every scalar field is Sensitive still has a meaningful response carrying its ID, and SessionListResponse below refers to this type either way.
No edge field is omitempty. A loaded edge with no related row has to reach the client as an explicit null: omitting the key would make it indistinguishable from an edge nobody asked to load.
func CreateSession ¶
func CreateSession(ctx context.Context, db *Client, v *ValidSessionCreateRequest) (*SessionResponse, error)
CreateSession inserts one Session and returns its response.
It takes the VALIDATED request. Apply is defined on that type and nowhere else, so validation is a compile-time requirement here rather than a step this function could forget on the caller's behalf.
func GetSession ¶
GetSession reads one Session and converts it to its response.
func NewSessionResponse ¶
func NewSessionResponse(e *Session) (*SessionResponse, error)
NewSessionResponse converts an entity to its response DTO.
Edge state is read through <Edge>OrErr(), never through a nil check: the flag separating "not loaded" from "loaded and absent" is unexported, so a nil pointer cannot tell them apart. Loaded-and-absent becomes an explicit null; a not-loaded edge is returned as an error rather than shipping a response that reads as "this session has none".
That error is cheap because SessionQueryWithResponseEdges below is generated from this type's own edge set, so generated wiring cannot forget an edge and the error only ever catches a hand-rolled query.
func PatchSession ¶
func PatchSession(ctx context.Context, db *Client, id uuid.UUID, v *ValidSessionPatchRequest) (*SessionResponse, error)
PatchSession applies a validated patch to one Session.
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 SessionSelect ¶
type SessionSelect struct {
*SessionQuery
// contains filtered or unexported fields
}
SessionSelect is the builder for selecting fields of Session entities.
func (*SessionSelect) Aggregate ¶
func (ss *SessionSelect) Aggregate(fns ...AggregateFunc) *SessionSelect
Aggregate adds the given aggregation functions to the selector query.
func (*SessionSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*SessionSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*SessionSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*SessionSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*SessionSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*SessionSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*SessionSelect) Scan ¶
func (ss *SessionSelect) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*SessionSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type SessionSummary ¶
type SessionSummary struct {
// ID field is always included in summaries
ID uuid.UUID `json:"id"`
UserAgent string `json:"user_agent"`
}
SessionSummary is the shape Session takes on another entity's response.
It carries the same scalar fields as SessionResponse and no edges at all. That is what bounds expansion: NewSessionResponse 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 NewSessionSummary ¶
func NewSessionSummary(e *Session) *SessionSummary
NewSessionSummary converts an entity to its summary DTO. It cannot fail: a summary reads no edges.
type SessionUpdate ¶
type SessionUpdate struct {
// contains filtered or unexported fields
}
SessionUpdate is the builder for updating Session entities.
func (*SessionUpdate) ClearAccount ¶
func (su *SessionUpdate) ClearAccount() *SessionUpdate
ClearAccount clears the "account" edge to the Account entity.
func (*SessionUpdate) Exec ¶
func (su *SessionUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*SessionUpdate) ExecX ¶
func (su *SessionUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*SessionUpdate) Mutation ¶
func (su *SessionUpdate) Mutation() *SessionMutation
Mutation returns the SessionMutation object of the builder.
func (*SessionUpdate) Save ¶
func (su *SessionUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*SessionUpdate) SaveX ¶
func (su *SessionUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*SessionUpdate) SetAccount ¶
func (su *SessionUpdate) SetAccount(a *Account) *SessionUpdate
SetAccount sets the "account" edge to the Account entity.
func (*SessionUpdate) SetAccountID ¶
func (su *SessionUpdate) SetAccountID(id uuid.UUID) *SessionUpdate
SetAccountID sets the "account" edge to the Account entity by ID.
func (*SessionUpdate) SetNillableAccountID ¶
func (su *SessionUpdate) SetNillableAccountID(id *uuid.UUID) *SessionUpdate
SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
func (*SessionUpdate) SetNillableUserAgent ¶
func (su *SessionUpdate) SetNillableUserAgent(s *string) *SessionUpdate
SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
func (*SessionUpdate) SetUserAgent ¶
func (su *SessionUpdate) SetUserAgent(s string) *SessionUpdate
SetUserAgent sets the "user_agent" field.
func (*SessionUpdate) Where ¶
func (su *SessionUpdate) Where(ps ...predicate.Session) *SessionUpdate
Where appends a list predicates to the SessionUpdate builder.
type SessionUpdateOne ¶
type SessionUpdateOne struct {
// contains filtered or unexported fields
}
SessionUpdateOne is the builder for updating a single Session entity.
func (*SessionUpdateOne) ClearAccount ¶
func (suo *SessionUpdateOne) ClearAccount() *SessionUpdateOne
ClearAccount clears the "account" edge to the Account entity.
func (*SessionUpdateOne) Exec ¶
func (suo *SessionUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*SessionUpdateOne) ExecX ¶
func (suo *SessionUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*SessionUpdateOne) Mutation ¶
func (suo *SessionUpdateOne) Mutation() *SessionMutation
Mutation returns the SessionMutation object of the builder.
func (*SessionUpdateOne) Save ¶
func (suo *SessionUpdateOne) Save(ctx context.Context) (*Session, error)
Save executes the query and returns the updated Session entity.
func (*SessionUpdateOne) SaveX ¶
func (suo *SessionUpdateOne) SaveX(ctx context.Context) *Session
SaveX is like Save, but panics if an error occurs.
func (*SessionUpdateOne) Select ¶
func (suo *SessionUpdateOne) Select(field string, fields ...string) *SessionUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*SessionUpdateOne) SetAccount ¶
func (suo *SessionUpdateOne) SetAccount(a *Account) *SessionUpdateOne
SetAccount sets the "account" edge to the Account entity.
func (*SessionUpdateOne) SetAccountID ¶
func (suo *SessionUpdateOne) SetAccountID(id uuid.UUID) *SessionUpdateOne
SetAccountID sets the "account" edge to the Account entity by ID.
func (*SessionUpdateOne) SetNillableAccountID ¶
func (suo *SessionUpdateOne) SetNillableAccountID(id *uuid.UUID) *SessionUpdateOne
SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
func (*SessionUpdateOne) SetNillableUserAgent ¶
func (suo *SessionUpdateOne) SetNillableUserAgent(s *string) *SessionUpdateOne
SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
func (*SessionUpdateOne) SetUserAgent ¶
func (suo *SessionUpdateOne) SetUserAgent(s string) *SessionUpdateOne
SetUserAgent sets the "user_agent" field.
func (*SessionUpdateOne) Where ¶
func (suo *SessionUpdateOne) Where(ps ...predicate.Session) *SessionUpdateOne
Where appends a list predicates to the SessionUpdate builder.
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
// Session is the client for interacting with the Session builders.
Session *SessionClient
// 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 ValidAccountCreateRequest ¶
type ValidAccountCreateRequest struct {
// contains filtered or unexported fields
}
ValidAccountCreateRequest wraps a AccountCreateRequest that has passed Validate. Apply is defined on this type and nowhere else, so a caller who skips validation has no method to call — a compile error rather than a validator that runs only when someone remembers it.
func (*ValidAccountCreateRequest) Apply ¶
func (v *ValidAccountCreateRequest) Apply(b *AccountCreate) *AccountCreate
Apply writes the request onto a create builder.
A field the caller omitted is not written at all, so the schema's Default() still applies. Writing the zero value unconditionally is what silently defeated every schema default.
func (*ValidAccountCreateRequest) HasLoginWindow ¶
func (v *ValidAccountCreateRequest) HasLoginWindow() bool
HasLoginWindow reports whether the payload carried "login_window".
func (*ValidAccountCreateRequest) HasName ¶
func (v *ValidAccountCreateRequest) HasName() bool
HasName reports whether the payload carried "name".
func (*ValidAccountCreateRequest) HasPasswordHash ¶
func (v *ValidAccountCreateRequest) HasPasswordHash() bool
HasPasswordHash reports whether the payload carried "password_hash".
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) HasLoginWindow ¶
func (v *ValidAccountPatchRequest) HasLoginWindow() bool
HasLoginWindow reports whether the payload carried "login_window".
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) 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) HasPasswordHash ¶
func (v *ValidAccountPatchRequest) HasPasswordHash() bool
HasPasswordHash reports whether the payload carried "password_hash".
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) LoginWindow ¶
func (v *ValidAccountPatchRequest) LoginWindow() ([]time.Time, bool)
LoginWindow reports the value the payload carried for "login_window", and whether Apply will Set it.
Presence is two of the three states a PATCH field has; this reads the third. Paired with HasLoginWindow(), 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).
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).
func (*ValidAccountPatchRequest) PasswordHash ¶
func (v *ValidAccountPatchRequest) PasswordHash() (string, bool)
PasswordHash reports the value the payload carried for "password_hash", and whether Apply will Set it.
Presence is two of the three states a PATCH field has; this reads the third. Paired with HasPasswordHash(), 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 ValidSessionCreateRequest ¶
type ValidSessionCreateRequest struct {
// contains filtered or unexported fields
}
ValidSessionCreateRequest wraps a SessionCreateRequest that has passed Validate. Apply is defined on this type and nowhere else, so a caller who skips validation has no method to call — a compile error rather than a validator that runs only when someone remembers it.
func (*ValidSessionCreateRequest) Apply ¶
func (v *ValidSessionCreateRequest) Apply(b *SessionCreate) *SessionCreate
Apply writes the request onto a create builder.
A field the caller omitted is not written at all, so the schema's Default() still applies. Writing the zero value unconditionally is what silently defeated every schema default.
func (*ValidSessionCreateRequest) HasUserAgent ¶
func (v *ValidSessionCreateRequest) HasUserAgent() bool
HasUserAgent reports whether the payload carried "user_agent".
type ValidSessionPatchRequest ¶
type ValidSessionPatchRequest struct {
// contains filtered or unexported fields
}
ValidSessionPatchRequest wraps a SessionPatchRequest that has passed Validate. It is the only type Apply is defined on.
func (*ValidSessionPatchRequest) Apply ¶
func (v *ValidSessionPatchRequest) Apply(b *SessionUpdateOne) *SessionUpdateOne
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 (*ValidSessionPatchRequest) HasUserAgent ¶
func (v *ValidSessionPatchRequest) HasUserAgent() bool
HasUserAgent reports whether the payload carried "user_agent".
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 (*ValidSessionPatchRequest) UserAgent ¶
func (v *ValidSessionPatchRequest) UserAgent() (string, bool)
UserAgent reports the value the payload carried for "user_agent", and whether Apply will Set it.
Presence is two of the three states a PATCH field has; this reads the third. Paired with HasUserAgent(), 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.
Source Files
¶
- account.go
- account_create.go
- account_delete.go
- account_dto.go
- account_filter.go
- account_handler.go
- account_query.go
- account_update.go
- account_wiring.go
- client.go
- ent.go
- entapi_errors.go
- entapi_http.go
- entapi_openapi.go
- mutation.go
- runtime.go
- session.go
- session_create.go
- session_delete.go
- session_dto.go
- session_filter.go
- session_handler.go
- session_query.go
- session_update.go
- session_wiring.go
- tx.go