queryent

package
v0.0.0-...-b6261dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypePlain  = "Plain"
	TypeRecord = "Record"
)

Variables

View Source
var ErrTxStarted = errors.New("queryent: cannot start a transaction within a transaction")

ErrTxStarted is returned when trying to start a new transaction from a transactional client.

View Source
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.

View Source
var PlainSortKeys = []string{
	"id",
}

PlainSortKeys is the complete sort allow-list. The primary key is naturally Sortable; every other key requires api.Sortable().

View Source
var RecordSortKeys = []string{
	"id", "title", "created_at",
}

RecordSortKeys is the complete sort allow-list. The primary key is naturally Sortable; every other key requires api.Sortable().

Functions

func Asc

func Asc(fields ...string) func(*sql.Selector)

Asc applies the given fields in ASC order.

func DeleteBatchPlains

func DeleteBatchPlains(ctx context.Context, db *Client, ids []uuid.UUID) (int, error)

DeleteBatchPlains removes several Plains 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 DeleteBatchRecords

func DeleteBatchRecords(ctx context.Context, db *Client, ids []uuid.UUID) (int, error)

DeleteBatchRecords removes several Records 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 DeletePlain

func DeletePlain(ctx context.Context, db *Client, id uuid.UUID) error

DeletePlain removes one Plain.

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 DeleteRecord

func DeleteRecord(ctx context.Context, db *Client, id uuid.UUID) error

DeleteRecord removes one Record.

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 Desc

func Desc(fields ...string) func(*sql.Selector)

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

IsConstraintError returns a boolean indicating whether the error is a constraint failure.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns a boolean indicating whether the error is a not found error.

func IsNotLoaded

func IsNotLoaded(err error) bool

IsNotLoaded returns a boolean indicating whether the error is a not loaded error.

func IsNotSingular

func IsNotSingular(err error) bool

IsNotSingular returns a boolean indicating whether the error is a not singular error.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns a boolean indicating whether the error is a validation error.

func ListPlains

ListPlains 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: PlainOrder can fail, because a sort key outside PlainSortKeys 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 ListRecords

ListRecords 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: RecordOrder can fail, because a sort key outside RecordSortKeys 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 MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

func NewContext(parent context.Context, c *Client) context.Context

NewContext returns a new context with the given Client attached.

func NewTxContext

func NewTxContext(parent context.Context, tx *Tx) context.Context

NewTxContext returns a new context with the given Tx attached.

func PlainCreateRequestTags

func PlainCreateRequestTags() []string

PlainCreateRequestTags returns the canonical JSON key of every field on PlainCreateRequest, 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 PlainOrder

func PlainOrder(r entapi.ListRequest) ([]plain.OrderOption, error)

PlainOrder is the single sort allow-list seam.

func PlainPatchRequestTags

func PlainPatchRequestTags() []string

PlainPatchRequestTags returns the canonical JSON key of every field on PlainPatchRequest, 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 RecordCreateRequestTags

func RecordCreateRequestTags() []string

RecordCreateRequestTags returns the canonical JSON key of every field on RecordCreateRequest, 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 RecordOrder

func RecordOrder(r entapi.ListRequest) ([]record.OrderOption, error)

RecordOrder is the single sort allow-list seam.

func RecordPatchRequestTags

func RecordPatchRequestTags() []string

RecordPatchRequestTags returns the canonical JSON key of every field on RecordPatchRequest, 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) CreatePlainEndpoint

func (h *APIHandler) CreatePlainEndpoint() entapi.Endpoint

CreatePlainEndpoint returns the generated POST /plains endpoint.

func (*APIHandler) CreateRecordEndpoint

func (h *APIHandler) CreateRecordEndpoint() entapi.Endpoint

CreateRecordEndpoint returns the generated POST /records endpoint.

func (*APIHandler) DeletePlainEndpoint

func (h *APIHandler) DeletePlainEndpoint() entapi.Endpoint

DeletePlainEndpoint returns the generated DELETE /plains/{id} endpoint.

func (*APIHandler) DeleteRecordEndpoint

func (h *APIHandler) DeleteRecordEndpoint() entapi.Endpoint

DeleteRecordEndpoint returns the generated DELETE /records/{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) GetPlainEndpoint

func (h *APIHandler) GetPlainEndpoint() entapi.Endpoint

GetPlainEndpoint returns the generated GET /plains/{id} endpoint.

func (*APIHandler) GetRecordEndpoint

func (h *APIHandler) GetRecordEndpoint() entapi.Endpoint

GetRecordEndpoint returns the generated GET /records/{id} endpoint.

func (*APIHandler) ListPlainsEndpoint

func (h *APIHandler) ListPlainsEndpoint() entapi.Endpoint

ListPlainsEndpoint returns the generated GET /plains endpoint.

func (*APIHandler) ListRecordsEndpoint

func (h *APIHandler) ListRecordsEndpoint() entapi.Endpoint

ListRecordsEndpoint returns the generated GET /records 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) PatchPlainEndpoint

func (h *APIHandler) PatchPlainEndpoint() entapi.Endpoint

PatchPlainEndpoint returns the generated PATCH /plains/{id} endpoint.

func (*APIHandler) PatchRecordEndpoint

func (h *APIHandler) PatchRecordEndpoint() entapi.Endpoint

PatchRecordEndpoint returns the generated PATCH /records/{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 AggregateFunc

type AggregateFunc func(*sql.Selector) string

AggregateFunc applies an aggregation step on the group-by traversal/selector.

func As

As is a pseudo aggregation function for renaming another other functions with custom names. For example:

GroupBy(field1, field2).
Aggregate(queryent.As(queryent.Sum(field1), "sum_field1"), (queryent.As(queryent.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
	// Plain is the client for interacting with the Plain builders.
	Plain *PlainClient
	// Record is the client for interacting with the Record builders.
	Record *RecordClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

FromContext returns a Client stored inside a context, or nil if there isn't one.

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new client configured with the given options.

func Open

func Open(driverName, dataSourceName string, options ...Option) (*Client, error)

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) BeginTx

func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx returns a transactional client with specified options.

func (*Client) Close

func (c *Client) Close() error

Close closes the database connection and prevents new queries from starting.

func (*Client) Debug

func (c *Client) Debug() *Client

Debug returns a new debug-client. It's used to get verbose logging on specific operations.

client.Debug().
	Plain.
	Query().
	Count(ctx)

func (*Client) Intercept

func (c *Client) Intercept(interceptors ...Interceptor)

Intercept adds the query interceptors to all the entity clients. In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error)

Mutate implements the ent.Mutator interface.

func (*Client) Tx

func (c *Client) Tx(ctx context.Context) (*Tx, error)

Tx returns a new transactional client. The provided context is used until the transaction is committed or rolled back.

func (*Client) Use

func (c *Client) Use(hooks ...Hook)

Use adds the mutation hooks to all the entity clients. In order to add hooks to a specific client, call: `client.Node.Use(...)`.

type CommitFunc

type CommitFunc func(context.Context, *Tx) error

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.

func (CommitFunc) Commit

func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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 Committer

type Committer interface {
	Commit(context.Context, *Tx) error
}

Committer is the interface that wraps the Commit method.

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 CreatePlainFn

CreatePlainFn is byte-identical to CreatePlain.

type CreateRecordFn

CreateRecordFn is byte-identical to CreateRecord.

type DeletePlainFn

type DeletePlainFn func(context.Context, *Client, uuid.UUID) error

DeletePlainFn is byte-identical to DeletePlain.

type DeleteRecordFn

type DeleteRecordFn func(context.Context, *Client, uuid.UUID) error

DeleteRecordFn is byte-identical to DeleteRecord.

type GetPlainFn

type GetPlainFn func(context.Context, *Client, uuid.UUID) (*PlainResponse, error)

GetPlainFn is byte-identical to GetPlain.

type GetRecordFn

type GetRecordFn func(context.Context, *Client, uuid.UUID) (*RecordResponse, error)

GetRecordFn is byte-identical to GetRecord.

type Hook

type Hook = ent.Hook

ent aliases to avoid import conflicts in user's code.

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 ListPlainsFn

ListPlainsFn is byte-identical to ListPlains.

type ListRecordsFn

ListRecordsFn is byte-identical to ListRecords.

type MutateFunc

type MutateFunc = ent.MutateFunc

ent aliases to avoid import conflicts in user's code.

type Mutation

type Mutation = ent.Mutation

ent aliases to avoid import conflicts in user's code.

type Mutator

type Mutator = ent.Mutator

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 Op

type Op = ent.Op

ent aliases to avoid import conflicts in user's code.

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

func Log(fn func(...any)) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector. Deprecated: Use Asc/Desc functions or the package builders instead.

type PatchPlainFn

PatchPlainFn is byte-identical to PatchPlain.

type PatchRecordFn

PatchRecordFn is byte-identical to PatchRecord.

type Plain

type Plain struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// Label holds the value of the "label" field.
	Label string `json:"label,omitempty"`
	// contains filtered or unexported fields
}

Plain is the model entity for the Plain schema.

func (*Plain) String

func (pl *Plain) String() string

String implements the fmt.Stringer.

func (*Plain) Unwrap

func (pl *Plain) Unwrap() *Plain

Unwrap unwraps the Plain 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 (*Plain) Update

func (pl *Plain) Update() *PlainUpdateOne

Update returns a builder for updating this Plain. Note that you need to call Plain.Unwrap() before calling this method if this Plain was returned from a transaction, and the transaction was committed or rolled back.

func (*Plain) Value

func (pl *Plain) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the Plain. This includes values selected through modifiers, order, etc.

type PlainClient

type PlainClient struct {
	// contains filtered or unexported fields
}

PlainClient is a client for the Plain schema.

func NewPlainClient

func NewPlainClient(c config) *PlainClient

NewPlainClient returns a client for the Plain from the given config.

func (*PlainClient) Create

func (c *PlainClient) Create() *PlainCreate

Create returns a builder for creating a Plain entity.

func (*PlainClient) CreateBulk

func (c *PlainClient) CreateBulk(builders ...*PlainCreate) *PlainCreateBulk

CreateBulk returns a builder for creating a bulk of Plain entities.

func (*PlainClient) Delete

func (c *PlainClient) Delete() *PlainDelete

Delete returns a delete builder for Plain.

func (*PlainClient) DeleteOne

func (c *PlainClient) DeleteOne(pl *Plain) *PlainDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*PlainClient) DeleteOneID

func (c *PlainClient) DeleteOneID(id uuid.UUID) *PlainDeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*PlainClient) Get

func (c *PlainClient) Get(ctx context.Context, id uuid.UUID) (*Plain, error)

Get returns a Plain entity by its id.

func (*PlainClient) GetX

func (c *PlainClient) GetX(ctx context.Context, id uuid.UUID) *Plain

GetX is like Get, but panics if an error occurs.

func (*PlainClient) Hooks

func (c *PlainClient) Hooks() []Hook

Hooks returns the client hooks.

func (*PlainClient) Intercept

func (c *PlainClient) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `plain.Intercept(f(g(h())))`.

func (*PlainClient) Interceptors

func (c *PlainClient) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*PlainClient) MapCreateBulk

func (c *PlainClient) MapCreateBulk(slice any, setFunc func(*PlainCreate, int)) *PlainCreateBulk

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 (*PlainClient) Query

func (c *PlainClient) Query() *PlainQuery

Query returns a query builder for Plain.

func (*PlainClient) Update

func (c *PlainClient) Update() *PlainUpdate

Update returns an update builder for Plain.

func (*PlainClient) UpdateOne

func (c *PlainClient) UpdateOne(pl *Plain) *PlainUpdateOne

UpdateOne returns an update builder for the given entity.

func (*PlainClient) UpdateOneID

func (c *PlainClient) UpdateOneID(id uuid.UUID) *PlainUpdateOne

UpdateOneID returns an update builder for the given id.

func (*PlainClient) Use

func (c *PlainClient) Use(hooks ...Hook)

Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `plain.Hooks(f(g(h())))`.

type PlainCreate

type PlainCreate struct {
	// contains filtered or unexported fields
}

PlainCreate is the builder for creating a Plain entity.

func (*PlainCreate) Exec

func (pc *PlainCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*PlainCreate) ExecX

func (pc *PlainCreate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*PlainCreate) Mutation

func (pc *PlainCreate) Mutation() *PlainMutation

Mutation returns the PlainMutation object of the builder.

func (*PlainCreate) Save

func (pc *PlainCreate) Save(ctx context.Context) (*Plain, error)

Save creates the Plain in the database.

func (*PlainCreate) SaveX

func (pc *PlainCreate) SaveX(ctx context.Context) *Plain

SaveX calls Save and panics if Save returns an error.

func (*PlainCreate) SetID

func (pc *PlainCreate) SetID(u uuid.UUID) *PlainCreate

SetID sets the "id" field.

func (*PlainCreate) SetLabel

func (pc *PlainCreate) SetLabel(s string) *PlainCreate

SetLabel sets the "label" field.

func (*PlainCreate) SetNillableID

func (pc *PlainCreate) SetNillableID(u *uuid.UUID) *PlainCreate

SetNillableID sets the "id" field if the given value is not nil.

type PlainCreateBulk

type PlainCreateBulk struct {
	// contains filtered or unexported fields
}

PlainCreateBulk is the builder for creating many Plain entities in bulk.

func (*PlainCreateBulk) Exec

func (pcb *PlainCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*PlainCreateBulk) ExecX

func (pcb *PlainCreateBulk) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*PlainCreateBulk) Save

func (pcb *PlainCreateBulk) Save(ctx context.Context) ([]*Plain, error)

Save creates the Plain entities in the database.

func (*PlainCreateBulk) SaveX

func (pcb *PlainCreateBulk) SaveX(ctx context.Context) []*Plain

SaveX is like Save, but panics if an error occurs.

type PlainCreateRequest

type PlainCreateRequest struct {
	Label string `json:"label"`
	// contains filtered or unexported fields
}

PlainCreateRequest is the create request for Plain.

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 (*PlainCreateRequest) HasLabel

func (r *PlainCreateRequest) HasLabel() bool

HasLabel reports whether the payload carried "label".

func (*PlainCreateRequest) UnmarshalJSON

func (r *PlainCreateRequest) 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 (*PlainCreateRequest) Validate

Validate checks the request and returns the only type Apply accepts.

type PlainDelete

type PlainDelete struct {
	// contains filtered or unexported fields
}

PlainDelete is the builder for deleting a Plain entity.

func (*PlainDelete) Exec

func (pd *PlainDelete) Exec(ctx context.Context) (int, error)

Exec executes the deletion query and returns how many vertices were deleted.

func (*PlainDelete) ExecX

func (pd *PlainDelete) ExecX(ctx context.Context) int

ExecX is like Exec, but panics if an error occurs.

func (*PlainDelete) Where

func (pd *PlainDelete) Where(ps ...predicate.Plain) *PlainDelete

Where appends a list predicates to the PlainDelete builder.

type PlainDeleteOne

type PlainDeleteOne struct {
	// contains filtered or unexported fields
}

PlainDeleteOne is the builder for deleting a single Plain entity.

func (*PlainDeleteOne) Exec

func (pdo *PlainDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*PlainDeleteOne) ExecX

func (pdo *PlainDeleteOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*PlainDeleteOne) Where

func (pdo *PlainDeleteOne) Where(ps ...predicate.Plain) *PlainDeleteOne

Where appends a list predicates to the PlainDelete builder.

type PlainFilter

type PlainFilter 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"`
}

PlainFilter is the typed query representation for Plain. Repeated URL parameters occupy repeated slots and Predicates ANDs them.

func ParsePlainQuery

func ParsePlainQuery(q url.Values) (*PlainFilter, entapi.ListRequest, error)

ParsePlainQuery 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 (*PlainFilter) Predicates

func (f *PlainFilter) Predicates() []predicate.Plain

Predicates converts the typed filter into conjunctive ent predicates.

type PlainGroupBy

type PlainGroupBy struct {
	// contains filtered or unexported fields
}

PlainGroupBy is the group-by builder for Plain entities.

func (*PlainGroupBy) Aggregate

func (pgb *PlainGroupBy) Aggregate(fns ...AggregateFunc) *PlainGroupBy

Aggregate adds the given aggregation functions to the group-by query.

func (*PlainGroupBy) Bool

func (s *PlainGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) BoolX

func (s *PlainGroupBy) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*PlainGroupBy) Bools

func (s *PlainGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) BoolsX

func (s *PlainGroupBy) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*PlainGroupBy) Float64

func (s *PlainGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) Float64X

func (s *PlainGroupBy) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*PlainGroupBy) Float64s

func (s *PlainGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) Float64sX

func (s *PlainGroupBy) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*PlainGroupBy) Int

func (s *PlainGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) IntX

func (s *PlainGroupBy) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*PlainGroupBy) Ints

func (s *PlainGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) IntsX

func (s *PlainGroupBy) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*PlainGroupBy) Scan

func (pgb *PlainGroupBy) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*PlainGroupBy) ScanX

func (s *PlainGroupBy) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*PlainGroupBy) String

func (s *PlainGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) StringX

func (s *PlainGroupBy) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*PlainGroupBy) Strings

func (s *PlainGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*PlainGroupBy) StringsX

func (s *PlainGroupBy) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type PlainListResponse

type PlainListResponse struct {
	Data  []*PlainResponse `json:"data"`
	Total int              `json:"total"`
	Page  int              `json:"page"`
	Size  int              `json:"size"`
}

PlainListResponse is the NAMED, non-generic shape of one list page — for OpenAPI/swaggo-class annotation tooling, which cannot express the generic entapi.Page[PlainResponse] that ListPlains returns. Convert at the handler boundary with NewPlainListResponse. (A fifth field, PageInfo, carried cursor metadata until #6 removed it.)

func NewPlainListResponse

func NewPlainListResponse(p *entapi.Page[PlainResponse]) *PlainListResponse

NewPlainListResponse converts the page ListPlains returns into the named list shape. The conversion expression is the shape contract: if PlainListResponse 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 PlainMutation

type PlainMutation struct {
	// contains filtered or unexported fields
}

PlainMutation represents an operation that mutates the Plain nodes in the graph.

func (*PlainMutation) AddField

func (m *PlainMutation) 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 (*PlainMutation) AddedEdges

func (m *PlainMutation) AddedEdges() []string

AddedEdges returns all edge names that were set/added in this mutation.

func (*PlainMutation) AddedField

func (m *PlainMutation) 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 (*PlainMutation) AddedFields

func (m *PlainMutation) AddedFields() []string

AddedFields returns all numeric fields that were incremented/decremented during this mutation.

func (*PlainMutation) AddedIDs

func (m *PlainMutation) AddedIDs(name string) []ent.Value

AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.

func (*PlainMutation) ClearEdge

func (m *PlainMutation) 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 (*PlainMutation) ClearField

func (m *PlainMutation) 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 (*PlainMutation) ClearedEdges

func (m *PlainMutation) ClearedEdges() []string

ClearedEdges returns all edge names that were cleared in this mutation.

func (*PlainMutation) ClearedFields

func (m *PlainMutation) ClearedFields() []string

ClearedFields returns all nullable fields that were cleared during this mutation.

func (PlainMutation) Client

func (m PlainMutation) 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 (*PlainMutation) EdgeCleared

func (m *PlainMutation) EdgeCleared(name string) bool

EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.

func (*PlainMutation) Field

func (m *PlainMutation) 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 (*PlainMutation) FieldCleared

func (m *PlainMutation) FieldCleared(name string) bool

FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.

func (*PlainMutation) Fields

func (m *PlainMutation) 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 (*PlainMutation) ID

func (m *PlainMutation) 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 (*PlainMutation) IDs

func (m *PlainMutation) IDs(ctx context.Context) ([]uuid.UUID, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*PlainMutation) Label

func (m *PlainMutation) Label() (r string, exists bool)

Label returns the value of the "label" field in the mutation.

func (*PlainMutation) OldField

func (m *PlainMutation) OldField(ctx context.Context, name string) (ent.Value, error)

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 (*PlainMutation) OldLabel

func (m *PlainMutation) OldLabel(ctx context.Context) (v string, err error)

OldLabel returns the old "label" field's value of the Plain entity. If the Plain 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 (*PlainMutation) Op

func (m *PlainMutation) Op() Op

Op returns the operation name.

func (*PlainMutation) RemovedEdges

func (m *PlainMutation) RemovedEdges() []string

RemovedEdges returns all edge names that were removed in this mutation.

func (*PlainMutation) RemovedIDs

func (m *PlainMutation) 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 (*PlainMutation) ResetEdge

func (m *PlainMutation) 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 (*PlainMutation) ResetField

func (m *PlainMutation) 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 (*PlainMutation) ResetLabel

func (m *PlainMutation) ResetLabel()

ResetLabel resets all changes to the "label" field.

func (*PlainMutation) SetField

func (m *PlainMutation) 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 (*PlainMutation) SetID

func (m *PlainMutation) SetID(id uuid.UUID)

SetID sets the value of the id field. Note that this operation is only accepted on creation of Plain entities.

func (*PlainMutation) SetLabel

func (m *PlainMutation) SetLabel(s string)

SetLabel sets the "label" field.

func (*PlainMutation) SetOp

func (m *PlainMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (PlainMutation) Tx

func (m PlainMutation) Tx() (*Tx, error)

Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.

func (*PlainMutation) Type

func (m *PlainMutation) Type() string

Type returns the node type of this mutation (Plain).

func (*PlainMutation) Where

func (m *PlainMutation) Where(ps ...predicate.Plain)

Where appends a list predicates to the PlainMutation builder.

func (*PlainMutation) WhereP

func (m *PlainMutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the PlainMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type PlainPatchRequest

type PlainPatchRequest struct {
	Label *string `json:"label,omitempty"`
	// contains filtered or unexported fields
}

PlainPatchRequest is the partial-update request for Plain.

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 (*PlainPatchRequest) HasLabel

func (r *PlainPatchRequest) HasLabel() bool

HasLabel reports whether the payload carried "label".

func (*PlainPatchRequest) UnmarshalJSON

func (r *PlainPatchRequest) 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 (*PlainPatchRequest) Validate

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 PlainQuery

type PlainQuery struct {
	// contains filtered or unexported fields
}

PlainQuery is the builder for querying Plain entities.

func PlainQueryWithResponseEdges

func PlainQueryWithResponseEdges(q *PlainQuery) *PlainQuery

PlainQueryWithResponseEdges applies the eager-load plan for PlainResponse.

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 NewPlainResponse 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 (*PlainQuery) Aggregate

func (pq *PlainQuery) Aggregate(fns ...AggregateFunc) *PlainSelect

Aggregate returns a PlainSelect configured with the given aggregations.

func (*PlainQuery) All

func (pq *PlainQuery) All(ctx context.Context) ([]*Plain, error)

All executes the query and returns a list of Plains.

func (*PlainQuery) AllX

func (pq *PlainQuery) AllX(ctx context.Context) []*Plain

AllX is like All, but panics if an error occurs.

func (*PlainQuery) Clone

func (pq *PlainQuery) Clone() *PlainQuery

Clone returns a duplicate of the PlainQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.

func (*PlainQuery) Count

func (pq *PlainQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*PlainQuery) CountX

func (pq *PlainQuery) CountX(ctx context.Context) int

CountX is like Count, but panics if an error occurs.

func (*PlainQuery) Exist

func (pq *PlainQuery) Exist(ctx context.Context) (bool, error)

Exist returns true if the query has elements in the graph.

func (*PlainQuery) ExistX

func (pq *PlainQuery) ExistX(ctx context.Context) bool

ExistX is like Exist, but panics if an error occurs.

func (*PlainQuery) First

func (pq *PlainQuery) First(ctx context.Context) (*Plain, error)

First returns the first Plain entity from the query. Returns a *NotFoundError when no Plain was found.

func (*PlainQuery) FirstID

func (pq *PlainQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

FirstID returns the first Plain ID from the query. Returns a *NotFoundError when no Plain ID was found.

func (*PlainQuery) FirstIDX

func (pq *PlainQuery) FirstIDX(ctx context.Context) uuid.UUID

FirstIDX is like FirstID, but panics if an error occurs.

func (*PlainQuery) FirstX

func (pq *PlainQuery) FirstX(ctx context.Context) *Plain

FirstX is like First, but panics if an error occurs.

func (*PlainQuery) GroupBy

func (pq *PlainQuery) GroupBy(field string, fields ...string) *PlainGroupBy

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 {
	Label string `json:"label,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Plain.Query().
	GroupBy(plain.FieldLabel).
	Aggregate(queryent.Count()).
	Scan(ctx, &v)

func (*PlainQuery) IDs

func (pq *PlainQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error)

IDs executes the query and returns a list of Plain IDs.

func (*PlainQuery) IDsX

func (pq *PlainQuery) IDsX(ctx context.Context) []uuid.UUID

IDsX is like IDs, but panics if an error occurs.

func (*PlainQuery) Limit

func (pq *PlainQuery) Limit(limit int) *PlainQuery

Limit the number of records to be returned by this query.

func (*PlainQuery) Offset

func (pq *PlainQuery) Offset(offset int) *PlainQuery

Offset to start from.

func (*PlainQuery) Only

func (pq *PlainQuery) Only(ctx context.Context) (*Plain, error)

Only returns a single Plain entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Plain entity is found. Returns a *NotFoundError when no Plain entities are found.

func (*PlainQuery) OnlyID

func (pq *PlainQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

OnlyID is like Only, but returns the only Plain ID in the query. Returns a *NotSingularError when more than one Plain ID is found. Returns a *NotFoundError when no entities are found.

func (*PlainQuery) OnlyIDX

func (pq *PlainQuery) OnlyIDX(ctx context.Context) uuid.UUID

OnlyIDX is like OnlyID, but panics if an error occurs.

func (*PlainQuery) OnlyX

func (pq *PlainQuery) OnlyX(ctx context.Context) *Plain

OnlyX is like Only, but panics if an error occurs.

func (*PlainQuery) Order

func (pq *PlainQuery) Order(o ...plain.OrderOption) *PlainQuery

Order specifies how the records should be ordered.

func (*PlainQuery) Select

func (pq *PlainQuery) Select(fields ...string) *PlainSelect

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 {
	Label string `json:"label,omitempty"`
}

client.Plain.Query().
	Select(plain.FieldLabel).
	Scan(ctx, &v)

func (*PlainQuery) Unique

func (pq *PlainQuery) Unique(unique bool) *PlainQuery

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 (*PlainQuery) Where

func (pq *PlainQuery) Where(ps ...predicate.Plain) *PlainQuery

Where adds a new predicate for the PlainQuery builder.

type PlainResponse

type PlainResponse struct {
	// ID field is always included in responses
	ID    uuid.UUID `json:"id"`
	Label string    `json:"label"`
}

PlainResponse represents the response for Plain.

It is emitted unconditionally: an entity whose every scalar field is Sensitive still has a meaningful response carrying its ID, and PlainListResponse below refers to this type either way.

func CreatePlain

func CreatePlain(ctx context.Context, db *Client, v *ValidPlainCreateRequest) (*PlainResponse, error)

CreatePlain inserts one Plain 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 GetPlain

func GetPlain(ctx context.Context, db *Client, id uuid.UUID) (*PlainResponse, error)

GetPlain reads one Plain and converts it to its response.

func NewPlainResponse

func NewPlainResponse(e *Plain) (*PlainResponse, error)

NewPlainResponse 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 PatchPlain

func PatchPlain(ctx context.Context, db *Client, id uuid.UUID, v *ValidPlainPatchRequest) (*PlainResponse, error)

PatchPlain applies a validated patch to one Plain.

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 PlainSelect

type PlainSelect struct {
	*PlainQuery
	// contains filtered or unexported fields
}

PlainSelect is the builder for selecting fields of Plain entities.

func (*PlainSelect) Aggregate

func (ps *PlainSelect) Aggregate(fns ...AggregateFunc) *PlainSelect

Aggregate adds the given aggregation functions to the selector query.

func (*PlainSelect) Bool

func (s *PlainSelect) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*PlainSelect) BoolX

func (s *PlainSelect) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*PlainSelect) Bools

func (s *PlainSelect) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*PlainSelect) BoolsX

func (s *PlainSelect) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*PlainSelect) Float64

func (s *PlainSelect) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*PlainSelect) Float64X

func (s *PlainSelect) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*PlainSelect) Float64s

func (s *PlainSelect) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*PlainSelect) Float64sX

func (s *PlainSelect) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*PlainSelect) Int

func (s *PlainSelect) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*PlainSelect) IntX

func (s *PlainSelect) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*PlainSelect) Ints

func (s *PlainSelect) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*PlainSelect) IntsX

func (s *PlainSelect) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*PlainSelect) Scan

func (ps *PlainSelect) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*PlainSelect) ScanX

func (s *PlainSelect) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*PlainSelect) String

func (s *PlainSelect) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*PlainSelect) StringX

func (s *PlainSelect) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*PlainSelect) Strings

func (s *PlainSelect) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*PlainSelect) StringsX

func (s *PlainSelect) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type PlainSummary

type PlainSummary struct {
	// ID field is always included in summaries
	ID    uuid.UUID `json:"id"`
	Label string    `json:"label"`
}

PlainSummary is the shape Plain takes on another entity's response.

It carries the same scalar fields as PlainResponse and no edges at all. That is what bounds expansion: NewPlainResponse 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 NewPlainSummary

func NewPlainSummary(e *Plain) *PlainSummary

NewPlainSummary converts an entity to its summary DTO. It cannot fail: a summary reads no edges.

type PlainUpdate

type PlainUpdate struct {
	// contains filtered or unexported fields
}

PlainUpdate is the builder for updating Plain entities.

func (*PlainUpdate) Exec

func (pu *PlainUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*PlainUpdate) ExecX

func (pu *PlainUpdate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*PlainUpdate) Mutation

func (pu *PlainUpdate) Mutation() *PlainMutation

Mutation returns the PlainMutation object of the builder.

func (*PlainUpdate) Save

func (pu *PlainUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of nodes affected by the update operation.

func (*PlainUpdate) SaveX

func (pu *PlainUpdate) SaveX(ctx context.Context) int

SaveX is like Save, but panics if an error occurs.

func (*PlainUpdate) SetLabel

func (pu *PlainUpdate) SetLabel(s string) *PlainUpdate

SetLabel sets the "label" field.

func (*PlainUpdate) SetNillableLabel

func (pu *PlainUpdate) SetNillableLabel(s *string) *PlainUpdate

SetNillableLabel sets the "label" field if the given value is not nil.

func (*PlainUpdate) Where

func (pu *PlainUpdate) Where(ps ...predicate.Plain) *PlainUpdate

Where appends a list predicates to the PlainUpdate builder.

type PlainUpdateOne

type PlainUpdateOne struct {
	// contains filtered or unexported fields
}

PlainUpdateOne is the builder for updating a single Plain entity.

func (*PlainUpdateOne) Exec

func (puo *PlainUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*PlainUpdateOne) ExecX

func (puo *PlainUpdateOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*PlainUpdateOne) Mutation

func (puo *PlainUpdateOne) Mutation() *PlainMutation

Mutation returns the PlainMutation object of the builder.

func (*PlainUpdateOne) Save

func (puo *PlainUpdateOne) Save(ctx context.Context) (*Plain, error)

Save executes the query and returns the updated Plain entity.

func (*PlainUpdateOne) SaveX

func (puo *PlainUpdateOne) SaveX(ctx context.Context) *Plain

SaveX is like Save, but panics if an error occurs.

func (*PlainUpdateOne) Select

func (puo *PlainUpdateOne) Select(field string, fields ...string) *PlainUpdateOne

Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.

func (*PlainUpdateOne) SetLabel

func (puo *PlainUpdateOne) SetLabel(s string) *PlainUpdateOne

SetLabel sets the "label" field.

func (*PlainUpdateOne) SetNillableLabel

func (puo *PlainUpdateOne) SetNillableLabel(s *string) *PlainUpdateOne

SetNillableLabel sets the "label" field if the given value is not nil.

func (*PlainUpdateOne) Where

func (puo *PlainUpdateOne) Where(ps ...predicate.Plain) *PlainUpdateOne

Where appends a list predicates to the PlainUpdate builder.

type Plains

type Plains []*Plain

Plains is a parsable slice of Plain.

type Policy

type Policy = ent.Policy

ent aliases to avoid import conflicts in user's code.

type Querier

type Querier = ent.Querier

ent aliases to avoid import conflicts in user's code.

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

ent aliases to avoid import conflicts in user's code.

type Query

type Query = ent.Query

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 Record

type Record struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Body holds the value of the "body" field.
	Body string `json:"body,omitempty"`
	// Ref holds the value of the "ref" field.
	Ref string `json:"ref,omitempty"`
	// Status holds the value of the "status" field.
	Status record.Status `json:"status,omitempty"`
	// Score holds the value of the "score" field.
	Score *int `json:"score,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Note holds the value of the "note" field.
	Note string `json:"note,omitempty"`
	// Secret holds the value of the "secret" field.
	Secret string `json:"-"`
	// contains filtered or unexported fields
}

Record is the model entity for the Record schema.

func (*Record) String

func (r *Record) String() string

String implements the fmt.Stringer.

func (*Record) Unwrap

func (r *Record) Unwrap() *Record

Unwrap unwraps the Record 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 (*Record) Update

func (r *Record) Update() *RecordUpdateOne

Update returns a builder for updating this Record. Note that you need to call Record.Unwrap() before calling this method if this Record was returned from a transaction, and the transaction was committed or rolled back.

func (*Record) Value

func (r *Record) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the Record. This includes values selected through modifiers, order, etc.

type RecordClient

type RecordClient struct {
	// contains filtered or unexported fields
}

RecordClient is a client for the Record schema.

func NewRecordClient

func NewRecordClient(c config) *RecordClient

NewRecordClient returns a client for the Record from the given config.

func (*RecordClient) Create

func (c *RecordClient) Create() *RecordCreate

Create returns a builder for creating a Record entity.

func (*RecordClient) CreateBulk

func (c *RecordClient) CreateBulk(builders ...*RecordCreate) *RecordCreateBulk

CreateBulk returns a builder for creating a bulk of Record entities.

func (*RecordClient) Delete

func (c *RecordClient) Delete() *RecordDelete

Delete returns a delete builder for Record.

func (*RecordClient) DeleteOne

func (c *RecordClient) DeleteOne(r *Record) *RecordDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*RecordClient) DeleteOneID

func (c *RecordClient) DeleteOneID(id uuid.UUID) *RecordDeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*RecordClient) Get

func (c *RecordClient) Get(ctx context.Context, id uuid.UUID) (*Record, error)

Get returns a Record entity by its id.

func (*RecordClient) GetX

func (c *RecordClient) GetX(ctx context.Context, id uuid.UUID) *Record

GetX is like Get, but panics if an error occurs.

func (*RecordClient) Hooks

func (c *RecordClient) Hooks() []Hook

Hooks returns the client hooks.

func (*RecordClient) Intercept

func (c *RecordClient) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `record.Intercept(f(g(h())))`.

func (*RecordClient) Interceptors

func (c *RecordClient) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*RecordClient) MapCreateBulk

func (c *RecordClient) MapCreateBulk(slice any, setFunc func(*RecordCreate, int)) *RecordCreateBulk

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 (*RecordClient) Query

func (c *RecordClient) Query() *RecordQuery

Query returns a query builder for Record.

func (*RecordClient) Update

func (c *RecordClient) Update() *RecordUpdate

Update returns an update builder for Record.

func (*RecordClient) UpdateOne

func (c *RecordClient) UpdateOne(r *Record) *RecordUpdateOne

UpdateOne returns an update builder for the given entity.

func (*RecordClient) UpdateOneID

func (c *RecordClient) UpdateOneID(id uuid.UUID) *RecordUpdateOne

UpdateOneID returns an update builder for the given id.

func (*RecordClient) Use

func (c *RecordClient) Use(hooks ...Hook)

Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `record.Hooks(f(g(h())))`.

type RecordCreate

type RecordCreate struct {
	// contains filtered or unexported fields
}

RecordCreate is the builder for creating a Record entity.

func (*RecordCreate) Exec

func (rc *RecordCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*RecordCreate) ExecX

func (rc *RecordCreate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*RecordCreate) Mutation

func (rc *RecordCreate) Mutation() *RecordMutation

Mutation returns the RecordMutation object of the builder.

func (*RecordCreate) Save

func (rc *RecordCreate) Save(ctx context.Context) (*Record, error)

Save creates the Record in the database.

func (*RecordCreate) SaveX

func (rc *RecordCreate) SaveX(ctx context.Context) *Record

SaveX calls Save and panics if Save returns an error.

func (*RecordCreate) SetBody

func (rc *RecordCreate) SetBody(s string) *RecordCreate

SetBody sets the "body" field.

func (*RecordCreate) SetCreatedAt

func (rc *RecordCreate) SetCreatedAt(t time.Time) *RecordCreate

SetCreatedAt sets the "created_at" field.

func (*RecordCreate) SetID

func (rc *RecordCreate) SetID(u uuid.UUID) *RecordCreate

SetID sets the "id" field.

func (*RecordCreate) SetNillableCreatedAt

func (rc *RecordCreate) SetNillableCreatedAt(t *time.Time) *RecordCreate

SetNillableCreatedAt sets the "created_at" field if the given value is not nil.

func (*RecordCreate) SetNillableID

func (rc *RecordCreate) SetNillableID(u *uuid.UUID) *RecordCreate

SetNillableID sets the "id" field if the given value is not nil.

func (*RecordCreate) SetNillableNote

func (rc *RecordCreate) SetNillableNote(s *string) *RecordCreate

SetNillableNote sets the "note" field if the given value is not nil.

func (*RecordCreate) SetNillableRef

func (rc *RecordCreate) SetNillableRef(s *string) *RecordCreate

SetNillableRef sets the "ref" field if the given value is not nil.

func (*RecordCreate) SetNillableScore

func (rc *RecordCreate) SetNillableScore(i *int) *RecordCreate

SetNillableScore sets the "score" field if the given value is not nil.

func (*RecordCreate) SetNillableStatus

func (rc *RecordCreate) SetNillableStatus(r *record.Status) *RecordCreate

SetNillableStatus sets the "status" field if the given value is not nil.

func (*RecordCreate) SetNote

func (rc *RecordCreate) SetNote(s string) *RecordCreate

SetNote sets the "note" field.

func (*RecordCreate) SetRef

func (rc *RecordCreate) SetRef(s string) *RecordCreate

SetRef sets the "ref" field.

func (*RecordCreate) SetScore

func (rc *RecordCreate) SetScore(i int) *RecordCreate

SetScore sets the "score" field.

func (*RecordCreate) SetSecret

func (rc *RecordCreate) SetSecret(s string) *RecordCreate

SetSecret sets the "secret" field.

func (*RecordCreate) SetStatus

func (rc *RecordCreate) SetStatus(r record.Status) *RecordCreate

SetStatus sets the "status" field.

func (*RecordCreate) SetTitle

func (rc *RecordCreate) SetTitle(s string) *RecordCreate

SetTitle sets the "title" field.

type RecordCreateBulk

type RecordCreateBulk struct {
	// contains filtered or unexported fields
}

RecordCreateBulk is the builder for creating many Record entities in bulk.

func (*RecordCreateBulk) Exec

func (rcb *RecordCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*RecordCreateBulk) ExecX

func (rcb *RecordCreateBulk) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*RecordCreateBulk) Save

func (rcb *RecordCreateBulk) Save(ctx context.Context) ([]*Record, error)

Save creates the Record entities in the database.

func (*RecordCreateBulk) SaveX

func (rcb *RecordCreateBulk) SaveX(ctx context.Context) []*Record

SaveX is like Save, but panics if an error occurs.

type RecordCreateRequest

type RecordCreateRequest struct {
	Title  string         `json:"title"`
	Body   string         `json:"body"`
	Ref    *string        `json:"reference,omitempty"`
	Status *record.Status `json:"status,omitempty"`
	Score  *int           `json:"score,omitempty"`
	Note   *string        `json:"note,omitempty"`
	Secret string         `json:"secret"`
	// contains filtered or unexported fields
}

RecordCreateRequest is the create request for Record.

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 (*RecordCreateRequest) HasBody

func (r *RecordCreateRequest) HasBody() bool

HasBody reports whether the payload carried "body".

func (*RecordCreateRequest) HasNote

func (r *RecordCreateRequest) HasNote() bool

HasNote reports whether the payload carried "note".

func (*RecordCreateRequest) HasRef

func (r *RecordCreateRequest) HasRef() bool

HasRef reports whether the payload carried "reference".

func (*RecordCreateRequest) HasScore

func (r *RecordCreateRequest) HasScore() bool

HasScore reports whether the payload carried "score".

func (*RecordCreateRequest) HasSecret

func (r *RecordCreateRequest) HasSecret() bool

HasSecret reports whether the payload carried "secret".

func (*RecordCreateRequest) HasStatus

func (r *RecordCreateRequest) HasStatus() bool

HasStatus reports whether the payload carried "status".

func (*RecordCreateRequest) HasTitle

func (r *RecordCreateRequest) HasTitle() bool

HasTitle reports whether the payload carried "title".

func (*RecordCreateRequest) UnmarshalJSON

func (r *RecordCreateRequest) 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 (*RecordCreateRequest) Validate

Validate checks the request and returns the only type Apply accepts.

type RecordDelete

type RecordDelete struct {
	// contains filtered or unexported fields
}

RecordDelete is the builder for deleting a Record entity.

func (*RecordDelete) Exec

func (rd *RecordDelete) Exec(ctx context.Context) (int, error)

Exec executes the deletion query and returns how many vertices were deleted.

func (*RecordDelete) ExecX

func (rd *RecordDelete) ExecX(ctx context.Context) int

ExecX is like Exec, but panics if an error occurs.

func (*RecordDelete) Where

func (rd *RecordDelete) Where(ps ...predicate.Record) *RecordDelete

Where appends a list predicates to the RecordDelete builder.

type RecordDeleteOne

type RecordDeleteOne struct {
	// contains filtered or unexported fields
}

RecordDeleteOne is the builder for deleting a single Record entity.

func (*RecordDeleteOne) Exec

func (rdo *RecordDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*RecordDeleteOne) ExecX

func (rdo *RecordDeleteOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*RecordDeleteOne) Where

func (rdo *RecordDeleteOne) Where(ps ...predicate.Record) *RecordDeleteOne

Where appends a list predicates to the RecordDelete builder.

type RecordFilter

type RecordFilter 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"`
	// title: string
	Title             []string   `json:"title,omitempty"`
	TitleNEQ          []string   `json:"title_neq,omitempty"`
	TitleIn           [][]string `json:"title_in,omitempty"`
	TitleNotIn        [][]string `json:"title_not_in,omitempty"`
	TitleGT           []string   `json:"title_gt,omitempty"`
	TitleGTE          []string   `json:"title_gte,omitempty"`
	TitleLT           []string   `json:"title_lt,omitempty"`
	TitleLTE          []string   `json:"title_lte,omitempty"`
	TitleContains     []string   `json:"title_contains,omitempty"`
	TitleHasPrefix    []string   `json:"title_prefix,omitempty"`
	TitleHasSuffix    []string   `json:"title_suffix,omitempty"`
	TitleContainsFold []string   `json:"title_icontains,omitempty"`
	// reference: string, optional
	Ref       []string   `json:"reference,omitempty"`
	RefNEQ    []string   `json:"reference_neq,omitempty"`
	RefIn     [][]string `json:"reference_in,omitempty"`
	RefNotIn  [][]string `json:"reference_not_in,omitempty"`
	RefGT     []string   `json:"reference_gt,omitempty"`
	RefGTE    []string   `json:"reference_gte,omitempty"`
	RefLT     []string   `json:"reference_lt,omitempty"`
	RefLTE    []string   `json:"reference_lte,omitempty"`
	RefIsNull []bool     `json:"reference_is_null,omitempty"`
	// status: record.Status
	Status      []record.Status   `json:"status,omitempty"`
	StatusNEQ   []record.Status   `json:"status_neq,omitempty"`
	StatusIn    [][]record.Status `json:"status_in,omitempty"`
	StatusNotIn [][]record.Status `json:"status_not_in,omitempty"`
	// score: int, optional
	Score       []int   `json:"score,omitempty"`
	ScoreNEQ    []int   `json:"score_neq,omitempty"`
	ScoreIn     [][]int `json:"score_in,omitempty"`
	ScoreNotIn  [][]int `json:"score_not_in,omitempty"`
	ScoreGT     []int   `json:"score_gt,omitempty"`
	ScoreGTE    []int   `json:"score_gte,omitempty"`
	ScoreLT     []int   `json:"score_lt,omitempty"`
	ScoreLTE    []int   `json:"score_lte,omitempty"`
	ScoreIsNull []bool  `json:"score_is_null,omitempty"`
	// created_at: time.Time
	CreatedAt      []time.Time   `json:"created_at,omitempty"`
	CreatedAtNEQ   []time.Time   `json:"created_at_neq,omitempty"`
	CreatedAtIn    [][]time.Time `json:"created_at_in,omitempty"`
	CreatedAtNotIn [][]time.Time `json:"created_at_not_in,omitempty"`
	CreatedAtGT    []time.Time   `json:"created_at_gt,omitempty"`
	CreatedAtGTE   []time.Time   `json:"created_at_gte,omitempty"`
	CreatedAtLT    []time.Time   `json:"created_at_lt,omitempty"`
	CreatedAtLTE   []time.Time   `json:"created_at_lte,omitempty"`
	// Q is the single free-text term matched across Searchable fields.
	Q *string `json:"_q,omitempty"`
}

RecordFilter is the typed query representation for Record. Repeated URL parameters occupy repeated slots and Predicates ANDs them.

func ParseRecordQuery

func ParseRecordQuery(q url.Values) (*RecordFilter, entapi.ListRequest, error)

ParseRecordQuery 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 (*RecordFilter) Predicates

func (f *RecordFilter) Predicates() []predicate.Record

Predicates converts the typed filter into conjunctive ent predicates.

type RecordGroupBy

type RecordGroupBy struct {
	// contains filtered or unexported fields
}

RecordGroupBy is the group-by builder for Record entities.

func (*RecordGroupBy) Aggregate

func (rgb *RecordGroupBy) Aggregate(fns ...AggregateFunc) *RecordGroupBy

Aggregate adds the given aggregation functions to the group-by query.

func (*RecordGroupBy) Bool

func (s *RecordGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) BoolX

func (s *RecordGroupBy) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*RecordGroupBy) Bools

func (s *RecordGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) BoolsX

func (s *RecordGroupBy) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*RecordGroupBy) Float64

func (s *RecordGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) Float64X

func (s *RecordGroupBy) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*RecordGroupBy) Float64s

func (s *RecordGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) Float64sX

func (s *RecordGroupBy) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*RecordGroupBy) Int

func (s *RecordGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) IntX

func (s *RecordGroupBy) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*RecordGroupBy) Ints

func (s *RecordGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) IntsX

func (s *RecordGroupBy) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*RecordGroupBy) Scan

func (rgb *RecordGroupBy) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*RecordGroupBy) ScanX

func (s *RecordGroupBy) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*RecordGroupBy) String

func (s *RecordGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) StringX

func (s *RecordGroupBy) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*RecordGroupBy) Strings

func (s *RecordGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*RecordGroupBy) StringsX

func (s *RecordGroupBy) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type RecordListResponse

type RecordListResponse struct {
	Data  []*RecordResponse `json:"data"`
	Total int               `json:"total"`
	Page  int               `json:"page"`
	Size  int               `json:"size"`
}

RecordListResponse is the NAMED, non-generic shape of one list page — for OpenAPI/swaggo-class annotation tooling, which cannot express the generic entapi.Page[RecordResponse] that ListRecords returns. Convert at the handler boundary with NewRecordListResponse. (A fifth field, PageInfo, carried cursor metadata until #6 removed it.)

func NewRecordListResponse

func NewRecordListResponse(p *entapi.Page[RecordResponse]) *RecordListResponse

NewRecordListResponse converts the page ListRecords returns into the named list shape. The conversion expression is the shape contract: if RecordListResponse 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 RecordMutation

type RecordMutation struct {
	// contains filtered or unexported fields
}

RecordMutation represents an operation that mutates the Record nodes in the graph.

func (*RecordMutation) AddField

func (m *RecordMutation) 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 (*RecordMutation) AddScore

func (m *RecordMutation) AddScore(i int)

AddScore adds i to the "score" field.

func (*RecordMutation) AddedEdges

func (m *RecordMutation) AddedEdges() []string

AddedEdges returns all edge names that were set/added in this mutation.

func (*RecordMutation) AddedField

func (m *RecordMutation) 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 (*RecordMutation) AddedFields

func (m *RecordMutation) AddedFields() []string

AddedFields returns all numeric fields that were incremented/decremented during this mutation.

func (*RecordMutation) AddedIDs

func (m *RecordMutation) AddedIDs(name string) []ent.Value

AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.

func (*RecordMutation) AddedScore

func (m *RecordMutation) AddedScore() (r int, exists bool)

AddedScore returns the value that was added to the "score" field in this mutation.

func (*RecordMutation) Body

func (m *RecordMutation) Body() (r string, exists bool)

Body returns the value of the "body" field in the mutation.

func (*RecordMutation) ClearEdge

func (m *RecordMutation) 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 (*RecordMutation) ClearField

func (m *RecordMutation) 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 (*RecordMutation) ClearNote

func (m *RecordMutation) ClearNote()

ClearNote clears the value of the "note" field.

func (*RecordMutation) ClearRef

func (m *RecordMutation) ClearRef()

ClearRef clears the value of the "ref" field.

func (*RecordMutation) ClearScore

func (m *RecordMutation) ClearScore()

ClearScore clears the value of the "score" field.

func (*RecordMutation) ClearedEdges

func (m *RecordMutation) ClearedEdges() []string

ClearedEdges returns all edge names that were cleared in this mutation.

func (*RecordMutation) ClearedFields

func (m *RecordMutation) ClearedFields() []string

ClearedFields returns all nullable fields that were cleared during this mutation.

func (RecordMutation) Client

func (m RecordMutation) 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 (*RecordMutation) CreatedAt

func (m *RecordMutation) CreatedAt() (r time.Time, exists bool)

CreatedAt returns the value of the "created_at" field in the mutation.

func (*RecordMutation) EdgeCleared

func (m *RecordMutation) EdgeCleared(name string) bool

EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.

func (*RecordMutation) Field

func (m *RecordMutation) 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 (*RecordMutation) FieldCleared

func (m *RecordMutation) FieldCleared(name string) bool

FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.

func (*RecordMutation) Fields

func (m *RecordMutation) 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 (*RecordMutation) ID

func (m *RecordMutation) 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 (*RecordMutation) IDs

func (m *RecordMutation) IDs(ctx context.Context) ([]uuid.UUID, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*RecordMutation) Note

func (m *RecordMutation) Note() (r string, exists bool)

Note returns the value of the "note" field in the mutation.

func (*RecordMutation) NoteCleared

func (m *RecordMutation) NoteCleared() bool

NoteCleared returns if the "note" field was cleared in this mutation.

func (*RecordMutation) OldBody

func (m *RecordMutation) OldBody(ctx context.Context) (v string, err error)

OldBody returns the old "body" field's value of the Record entity. If the Record 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 (*RecordMutation) OldCreatedAt

func (m *RecordMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)

OldCreatedAt returns the old "created_at" field's value of the Record entity. If the Record 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 (*RecordMutation) OldField

func (m *RecordMutation) OldField(ctx context.Context, name string) (ent.Value, error)

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 (*RecordMutation) OldNote

func (m *RecordMutation) OldNote(ctx context.Context) (v string, err error)

OldNote returns the old "note" field's value of the Record entity. If the Record 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 (*RecordMutation) OldRef

func (m *RecordMutation) OldRef(ctx context.Context) (v string, err error)

OldRef returns the old "ref" field's value of the Record entity. If the Record 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 (*RecordMutation) OldScore

func (m *RecordMutation) OldScore(ctx context.Context) (v *int, err error)

OldScore returns the old "score" field's value of the Record entity. If the Record 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 (*RecordMutation) OldSecret

func (m *RecordMutation) OldSecret(ctx context.Context) (v string, err error)

OldSecret returns the old "secret" field's value of the Record entity. If the Record 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 (*RecordMutation) OldStatus

func (m *RecordMutation) OldStatus(ctx context.Context) (v record.Status, err error)

OldStatus returns the old "status" field's value of the Record entity. If the Record 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 (*RecordMutation) OldTitle

func (m *RecordMutation) OldTitle(ctx context.Context) (v string, err error)

OldTitle returns the old "title" field's value of the Record entity. If the Record 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 (*RecordMutation) Op

func (m *RecordMutation) Op() Op

Op returns the operation name.

func (*RecordMutation) Ref

func (m *RecordMutation) Ref() (r string, exists bool)

Ref returns the value of the "ref" field in the mutation.

func (*RecordMutation) RefCleared

func (m *RecordMutation) RefCleared() bool

RefCleared returns if the "ref" field was cleared in this mutation.

func (*RecordMutation) RemovedEdges

func (m *RecordMutation) RemovedEdges() []string

RemovedEdges returns all edge names that were removed in this mutation.

func (*RecordMutation) RemovedIDs

func (m *RecordMutation) 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 (*RecordMutation) ResetBody

func (m *RecordMutation) ResetBody()

ResetBody resets all changes to the "body" field.

func (*RecordMutation) ResetCreatedAt

func (m *RecordMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*RecordMutation) ResetEdge

func (m *RecordMutation) 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 (*RecordMutation) ResetField

func (m *RecordMutation) 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 (*RecordMutation) ResetNote

func (m *RecordMutation) ResetNote()

ResetNote resets all changes to the "note" field.

func (*RecordMutation) ResetRef

func (m *RecordMutation) ResetRef()

ResetRef resets all changes to the "ref" field.

func (*RecordMutation) ResetScore

func (m *RecordMutation) ResetScore()

ResetScore resets all changes to the "score" field.

func (*RecordMutation) ResetSecret

func (m *RecordMutation) ResetSecret()

ResetSecret resets all changes to the "secret" field.

func (*RecordMutation) ResetStatus

func (m *RecordMutation) ResetStatus()

ResetStatus resets all changes to the "status" field.

func (*RecordMutation) ResetTitle

func (m *RecordMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*RecordMutation) Score

func (m *RecordMutation) Score() (r int, exists bool)

Score returns the value of the "score" field in the mutation.

func (*RecordMutation) ScoreCleared

func (m *RecordMutation) ScoreCleared() bool

ScoreCleared returns if the "score" field was cleared in this mutation.

func (*RecordMutation) Secret

func (m *RecordMutation) Secret() (r string, exists bool)

Secret returns the value of the "secret" field in the mutation.

func (*RecordMutation) SetBody

func (m *RecordMutation) SetBody(s string)

SetBody sets the "body" field.

func (*RecordMutation) SetCreatedAt

func (m *RecordMutation) SetCreatedAt(t time.Time)

SetCreatedAt sets the "created_at" field.

func (*RecordMutation) SetField

func (m *RecordMutation) 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 (*RecordMutation) SetID

func (m *RecordMutation) SetID(id uuid.UUID)

SetID sets the value of the id field. Note that this operation is only accepted on creation of Record entities.

func (*RecordMutation) SetNote

func (m *RecordMutation) SetNote(s string)

SetNote sets the "note" field.

func (*RecordMutation) SetOp

func (m *RecordMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*RecordMutation) SetRef

func (m *RecordMutation) SetRef(s string)

SetRef sets the "ref" field.

func (*RecordMutation) SetScore

func (m *RecordMutation) SetScore(i int)

SetScore sets the "score" field.

func (*RecordMutation) SetSecret

func (m *RecordMutation) SetSecret(s string)

SetSecret sets the "secret" field.

func (*RecordMutation) SetStatus

func (m *RecordMutation) SetStatus(r record.Status)

SetStatus sets the "status" field.

func (*RecordMutation) SetTitle

func (m *RecordMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*RecordMutation) Status

func (m *RecordMutation) Status() (r record.Status, exists bool)

Status returns the value of the "status" field in the mutation.

func (*RecordMutation) Title

func (m *RecordMutation) Title() (r string, exists bool)

Title returns the value of the "title" field in the mutation.

func (RecordMutation) Tx

func (m RecordMutation) Tx() (*Tx, error)

Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.

func (*RecordMutation) Type

func (m *RecordMutation) Type() string

Type returns the node type of this mutation (Record).

func (*RecordMutation) Where

func (m *RecordMutation) Where(ps ...predicate.Record)

Where appends a list predicates to the RecordMutation builder.

func (*RecordMutation) WhereP

func (m *RecordMutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the RecordMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type RecordPatchRequest

type RecordPatchRequest struct {
	Title  *string        `json:"title,omitempty"`
	Body   *string        `json:"body,omitempty"`
	Ref    *string        `json:"reference,omitempty"`
	Status *record.Status `json:"status,omitempty"`
	Score  *int           `json:"score,omitempty"`
	Note   *string        `json:"note,omitempty"`
	Secret *string        `json:"secret,omitempty"`
	// contains filtered or unexported fields
}

RecordPatchRequest is the partial-update request for Record.

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 (*RecordPatchRequest) HasBody

func (r *RecordPatchRequest) HasBody() bool

HasBody reports whether the payload carried "body".

func (*RecordPatchRequest) HasNote

func (r *RecordPatchRequest) HasNote() bool

HasNote reports whether the payload carried "note".

func (*RecordPatchRequest) HasRef

func (r *RecordPatchRequest) HasRef() bool

HasRef reports whether the payload carried "reference".

func (*RecordPatchRequest) HasScore

func (r *RecordPatchRequest) HasScore() bool

HasScore reports whether the payload carried "score".

func (*RecordPatchRequest) HasSecret

func (r *RecordPatchRequest) HasSecret() bool

HasSecret reports whether the payload carried "secret".

func (*RecordPatchRequest) HasStatus

func (r *RecordPatchRequest) HasStatus() bool

HasStatus reports whether the payload carried "status".

func (*RecordPatchRequest) HasTitle

func (r *RecordPatchRequest) HasTitle() bool

HasTitle reports whether the payload carried "title".

func (*RecordPatchRequest) UnmarshalJSON

func (r *RecordPatchRequest) 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 (*RecordPatchRequest) Validate

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 RecordQuery

type RecordQuery struct {
	// contains filtered or unexported fields
}

RecordQuery is the builder for querying Record entities.

func RecordQueryWithResponseEdges

func RecordQueryWithResponseEdges(q *RecordQuery) *RecordQuery

RecordQueryWithResponseEdges applies the eager-load plan for RecordResponse.

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 NewRecordResponse 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 (*RecordQuery) Aggregate

func (rq *RecordQuery) Aggregate(fns ...AggregateFunc) *RecordSelect

Aggregate returns a RecordSelect configured with the given aggregations.

func (*RecordQuery) All

func (rq *RecordQuery) All(ctx context.Context) ([]*Record, error)

All executes the query and returns a list of Records.

func (*RecordQuery) AllX

func (rq *RecordQuery) AllX(ctx context.Context) []*Record

AllX is like All, but panics if an error occurs.

func (*RecordQuery) Clone

func (rq *RecordQuery) Clone() *RecordQuery

Clone returns a duplicate of the RecordQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.

func (*RecordQuery) Count

func (rq *RecordQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*RecordQuery) CountX

func (rq *RecordQuery) CountX(ctx context.Context) int

CountX is like Count, but panics if an error occurs.

func (*RecordQuery) Exist

func (rq *RecordQuery) Exist(ctx context.Context) (bool, error)

Exist returns true if the query has elements in the graph.

func (*RecordQuery) ExistX

func (rq *RecordQuery) ExistX(ctx context.Context) bool

ExistX is like Exist, but panics if an error occurs.

func (*RecordQuery) First

func (rq *RecordQuery) First(ctx context.Context) (*Record, error)

First returns the first Record entity from the query. Returns a *NotFoundError when no Record was found.

func (*RecordQuery) FirstID

func (rq *RecordQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

FirstID returns the first Record ID from the query. Returns a *NotFoundError when no Record ID was found.

func (*RecordQuery) FirstIDX

func (rq *RecordQuery) FirstIDX(ctx context.Context) uuid.UUID

FirstIDX is like FirstID, but panics if an error occurs.

func (*RecordQuery) FirstX

func (rq *RecordQuery) FirstX(ctx context.Context) *Record

FirstX is like First, but panics if an error occurs.

func (*RecordQuery) GroupBy

func (rq *RecordQuery) GroupBy(field string, fields ...string) *RecordGroupBy

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 {
	Title string `json:"title,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Record.Query().
	GroupBy(record.FieldTitle).
	Aggregate(queryent.Count()).
	Scan(ctx, &v)

func (*RecordQuery) IDs

func (rq *RecordQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error)

IDs executes the query and returns a list of Record IDs.

func (*RecordQuery) IDsX

func (rq *RecordQuery) IDsX(ctx context.Context) []uuid.UUID

IDsX is like IDs, but panics if an error occurs.

func (*RecordQuery) Limit

func (rq *RecordQuery) Limit(limit int) *RecordQuery

Limit the number of records to be returned by this query.

func (*RecordQuery) Offset

func (rq *RecordQuery) Offset(offset int) *RecordQuery

Offset to start from.

func (*RecordQuery) Only

func (rq *RecordQuery) Only(ctx context.Context) (*Record, error)

Only returns a single Record entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Record entity is found. Returns a *NotFoundError when no Record entities are found.

func (*RecordQuery) OnlyID

func (rq *RecordQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

OnlyID is like Only, but returns the only Record ID in the query. Returns a *NotSingularError when more than one Record ID is found. Returns a *NotFoundError when no entities are found.

func (*RecordQuery) OnlyIDX

func (rq *RecordQuery) OnlyIDX(ctx context.Context) uuid.UUID

OnlyIDX is like OnlyID, but panics if an error occurs.

func (*RecordQuery) OnlyX

func (rq *RecordQuery) OnlyX(ctx context.Context) *Record

OnlyX is like Only, but panics if an error occurs.

func (*RecordQuery) Order

func (rq *RecordQuery) Order(o ...record.OrderOption) *RecordQuery

Order specifies how the records should be ordered.

func (*RecordQuery) Select

func (rq *RecordQuery) Select(fields ...string) *RecordSelect

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 {
	Title string `json:"title,omitempty"`
}

client.Record.Query().
	Select(record.FieldTitle).
	Scan(ctx, &v)

func (*RecordQuery) Unique

func (rq *RecordQuery) Unique(unique bool) *RecordQuery

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 (*RecordQuery) Where

func (rq *RecordQuery) Where(ps ...predicate.Record) *RecordQuery

Where adds a new predicate for the RecordQuery builder.

type RecordResponse

type RecordResponse struct {
	// ID field is always included in responses
	ID        uuid.UUID     `json:"id"`
	Title     string        `json:"title"`
	Body      string        `json:"body"`
	Ref       *string       `json:"reference,omitempty"`
	Status    record.Status `json:"status"`
	Score     *int          `json:"score,omitempty"`
	CreatedAt time.Time     `json:"created_at"`
	Note      *string       `json:"note,omitempty"`
}

RecordResponse represents the response for Record.

It is emitted unconditionally: an entity whose every scalar field is Sensitive still has a meaningful response carrying its ID, and RecordListResponse below refers to this type either way.

func CreateRecord

func CreateRecord(ctx context.Context, db *Client, v *ValidRecordCreateRequest) (*RecordResponse, error)

CreateRecord inserts one Record 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 GetRecord

func GetRecord(ctx context.Context, db *Client, id uuid.UUID) (*RecordResponse, error)

GetRecord reads one Record and converts it to its response.

func NewRecordResponse

func NewRecordResponse(e *Record) (*RecordResponse, error)

NewRecordResponse 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 PatchRecord

func PatchRecord(ctx context.Context, db *Client, id uuid.UUID, v *ValidRecordPatchRequest) (*RecordResponse, error)

PatchRecord applies a validated patch to one Record.

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 RecordSelect

type RecordSelect struct {
	*RecordQuery
	// contains filtered or unexported fields
}

RecordSelect is the builder for selecting fields of Record entities.

func (*RecordSelect) Aggregate

func (rs *RecordSelect) Aggregate(fns ...AggregateFunc) *RecordSelect

Aggregate adds the given aggregation functions to the selector query.

func (*RecordSelect) Bool

func (s *RecordSelect) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*RecordSelect) BoolX

func (s *RecordSelect) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*RecordSelect) Bools

func (s *RecordSelect) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*RecordSelect) BoolsX

func (s *RecordSelect) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*RecordSelect) Float64

func (s *RecordSelect) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*RecordSelect) Float64X

func (s *RecordSelect) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*RecordSelect) Float64s

func (s *RecordSelect) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*RecordSelect) Float64sX

func (s *RecordSelect) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*RecordSelect) Int

func (s *RecordSelect) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*RecordSelect) IntX

func (s *RecordSelect) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*RecordSelect) Ints

func (s *RecordSelect) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*RecordSelect) IntsX

func (s *RecordSelect) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*RecordSelect) Scan

func (rs *RecordSelect) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*RecordSelect) ScanX

func (s *RecordSelect) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*RecordSelect) String

func (s *RecordSelect) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*RecordSelect) StringX

func (s *RecordSelect) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*RecordSelect) Strings

func (s *RecordSelect) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*RecordSelect) StringsX

func (s *RecordSelect) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type RecordSummary

type RecordSummary struct {
	// ID field is always included in summaries
	ID        uuid.UUID     `json:"id"`
	Title     string        `json:"title"`
	Body      string        `json:"body"`
	Ref       *string       `json:"reference,omitempty"`
	Status    record.Status `json:"status"`
	Score     *int          `json:"score,omitempty"`
	CreatedAt time.Time     `json:"created_at"`
	Note      *string       `json:"note,omitempty"`
}

RecordSummary is the shape Record takes on another entity's response.

It carries the same scalar fields as RecordResponse and no edges at all. That is what bounds expansion: NewRecordResponse 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 NewRecordSummary

func NewRecordSummary(e *Record) *RecordSummary

NewRecordSummary converts an entity to its summary DTO. It cannot fail: a summary reads no edges.

type RecordUpdate

type RecordUpdate struct {
	// contains filtered or unexported fields
}

RecordUpdate is the builder for updating Record entities.

func (*RecordUpdate) AddScore

func (ru *RecordUpdate) AddScore(i int) *RecordUpdate

AddScore adds i to the "score" field.

func (*RecordUpdate) ClearNote

func (ru *RecordUpdate) ClearNote() *RecordUpdate

ClearNote clears the value of the "note" field.

func (*RecordUpdate) ClearRef

func (ru *RecordUpdate) ClearRef() *RecordUpdate

ClearRef clears the value of the "ref" field.

func (*RecordUpdate) ClearScore

func (ru *RecordUpdate) ClearScore() *RecordUpdate

ClearScore clears the value of the "score" field.

func (*RecordUpdate) Exec

func (ru *RecordUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*RecordUpdate) ExecX

func (ru *RecordUpdate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*RecordUpdate) Mutation

func (ru *RecordUpdate) Mutation() *RecordMutation

Mutation returns the RecordMutation object of the builder.

func (*RecordUpdate) Save

func (ru *RecordUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of nodes affected by the update operation.

func (*RecordUpdate) SaveX

func (ru *RecordUpdate) SaveX(ctx context.Context) int

SaveX is like Save, but panics if an error occurs.

func (*RecordUpdate) SetBody

func (ru *RecordUpdate) SetBody(s string) *RecordUpdate

SetBody sets the "body" field.

func (*RecordUpdate) SetNillableBody

func (ru *RecordUpdate) SetNillableBody(s *string) *RecordUpdate

SetNillableBody sets the "body" field if the given value is not nil.

func (*RecordUpdate) SetNillableNote

func (ru *RecordUpdate) SetNillableNote(s *string) *RecordUpdate

SetNillableNote sets the "note" field if the given value is not nil.

func (*RecordUpdate) SetNillableRef

func (ru *RecordUpdate) SetNillableRef(s *string) *RecordUpdate

SetNillableRef sets the "ref" field if the given value is not nil.

func (*RecordUpdate) SetNillableScore

func (ru *RecordUpdate) SetNillableScore(i *int) *RecordUpdate

SetNillableScore sets the "score" field if the given value is not nil.

func (*RecordUpdate) SetNillableSecret

func (ru *RecordUpdate) SetNillableSecret(s *string) *RecordUpdate

SetNillableSecret sets the "secret" field if the given value is not nil.

func (*RecordUpdate) SetNillableStatus

func (ru *RecordUpdate) SetNillableStatus(r *record.Status) *RecordUpdate

SetNillableStatus sets the "status" field if the given value is not nil.

func (*RecordUpdate) SetNillableTitle

func (ru *RecordUpdate) SetNillableTitle(s *string) *RecordUpdate

SetNillableTitle sets the "title" field if the given value is not nil.

func (*RecordUpdate) SetNote

func (ru *RecordUpdate) SetNote(s string) *RecordUpdate

SetNote sets the "note" field.

func (*RecordUpdate) SetRef

func (ru *RecordUpdate) SetRef(s string) *RecordUpdate

SetRef sets the "ref" field.

func (*RecordUpdate) SetScore

func (ru *RecordUpdate) SetScore(i int) *RecordUpdate

SetScore sets the "score" field.

func (*RecordUpdate) SetSecret

func (ru *RecordUpdate) SetSecret(s string) *RecordUpdate

SetSecret sets the "secret" field.

func (*RecordUpdate) SetStatus

func (ru *RecordUpdate) SetStatus(r record.Status) *RecordUpdate

SetStatus sets the "status" field.

func (*RecordUpdate) SetTitle

func (ru *RecordUpdate) SetTitle(s string) *RecordUpdate

SetTitle sets the "title" field.

func (*RecordUpdate) Where

func (ru *RecordUpdate) Where(ps ...predicate.Record) *RecordUpdate

Where appends a list predicates to the RecordUpdate builder.

type RecordUpdateOne

type RecordUpdateOne struct {
	// contains filtered or unexported fields
}

RecordUpdateOne is the builder for updating a single Record entity.

func (*RecordUpdateOne) AddScore

func (ruo *RecordUpdateOne) AddScore(i int) *RecordUpdateOne

AddScore adds i to the "score" field.

func (*RecordUpdateOne) ClearNote

func (ruo *RecordUpdateOne) ClearNote() *RecordUpdateOne

ClearNote clears the value of the "note" field.

func (*RecordUpdateOne) ClearRef

func (ruo *RecordUpdateOne) ClearRef() *RecordUpdateOne

ClearRef clears the value of the "ref" field.

func (*RecordUpdateOne) ClearScore

func (ruo *RecordUpdateOne) ClearScore() *RecordUpdateOne

ClearScore clears the value of the "score" field.

func (*RecordUpdateOne) Exec

func (ruo *RecordUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*RecordUpdateOne) ExecX

func (ruo *RecordUpdateOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*RecordUpdateOne) Mutation

func (ruo *RecordUpdateOne) Mutation() *RecordMutation

Mutation returns the RecordMutation object of the builder.

func (*RecordUpdateOne) Save

func (ruo *RecordUpdateOne) Save(ctx context.Context) (*Record, error)

Save executes the query and returns the updated Record entity.

func (*RecordUpdateOne) SaveX

func (ruo *RecordUpdateOne) SaveX(ctx context.Context) *Record

SaveX is like Save, but panics if an error occurs.

func (*RecordUpdateOne) Select

func (ruo *RecordUpdateOne) Select(field string, fields ...string) *RecordUpdateOne

Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.

func (*RecordUpdateOne) SetBody

func (ruo *RecordUpdateOne) SetBody(s string) *RecordUpdateOne

SetBody sets the "body" field.

func (*RecordUpdateOne) SetNillableBody

func (ruo *RecordUpdateOne) SetNillableBody(s *string) *RecordUpdateOne

SetNillableBody sets the "body" field if the given value is not nil.

func (*RecordUpdateOne) SetNillableNote

func (ruo *RecordUpdateOne) SetNillableNote(s *string) *RecordUpdateOne

SetNillableNote sets the "note" field if the given value is not nil.

func (*RecordUpdateOne) SetNillableRef

func (ruo *RecordUpdateOne) SetNillableRef(s *string) *RecordUpdateOne

SetNillableRef sets the "ref" field if the given value is not nil.

func (*RecordUpdateOne) SetNillableScore

func (ruo *RecordUpdateOne) SetNillableScore(i *int) *RecordUpdateOne

SetNillableScore sets the "score" field if the given value is not nil.

func (*RecordUpdateOne) SetNillableSecret

func (ruo *RecordUpdateOne) SetNillableSecret(s *string) *RecordUpdateOne

SetNillableSecret sets the "secret" field if the given value is not nil.

func (*RecordUpdateOne) SetNillableStatus

func (ruo *RecordUpdateOne) SetNillableStatus(r *record.Status) *RecordUpdateOne

SetNillableStatus sets the "status" field if the given value is not nil.

func (*RecordUpdateOne) SetNillableTitle

func (ruo *RecordUpdateOne) SetNillableTitle(s *string) *RecordUpdateOne

SetNillableTitle sets the "title" field if the given value is not nil.

func (*RecordUpdateOne) SetNote

func (ruo *RecordUpdateOne) SetNote(s string) *RecordUpdateOne

SetNote sets the "note" field.

func (*RecordUpdateOne) SetRef

func (ruo *RecordUpdateOne) SetRef(s string) *RecordUpdateOne

SetRef sets the "ref" field.

func (*RecordUpdateOne) SetScore

func (ruo *RecordUpdateOne) SetScore(i int) *RecordUpdateOne

SetScore sets the "score" field.

func (*RecordUpdateOne) SetSecret

func (ruo *RecordUpdateOne) SetSecret(s string) *RecordUpdateOne

SetSecret sets the "secret" field.

func (*RecordUpdateOne) SetStatus

func (ruo *RecordUpdateOne) SetStatus(r record.Status) *RecordUpdateOne

SetStatus sets the "status" field.

func (*RecordUpdateOne) SetTitle

func (ruo *RecordUpdateOne) SetTitle(s string) *RecordUpdateOne

SetTitle sets the "title" field.

func (*RecordUpdateOne) Where

func (ruo *RecordUpdateOne) Where(ps ...predicate.Record) *RecordUpdateOne

Where appends a list predicates to the RecordUpdate builder.

type Records

type Records []*Record

Records is a parsable slice of Record.

type RollbackFunc

type RollbackFunc func(context.Context, *Tx) error

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.

func (RollbackFunc) Rollback

func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error

Rollback calls f(ctx, m).

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

type Rollbacker interface {
	Rollback(context.Context, *Tx) error
}

Rollbacker is the interface that wraps the Rollback method.

type TraverseFunc

type TraverseFunc = ent.TraverseFunc

ent aliases to avoid import conflicts in user's code.

type Traverser

type Traverser = ent.Traverser

ent aliases to avoid import conflicts in user's code.

type Tx

type Tx struct {

	// Plain is the client for interacting with the Plain builders.
	Plain *PlainClient
	// Record is the client for interacting with the Record builders.
	Record *RecordClient
	// contains filtered or unexported fields
}

Tx is a transactional client that is created by calling Client.Tx().

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

TxFromContext returns a Tx stored inside a context, or nil if there isn't one.

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidPlainCreateRequest

type ValidPlainCreateRequest struct {
	// contains filtered or unexported fields
}

ValidPlainCreateRequest wraps a PlainCreateRequest 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 (*ValidPlainCreateRequest) Apply

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 (*ValidPlainCreateRequest) HasLabel

func (v *ValidPlainCreateRequest) HasLabel() bool

HasLabel reports whether the payload carried "label".

type ValidPlainPatchRequest

type ValidPlainPatchRequest struct {
	// contains filtered or unexported fields
}

ValidPlainPatchRequest wraps a PlainPatchRequest that has passed Validate. It is the only type Apply is defined on.

func (*ValidPlainPatchRequest) Apply

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 (*ValidPlainPatchRequest) HasLabel

func (v *ValidPlainPatchRequest) HasLabel() bool

HasLabel reports whether the payload carried "label".

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 (*ValidPlainPatchRequest) Label

func (v *ValidPlainPatchRequest) Label() (string, bool)

Label reports the value the payload carried for "label", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasLabel(), 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 ValidRecordCreateRequest

type ValidRecordCreateRequest struct {
	// contains filtered or unexported fields
}

ValidRecordCreateRequest wraps a RecordCreateRequest 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 (*ValidRecordCreateRequest) Apply

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 (*ValidRecordCreateRequest) HasBody

func (v *ValidRecordCreateRequest) HasBody() bool

HasBody reports whether the payload carried "body".

func (*ValidRecordCreateRequest) HasNote

func (v *ValidRecordCreateRequest) HasNote() bool

HasNote reports whether the payload carried "note".

func (*ValidRecordCreateRequest) HasRef

func (v *ValidRecordCreateRequest) HasRef() bool

HasRef reports whether the payload carried "reference".

func (*ValidRecordCreateRequest) HasScore

func (v *ValidRecordCreateRequest) HasScore() bool

HasScore reports whether the payload carried "score".

func (*ValidRecordCreateRequest) HasSecret

func (v *ValidRecordCreateRequest) HasSecret() bool

HasSecret reports whether the payload carried "secret".

func (*ValidRecordCreateRequest) HasStatus

func (v *ValidRecordCreateRequest) HasStatus() bool

HasStatus reports whether the payload carried "status".

func (*ValidRecordCreateRequest) HasTitle

func (v *ValidRecordCreateRequest) HasTitle() bool

HasTitle reports whether the payload carried "title".

type ValidRecordPatchRequest

type ValidRecordPatchRequest struct {
	// contains filtered or unexported fields
}

ValidRecordPatchRequest wraps a RecordPatchRequest that has passed Validate. It is the only type Apply is defined on.

func (*ValidRecordPatchRequest) Apply

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 (*ValidRecordPatchRequest) Body

func (v *ValidRecordPatchRequest) Body() (string, bool)

Body reports the value the payload carried for "body", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasBody(), 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 (*ValidRecordPatchRequest) HasBody

func (v *ValidRecordPatchRequest) HasBody() bool

HasBody reports whether the payload carried "body".

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 (*ValidRecordPatchRequest) HasNote

func (v *ValidRecordPatchRequest) HasNote() bool

HasNote reports whether the payload carried "note".

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 (*ValidRecordPatchRequest) HasRef

func (v *ValidRecordPatchRequest) HasRef() bool

HasRef reports whether the payload carried "reference".

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 (*ValidRecordPatchRequest) HasScore

func (v *ValidRecordPatchRequest) HasScore() bool

HasScore reports whether the payload carried "score".

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 (*ValidRecordPatchRequest) HasSecret

func (v *ValidRecordPatchRequest) HasSecret() bool

HasSecret reports whether the payload carried "secret".

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 (*ValidRecordPatchRequest) HasStatus

func (v *ValidRecordPatchRequest) HasStatus() bool

HasStatus reports whether the payload carried "status".

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 (*ValidRecordPatchRequest) HasTitle

func (v *ValidRecordPatchRequest) HasTitle() bool

HasTitle reports whether the payload carried "title".

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 (*ValidRecordPatchRequest) Note

func (v *ValidRecordPatchRequest) Note() (string, bool)

Note reports the value the payload carried for "note", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasNote(), 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 (*ValidRecordPatchRequest) Ref

func (v *ValidRecordPatchRequest) Ref() (string, bool)

Ref reports the value the payload carried for "reference", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasRef(), 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 (*ValidRecordPatchRequest) Score

func (v *ValidRecordPatchRequest) Score() (int, bool)

Score reports the value the payload carried for "score", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasScore(), 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 (*ValidRecordPatchRequest) Secret

func (v *ValidRecordPatchRequest) Secret() (string, bool)

Secret reports the value the payload carried for "secret", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasSecret(), 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 (*ValidRecordPatchRequest) Status

func (v *ValidRecordPatchRequest) Status() (record.Status, bool)

Status reports the value the payload carried for "status", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasStatus(), 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 (*ValidRecordPatchRequest) Title

func (v *ValidRecordPatchRequest) Title() (string, bool)

Title reports the value the payload carried for "title", and whether Apply will Set it.

Presence is two of the three states a PATCH field has; this reads the third. Paired with HasTitle(), 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.

type Value

type Value = ent.Value

ent aliases to avoid import conflicts in user's code.

Directories

Path Synopsis
Package schema holds the hand-written ent schemas for the "query" codegen fixture: the field shapes the filter, free-text search and sort allow-list generation is derived from (#27).
Package schema holds the hand-written ent schemas for the "query" codegen fixture: the field shapes the filter, free-text search and sort allow-list generation is derived from (#27).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL