ent

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 26 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.
	TypePost = "Post"
	TypeTag  = "Tag"
	TypeUser = "User"
)

Variables

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

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

UserFIQLFields is the FIQL field registry for User. Pass it to entdomain.ParseFIQL to filter User entities.

Functions

func Asc

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

Asc applies the given fields in ASC order.

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 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 UserFIQL

func UserFIQL(expr string) (predicate.User, error)

UserFIQL parses a FIQL filter expression and returns an ent predicate for querying User entities.

Example:

pred, err := ent.UserFIQL("name==john;age=gt=25")
users, err := client.User.Query().Where(pred).All(ctx)

Types

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(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
Scan(ctx, &v)

func Count

func Count() AggregateFunc

Count applies the "count" aggregation function on each group.

func Max

func Max(field string) AggregateFunc

Max applies the "max" aggregation function on the given field of each group.

func Mean

func Mean(field string) AggregateFunc

Mean applies the "mean" aggregation function on the given field of each group.

func Min

func Min(field string) AggregateFunc

Min applies the "min" aggregation function on the given field of each group.

func Sum

func Sum(field string) AggregateFunc

Sum applies the "sum" aggregation function on the given field of each group.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Post is the client for interacting with the Post builders.
	Post *PostClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// 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().
	Post.
	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 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 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 Policy

type Policy = ent.Policy

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

type Post

type Post struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Published holds the value of the "published" field.
	Published bool `json:"published,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the PostQuery when eager-loading is set.
	Edges PostEdges `json:"edges"`
	// contains filtered or unexported fields
}

Post is the model entity for the Post schema.

func (*Post) QueryOwner

func (_m *Post) QueryOwner() *UserQuery

QueryOwner queries the "owner" edge of the Post entity.

func (*Post) QueryPinners

func (_m *Post) QueryPinners() *UserQuery

QueryPinners queries the "pinners" edge of the Post entity.

func (*Post) String

func (_m *Post) String() string

String implements the fmt.Stringer.

func (*Post) ToDomain

func (e *Post) ToDomain() *domain.Post

ToDomain maps the ent Post to a domain.Post.

func (*Post) Unwrap

func (_m *Post) Unwrap() *Post

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

func (_m *Post) Update() *PostUpdateOne

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

func (*Post) Value

func (_m *Post) Value(name string) (ent.Value, error)

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

type PostClient

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

PostClient is a client for the Post schema.

func NewPostClient

func NewPostClient(c config) *PostClient

NewPostClient returns a client for the Post from the given config.

func (*PostClient) Create

func (c *PostClient) Create() *PostCreate

Create returns a builder for creating a Post entity.

func (*PostClient) CreateBulk

func (c *PostClient) CreateBulk(builders ...*PostCreate) *PostCreateBulk

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

func (*PostClient) Delete

func (c *PostClient) Delete() *PostDelete

Delete returns a delete builder for Post.

func (*PostClient) DeleteOne

func (c *PostClient) DeleteOne(_m *Post) *PostDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*PostClient) DeleteOneID

func (c *PostClient) DeleteOneID(id int) *PostDeleteOne

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

func (*PostClient) Get

func (c *PostClient) Get(ctx context.Context, id int) (*Post, error)

Get returns a Post entity by its id.

func (*PostClient) GetX

func (c *PostClient) GetX(ctx context.Context, id int) *Post

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

func (*PostClient) Hooks

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

Hooks returns the client hooks.

func (*PostClient) Intercept

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

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

func (*PostClient) Interceptors

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

Interceptors returns the client interceptors.

func (*PostClient) MapCreateBulk

func (c *PostClient) MapCreateBulk(slice any, setFunc func(*PostCreate, int)) *PostCreateBulk

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

func (c *PostClient) Query() *PostQuery

Query returns a query builder for Post.

func (*PostClient) QueryOwner

func (c *PostClient) QueryOwner(_m *Post) *UserQuery

QueryOwner queries the owner edge of a Post.

func (*PostClient) QueryPinners

func (c *PostClient) QueryPinners(_m *Post) *UserQuery

QueryPinners queries the pinners edge of a Post.

func (*PostClient) Update

func (c *PostClient) Update() *PostUpdate

Update returns an update builder for Post.

func (*PostClient) UpdateOne

func (c *PostClient) UpdateOne(_m *Post) *PostUpdateOne

UpdateOne returns an update builder for the given entity.

func (*PostClient) UpdateOneID

func (c *PostClient) UpdateOneID(id int) *PostUpdateOne

UpdateOneID returns an update builder for the given id.

func (*PostClient) Use

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

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

type PostCreate

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

PostCreate is the builder for creating a Post entity.

func (*PostCreate) AddPinnerIDs

func (_c *PostCreate) AddPinnerIDs(ids ...int) *PostCreate

AddPinnerIDs adds the "pinners" edge to the User entity by IDs.

func (*PostCreate) AddPinners

func (_c *PostCreate) AddPinners(v ...*User) *PostCreate

AddPinners adds the "pinners" edges to the User entity.

func (*PostCreate) ApplyDomain

func (c *PostCreate) ApplyDomain(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) (*PostCreate, error)

ApplyDomain applies domain.Post fields to the PostCreate builder.

func (*PostCreate) ApplyDomainX

func (c *PostCreate) ApplyDomainX(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) *PostCreate

ApplyDomainX is the panicking variant of ApplyDomain. It enables fluent chaining at the cost of converting transformer errors into panics. Mirrors ent's SaveX/FirstX/OnlyX convention: use in tests and scripts, prefer ApplyDomain on request paths where transformer errors (e.g. KMS failures) must be recoverable.

func (*PostCreate) Exec

func (_c *PostCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*PostCreate) ExecX

func (_c *PostCreate) ExecX(ctx context.Context)

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

func (*PostCreate) Mutation

func (_c *PostCreate) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostCreate) OnConflict

func (_c *PostCreate) OnConflict(opts ...sql.ConflictOption) *PostUpsertOne

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.Post.Create().
	SetTitle(v).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.PostUpsert) {
		SetTitle(v+v).
	}).
	Exec(ctx)

func (*PostCreate) OnConflictColumns

func (_c *PostCreate) OnConflictColumns(columns ...string) *PostUpsertOne

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.Post.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*PostCreate) Save

func (_c *PostCreate) Save(ctx context.Context) (*Post, error)

Save creates the Post in the database.

func (*PostCreate) SaveX

func (_c *PostCreate) SaveX(ctx context.Context) *Post

SaveX calls Save and panics if Save returns an error.

func (*PostCreate) SetNillableOwnerID

func (_c *PostCreate) SetNillableOwnerID(id *int) *PostCreate

SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil.

func (*PostCreate) SetNillablePublished

func (_c *PostCreate) SetNillablePublished(v *bool) *PostCreate

SetNillablePublished sets the "published" field if the given value is not nil.

func (*PostCreate) SetOwner

func (_c *PostCreate) SetOwner(v *User) *PostCreate

SetOwner sets the "owner" edge to the User entity.

func (*PostCreate) SetOwnerID

func (_c *PostCreate) SetOwnerID(id int) *PostCreate

SetOwnerID sets the "owner" edge to the User entity by ID.

func (*PostCreate) SetPublished

func (_c *PostCreate) SetPublished(v bool) *PostCreate

SetPublished sets the "published" field.

func (*PostCreate) SetTitle

func (_c *PostCreate) SetTitle(v string) *PostCreate

SetTitle sets the "title" field.

type PostCreateBulk

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

PostCreateBulk is the builder for creating many Post entities in bulk.

func (*PostCreateBulk) Exec

func (_c *PostCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*PostCreateBulk) ExecX

func (_c *PostCreateBulk) ExecX(ctx context.Context)

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

func (*PostCreateBulk) OnConflict

func (_c *PostCreateBulk) OnConflict(opts ...sql.ConflictOption) *PostUpsertBulk

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.Post.CreateBulk(builders...).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.PostUpsert) {
		SetTitle(v+v).
	}).
	Exec(ctx)

func (*PostCreateBulk) OnConflictColumns

func (_c *PostCreateBulk) OnConflictColumns(columns ...string) *PostUpsertBulk

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.Post.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*PostCreateBulk) Save

func (_c *PostCreateBulk) Save(ctx context.Context) ([]*Post, error)

Save creates the Post entities in the database.

func (*PostCreateBulk) SaveX

func (_c *PostCreateBulk) SaveX(ctx context.Context) []*Post

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

type PostDelete

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

PostDelete is the builder for deleting a Post entity.

func (*PostDelete) Exec

func (_d *PostDelete) Exec(ctx context.Context) (int, error)

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

func (*PostDelete) ExecX

func (_d *PostDelete) ExecX(ctx context.Context) int

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

func (*PostDelete) Where

func (_d *PostDelete) Where(ps ...predicate.Post) *PostDelete

Where appends a list predicates to the PostDelete builder.

type PostDeleteOne

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

PostDeleteOne is the builder for deleting a single Post entity.

func (*PostDeleteOne) Exec

func (_d *PostDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*PostDeleteOne) ExecX

func (_d *PostDeleteOne) ExecX(ctx context.Context)

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

func (*PostDeleteOne) Where

func (_d *PostDeleteOne) Where(ps ...predicate.Post) *PostDeleteOne

Where appends a list predicates to the PostDelete builder.

type PostDomainField

type PostDomainField = string

PostDomainField is the type for Post domain field constants.

const (
	PostDomainFieldTitle     PostDomainField = "title"
	PostDomainFieldPublished PostDomainField = "published"
	PostDomainFieldOwnerID   PostDomainField = "owner_id"
	PostDomainFieldPinnerIDs PostDomainField = "pinner_ids"
)

type PostDomainTransformer

type PostDomainTransformer struct {
}

PostDomainTransformer holds optional transformer functions for Post → domain mapping.

Get* functions are pure synchronous projections invoked by ToDomain. Set*OnCreate / Set*OnUpdate are invoked during ApplyDomain and may perform I/O (e.g. KMS-backed field encryption); they receive ctx + the full domain struct so they can access sibling fields and propagate cancellation.

var PostTransformer *PostDomainTransformer

PostTransformer is the package-level transformer for Post (nil by default).

type PostEdges

type PostEdges struct {
	// Owner holds the value of the owner edge.
	Owner *User `json:"owner,omitempty"`
	// Pinners holds the value of the pinners edge.
	Pinners []*User `json:"pinners,omitempty"`
	// contains filtered or unexported fields
}

PostEdges holds the relations/edges for other nodes in the graph.

func (PostEdges) OwnerOrErr

func (e PostEdges) OwnerOrErr() (*User, error)

OwnerOrErr returns the Owner value or an error if the edge was not loaded in eager-loading, or loaded but was not found.

func (PostEdges) PinnersOrErr

func (e PostEdges) PinnersOrErr() ([]*User, error)

PinnersOrErr returns the Pinners value or an error if the edge was not loaded in eager-loading.

type PostGroupBy

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

PostGroupBy is the group-by builder for Post entities.

func (*PostGroupBy) Aggregate

func (_g *PostGroupBy) Aggregate(fns ...AggregateFunc) *PostGroupBy

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

func (*PostGroupBy) Bool

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

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

func (*PostGroupBy) BoolX

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

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

func (*PostGroupBy) Bools

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

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

func (*PostGroupBy) BoolsX

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

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

func (*PostGroupBy) Float64

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

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

func (*PostGroupBy) Float64X

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

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

func (*PostGroupBy) Float64s

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

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

func (*PostGroupBy) Float64sX

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

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

func (*PostGroupBy) Int

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

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

func (*PostGroupBy) IntX

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

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

func (*PostGroupBy) Ints

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

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

func (*PostGroupBy) IntsX

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

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

func (*PostGroupBy) Scan

func (_g *PostGroupBy) Scan(ctx context.Context, v any) error

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

func (*PostGroupBy) ScanX

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

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

func (*PostGroupBy) String

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

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

func (*PostGroupBy) StringX

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

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

func (*PostGroupBy) Strings

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

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

func (*PostGroupBy) StringsX

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

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

type PostMutation

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

PostMutation represents an operation that mutates the Post nodes in the graph.

func (*PostMutation) AddField

func (m *PostMutation) 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 (*PostMutation) AddPinnerIDs

func (m *PostMutation) AddPinnerIDs(ids ...int)

AddPinnerIDs adds the "pinners" edge to the User entity by ids.

func (*PostMutation) AddedEdges

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

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

func (*PostMutation) AddedField

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

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

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

func (*PostMutation) AddedIDs

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

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

func (*PostMutation) ClearEdge

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

func (m *PostMutation) 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 (*PostMutation) ClearOwner

func (m *PostMutation) ClearOwner()

ClearOwner clears the "owner" edge to the User entity.

func (*PostMutation) ClearPinners

func (m *PostMutation) ClearPinners()

ClearPinners clears the "pinners" edge to the User entity.

func (*PostMutation) ClearedEdges

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

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

func (*PostMutation) ClearedFields

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

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

func (PostMutation) Client

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

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

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

func (*PostMutation) Field

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

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

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

func (*PostMutation) Fields

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

func (m *PostMutation) ID() (id int, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.

func (*PostMutation) IDs

func (m *PostMutation) IDs(ctx context.Context) ([]int, error)

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

func (*PostMutation) OldField

func (m *PostMutation) 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 (*PostMutation) OldPublished

func (m *PostMutation) OldPublished(ctx context.Context) (v bool, err error)

OldPublished returns the old "published" field's value of the Post entity. If the Post 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 (*PostMutation) OldTitle

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

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

func (m *PostMutation) Op() Op

Op returns the operation name.

func (*PostMutation) OwnerCleared

func (m *PostMutation) OwnerCleared() bool

OwnerCleared reports if the "owner" edge to the User entity was cleared.

func (*PostMutation) OwnerID

func (m *PostMutation) OwnerID() (id int, exists bool)

OwnerID returns the "owner" edge ID in the mutation.

func (*PostMutation) OwnerIDs

func (m *PostMutation) OwnerIDs() (ids []int)

OwnerIDs returns the "owner" edge IDs in the mutation. Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use OwnerID instead. It exists only for internal usage by the builders.

func (*PostMutation) PinnersCleared

func (m *PostMutation) PinnersCleared() bool

PinnersCleared reports if the "pinners" edge to the User entity was cleared.

func (*PostMutation) PinnersIDs

func (m *PostMutation) PinnersIDs() (ids []int)

PinnersIDs returns the "pinners" edge IDs in the mutation.

func (*PostMutation) Published

func (m *PostMutation) Published() (r bool, exists bool)

Published returns the value of the "published" field in the mutation.

func (*PostMutation) RemovePinnerIDs

func (m *PostMutation) RemovePinnerIDs(ids ...int)

RemovePinnerIDs removes the "pinners" edge to the User entity by IDs.

func (*PostMutation) RemovedEdges

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

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

func (*PostMutation) RemovedIDs

func (m *PostMutation) 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 (*PostMutation) RemovedPinnersIDs

func (m *PostMutation) RemovedPinnersIDs() (ids []int)

RemovedPinners returns the removed IDs of the "pinners" edge to the User entity.

func (*PostMutation) ResetEdge

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

func (m *PostMutation) 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 (*PostMutation) ResetOwner

func (m *PostMutation) ResetOwner()

ResetOwner resets all changes to the "owner" edge.

func (*PostMutation) ResetPinners

func (m *PostMutation) ResetPinners()

ResetPinners resets all changes to the "pinners" edge.

func (*PostMutation) ResetPublished

func (m *PostMutation) ResetPublished()

ResetPublished resets all changes to the "published" field.

func (*PostMutation) ResetTitle

func (m *PostMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*PostMutation) SetField

func (m *PostMutation) 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 (*PostMutation) SetOp

func (m *PostMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*PostMutation) SetOwnerID

func (m *PostMutation) SetOwnerID(id int)

SetOwnerID sets the "owner" edge to the User entity by id.

func (*PostMutation) SetPublished

func (m *PostMutation) SetPublished(b bool)

SetPublished sets the "published" field.

func (*PostMutation) SetTitle

func (m *PostMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*PostMutation) Title

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

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

func (PostMutation) Tx

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

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

func (*PostMutation) Type

func (m *PostMutation) Type() string

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

func (*PostMutation) Where

func (m *PostMutation) Where(ps ...predicate.Post)

Where appends a list predicates to the PostMutation builder.

func (*PostMutation) WhereP

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

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

type PostQuery

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

PostQuery is the builder for querying Post entities.

func (*PostQuery) Aggregate

func (_q *PostQuery) Aggregate(fns ...AggregateFunc) *PostSelect

Aggregate returns a PostSelect configured with the given aggregations.

func (*PostQuery) All

func (_q *PostQuery) All(ctx context.Context) ([]*Post, error)

All executes the query and returns a list of Posts.

func (*PostQuery) AllX

func (_q *PostQuery) AllX(ctx context.Context) []*Post

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

func (*PostQuery) Clone

func (_q *PostQuery) Clone() *PostQuery

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

func (*PostQuery) Count

func (_q *PostQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*PostQuery) CountX

func (_q *PostQuery) CountX(ctx context.Context) int

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

func (*PostQuery) Exist

func (_q *PostQuery) Exist(ctx context.Context) (bool, error)

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

func (*PostQuery) ExistX

func (_q *PostQuery) ExistX(ctx context.Context) bool

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

func (*PostQuery) First

func (_q *PostQuery) First(ctx context.Context) (*Post, error)

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

func (*PostQuery) FirstID

func (_q *PostQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*PostQuery) FirstIDX

func (_q *PostQuery) FirstIDX(ctx context.Context) int

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

func (*PostQuery) FirstX

func (_q *PostQuery) FirstX(ctx context.Context) *Post

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

func (*PostQuery) GroupBy

func (_q *PostQuery) GroupBy(field string, fields ...string) *PostGroupBy

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.Post.Query().
	GroupBy(post.FieldTitle).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*PostQuery) IDs

func (_q *PostQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*PostQuery) IDsX

func (_q *PostQuery) IDsX(ctx context.Context) []int

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

func (*PostQuery) Limit

func (_q *PostQuery) Limit(limit int) *PostQuery

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

func (*PostQuery) Offset

func (_q *PostQuery) Offset(offset int) *PostQuery

Offset to start from.

func (*PostQuery) Only

func (_q *PostQuery) Only(ctx context.Context) (*Post, error)

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

func (*PostQuery) OnlyID

func (_q *PostQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*PostQuery) OnlyIDX

func (_q *PostQuery) OnlyIDX(ctx context.Context) int

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

func (*PostQuery) OnlyX

func (_q *PostQuery) OnlyX(ctx context.Context) *Post

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

func (*PostQuery) Order

func (_q *PostQuery) Order(o ...post.OrderOption) *PostQuery

Order specifies how the records should be ordered.

func (*PostQuery) QueryOwner

func (_q *PostQuery) QueryOwner() *UserQuery

QueryOwner chains the current query on the "owner" edge.

func (*PostQuery) QueryPinners

func (_q *PostQuery) QueryPinners() *UserQuery

QueryPinners chains the current query on the "pinners" edge.

func (*PostQuery) Select

func (_q *PostQuery) Select(fields ...string) *PostSelect

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.Post.Query().
	Select(post.FieldTitle).
	Scan(ctx, &v)

func (*PostQuery) Unique

func (_q *PostQuery) Unique(unique bool) *PostQuery

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

func (_q *PostQuery) Where(ps ...predicate.Post) *PostQuery

Where adds a new predicate for the PostQuery builder.

func (*PostQuery) WithOwner

func (_q *PostQuery) WithOwner(opts ...func(*UserQuery)) *PostQuery

WithOwner tells the query-builder to eager-load the nodes that are connected to the "owner" edge. The optional arguments are used to configure the query builder of the edge.

func (*PostQuery) WithPinners

func (_q *PostQuery) WithPinners(opts ...func(*UserQuery)) *PostQuery

WithPinners tells the query-builder to eager-load the nodes that are connected to the "pinners" edge. The optional arguments are used to configure the query builder of the edge.

type PostSelect

type PostSelect struct {
	*PostQuery
	// contains filtered or unexported fields
}

PostSelect is the builder for selecting fields of Post entities.

func (*PostSelect) Aggregate

func (_s *PostSelect) Aggregate(fns ...AggregateFunc) *PostSelect

Aggregate adds the given aggregation functions to the selector query.

func (*PostSelect) Bool

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

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

func (*PostSelect) BoolX

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

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

func (*PostSelect) Bools

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

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

func (*PostSelect) BoolsX

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

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

func (*PostSelect) Float64

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

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

func (*PostSelect) Float64X

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

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

func (*PostSelect) Float64s

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

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

func (*PostSelect) Float64sX

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

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

func (*PostSelect) Int

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

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

func (*PostSelect) IntX

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

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

func (*PostSelect) Ints

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

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

func (*PostSelect) IntsX

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

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

func (*PostSelect) Scan

func (_s *PostSelect) Scan(ctx context.Context, v any) error

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

func (*PostSelect) ScanX

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

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

func (*PostSelect) String

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

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

func (*PostSelect) StringX

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

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

func (*PostSelect) Strings

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

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

func (*PostSelect) StringsX

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

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

type PostUpdate

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

PostUpdate is the builder for updating Post entities.

func (*PostUpdate) AddPinnerIDs

func (_u *PostUpdate) AddPinnerIDs(ids ...int) *PostUpdate

AddPinnerIDs adds the "pinners" edge to the User entity by IDs.

func (*PostUpdate) AddPinners

func (_u *PostUpdate) AddPinners(v ...*User) *PostUpdate

AddPinners adds the "pinners" edges to the User entity.

func (*PostUpdate) ApplyDomain

func (u *PostUpdate) ApplyDomain(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) (*PostUpdate, error)

ApplyDomain applies domain.Post fields to the PostUpdate builder. Chain .Where(...) conditions to target specific records.

Note: ctx is accepted for API symmetry with ApplyDomainCreate/UpdateOne and to allow future ctx-aware field transformers. Currently no transformer hooks fire here — the error return is always nil.

func (*PostUpdate) ApplyDomainX

func (u *PostUpdate) ApplyDomainX(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) *PostUpdate

ApplyDomainX is the panicking variant of ApplyDomain. See *PostCreate.ApplyDomainX.

func (*PostUpdate) ClearOwner

func (_u *PostUpdate) ClearOwner() *PostUpdate

ClearOwner clears the "owner" edge to the User entity.

func (*PostUpdate) ClearPinners

func (_u *PostUpdate) ClearPinners() *PostUpdate

ClearPinners clears all "pinners" edges to the User entity.

func (*PostUpdate) Exec

func (_u *PostUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*PostUpdate) ExecX

func (_u *PostUpdate) ExecX(ctx context.Context)

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

func (*PostUpdate) Mutation

func (_u *PostUpdate) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostUpdate) RemovePinnerIDs

func (_u *PostUpdate) RemovePinnerIDs(ids ...int) *PostUpdate

RemovePinnerIDs removes the "pinners" edge to User entities by IDs.

func (*PostUpdate) RemovePinners

func (_u *PostUpdate) RemovePinners(v ...*User) *PostUpdate

RemovePinners removes "pinners" edges to User entities.

func (*PostUpdate) Save

func (_u *PostUpdate) Save(ctx context.Context) (int, error)

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

func (*PostUpdate) SaveX

func (_u *PostUpdate) SaveX(ctx context.Context) int

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

func (*PostUpdate) SetNillableOwnerID

func (_u *PostUpdate) SetNillableOwnerID(id *int) *PostUpdate

SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil.

func (*PostUpdate) SetNillablePublished

func (_u *PostUpdate) SetNillablePublished(v *bool) *PostUpdate

SetNillablePublished sets the "published" field if the given value is not nil.

func (*PostUpdate) SetNillableTitle

func (_u *PostUpdate) SetNillableTitle(v *string) *PostUpdate

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

func (*PostUpdate) SetOwner

func (_u *PostUpdate) SetOwner(v *User) *PostUpdate

SetOwner sets the "owner" edge to the User entity.

func (*PostUpdate) SetOwnerID

func (_u *PostUpdate) SetOwnerID(id int) *PostUpdate

SetOwnerID sets the "owner" edge to the User entity by ID.

func (*PostUpdate) SetPublished

func (_u *PostUpdate) SetPublished(v bool) *PostUpdate

SetPublished sets the "published" field.

func (*PostUpdate) SetTitle

func (_u *PostUpdate) SetTitle(v string) *PostUpdate

SetTitle sets the "title" field.

func (*PostUpdate) Where

func (_u *PostUpdate) Where(ps ...predicate.Post) *PostUpdate

Where appends a list predicates to the PostUpdate builder.

type PostUpdateOne

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

PostUpdateOne is the builder for updating a single Post entity.

func (*PostUpdateOne) AddPinnerIDs

func (_u *PostUpdateOne) AddPinnerIDs(ids ...int) *PostUpdateOne

AddPinnerIDs adds the "pinners" edge to the User entity by IDs.

func (*PostUpdateOne) AddPinners

func (_u *PostUpdateOne) AddPinners(v ...*User) *PostUpdateOne

AddPinners adds the "pinners" edges to the User entity.

func (*PostUpdateOne) ApplyDomain

func (u *PostUpdateOne) ApplyDomain(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) (*PostUpdateOne, error)

ApplyDomain applies domain.Post fields to the PostUpdateOne builder.

func (*PostUpdateOne) ApplyDomainX

func (u *PostUpdateOne) ApplyDomainX(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) *PostUpdateOne

ApplyDomainX is the panicking variant of ApplyDomain. See *PostCreate.ApplyDomainX.

func (*PostUpdateOne) ClearOwner

func (_u *PostUpdateOne) ClearOwner() *PostUpdateOne

ClearOwner clears the "owner" edge to the User entity.

func (*PostUpdateOne) ClearPinners

func (_u *PostUpdateOne) ClearPinners() *PostUpdateOne

ClearPinners clears all "pinners" edges to the User entity.

func (*PostUpdateOne) Exec

func (_u *PostUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*PostUpdateOne) ExecX

func (_u *PostUpdateOne) ExecX(ctx context.Context)

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

func (*PostUpdateOne) Mutation

func (_u *PostUpdateOne) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostUpdateOne) RemovePinnerIDs

func (_u *PostUpdateOne) RemovePinnerIDs(ids ...int) *PostUpdateOne

RemovePinnerIDs removes the "pinners" edge to User entities by IDs.

func (*PostUpdateOne) RemovePinners

func (_u *PostUpdateOne) RemovePinners(v ...*User) *PostUpdateOne

RemovePinners removes "pinners" edges to User entities.

func (*PostUpdateOne) Save

func (_u *PostUpdateOne) Save(ctx context.Context) (*Post, error)

Save executes the query and returns the updated Post entity.

func (*PostUpdateOne) SaveX

func (_u *PostUpdateOne) SaveX(ctx context.Context) *Post

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

func (*PostUpdateOne) Select

func (_u *PostUpdateOne) Select(field string, fields ...string) *PostUpdateOne

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

func (*PostUpdateOne) SetNillableOwnerID

func (_u *PostUpdateOne) SetNillableOwnerID(id *int) *PostUpdateOne

SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil.

func (*PostUpdateOne) SetNillablePublished

func (_u *PostUpdateOne) SetNillablePublished(v *bool) *PostUpdateOne

SetNillablePublished sets the "published" field if the given value is not nil.

func (*PostUpdateOne) SetNillableTitle

func (_u *PostUpdateOne) SetNillableTitle(v *string) *PostUpdateOne

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

func (*PostUpdateOne) SetOwner

func (_u *PostUpdateOne) SetOwner(v *User) *PostUpdateOne

SetOwner sets the "owner" edge to the User entity.

func (*PostUpdateOne) SetOwnerID

func (_u *PostUpdateOne) SetOwnerID(id int) *PostUpdateOne

SetOwnerID sets the "owner" edge to the User entity by ID.

func (*PostUpdateOne) SetPublished

func (_u *PostUpdateOne) SetPublished(v bool) *PostUpdateOne

SetPublished sets the "published" field.

func (*PostUpdateOne) SetTitle

func (_u *PostUpdateOne) SetTitle(v string) *PostUpdateOne

SetTitle sets the "title" field.

func (*PostUpdateOne) Where

func (_u *PostUpdateOne) Where(ps ...predicate.Post) *PostUpdateOne

Where appends a list predicates to the PostUpdate builder.

type PostUpsert

type PostUpsert struct {
	*sql.UpdateSet
}

PostUpsert is the "OnConflict" setter.

func (*PostUpsert) SetPublished

func (u *PostUpsert) SetPublished(v bool) *PostUpsert

SetPublished sets the "published" field.

func (*PostUpsert) SetTitle

func (u *PostUpsert) SetTitle(v string) *PostUpsert

SetTitle sets the "title" field.

func (*PostUpsert) UpdatePublished

func (u *PostUpsert) UpdatePublished() *PostUpsert

UpdatePublished sets the "published" field to the value that was provided on create.

func (*PostUpsert) UpdateTitle

func (u *PostUpsert) UpdateTitle() *PostUpsert

UpdateTitle sets the "title" field to the value that was provided on create.

type PostUpsertBulk

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

PostUpsertBulk is the builder for "upsert"-ing a bulk of Post nodes.

func (*PostUpsertBulk) DoNothing

func (u *PostUpsertBulk) DoNothing() *PostUpsertBulk

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*PostUpsertBulk) Exec

func (u *PostUpsertBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*PostUpsertBulk) ExecX

func (u *PostUpsertBulk) ExecX(ctx context.Context)

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

func (*PostUpsertBulk) Ignore

func (u *PostUpsertBulk) Ignore() *PostUpsertBulk

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.Post.Create().
	OnConflict(sql.ResolveWithIgnore()).
	Exec(ctx)

func (*PostUpsertBulk) SetPublished

func (u *PostUpsertBulk) SetPublished(v bool) *PostUpsertBulk

SetPublished sets the "published" field.

func (*PostUpsertBulk) SetTitle

func (u *PostUpsertBulk) SetTitle(v string) *PostUpsertBulk

SetTitle sets the "title" field.

func (*PostUpsertBulk) Update

func (u *PostUpsertBulk) Update(set func(*PostUpsert)) *PostUpsertBulk

Update allows overriding fields `UPDATE` values. See the PostCreateBulk.OnConflict documentation for more info.

func (*PostUpsertBulk) UpdateNewValues

func (u *PostUpsertBulk) UpdateNewValues() *PostUpsertBulk

UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:

client.Post.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

func (*PostUpsertBulk) UpdatePublished

func (u *PostUpsertBulk) UpdatePublished() *PostUpsertBulk

UpdatePublished sets the "published" field to the value that was provided on create.

func (*PostUpsertBulk) UpdateTitle

func (u *PostUpsertBulk) UpdateTitle() *PostUpsertBulk

UpdateTitle sets the "title" field to the value that was provided on create.

type PostUpsertOne

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

PostUpsertOne is the builder for "upsert"-ing

one Post node.

func (*PostUpsertOne) ApplyDomain

func (u *PostUpsertOne) ApplyDomain(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) (*PostUpsertOne, error)

ApplyDomain applies domain.Post fields to the PostUpsertOne builder on conflict.

Note: ctx is accepted for API symmetry. Transformer hooks do not fire on upsert conflict paths; the error return is always nil.

func (*PostUpsertOne) ApplyDomainX

func (u *PostUpsertOne) ApplyDomainX(ctx context.Context, d *domain.Post, opts ...entdomain.ApplyOption) *PostUpsertOne

ApplyDomainX is the panicking variant of ApplyDomain. See *PostCreate.ApplyDomainX.

func (*PostUpsertOne) DoNothing

func (u *PostUpsertOne) DoNothing() *PostUpsertOne

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*PostUpsertOne) Exec

func (u *PostUpsertOne) Exec(ctx context.Context) error

Exec executes the query.

func (*PostUpsertOne) ExecX

func (u *PostUpsertOne) ExecX(ctx context.Context)

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

func (*PostUpsertOne) ID

func (u *PostUpsertOne) ID(ctx context.Context) (id int, err error)

Exec executes the UPSERT query and returns the inserted/updated ID.

func (*PostUpsertOne) IDX

func (u *PostUpsertOne) IDX(ctx context.Context) int

IDX is like ID, but panics if an error occurs.

func (*PostUpsertOne) Ignore

func (u *PostUpsertOne) Ignore() *PostUpsertOne

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.Post.Create().
    OnConflict(sql.ResolveWithIgnore()).
    Exec(ctx)

func (*PostUpsertOne) SetPublished

func (u *PostUpsertOne) SetPublished(v bool) *PostUpsertOne

SetPublished sets the "published" field.

func (*PostUpsertOne) SetTitle

func (u *PostUpsertOne) SetTitle(v string) *PostUpsertOne

SetTitle sets the "title" field.

func (*PostUpsertOne) Update

func (u *PostUpsertOne) Update(set func(*PostUpsert)) *PostUpsertOne

Update allows overriding fields `UPDATE` values. See the PostCreate.OnConflict documentation for more info.

func (*PostUpsertOne) UpdateNewValues

func (u *PostUpsertOne) UpdateNewValues() *PostUpsertOne

UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:

client.Post.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

func (*PostUpsertOne) UpdatePublished

func (u *PostUpsertOne) UpdatePublished() *PostUpsertOne

UpdatePublished sets the "published" field to the value that was provided on create.

func (*PostUpsertOne) UpdateTitle

func (u *PostUpsertOne) UpdateTitle() *PostUpsertOne

UpdateTitle sets the "title" field to the value that was provided on create.

type Posts

type Posts []*Post

Posts is a parsable slice of Post.

func (Posts) ToDomain

func (es Posts) ToDomain() domain.PostList

ToDomain maps a slice of ent Post to domain.PostList.

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 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 Tag

type Tag struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the TagQuery when eager-loading is set.
	Edges TagEdges `json:"edges"`
	// contains filtered or unexported fields
}

Tag is the model entity for the Tag schema.

func (*Tag) QueryUsers

func (_m *Tag) QueryUsers() *UserQuery

QueryUsers queries the "users" edge of the Tag entity.

func (*Tag) String

func (_m *Tag) String() string

String implements the fmt.Stringer.

func (*Tag) ToDomain

func (e *Tag) ToDomain() *domain.Tag

ToDomain maps the ent Tag to a domain.Tag.

func (*Tag) Unwrap

func (_m *Tag) Unwrap() *Tag

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

func (_m *Tag) Update() *TagUpdateOne

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

func (*Tag) Value

func (_m *Tag) Value(name string) (ent.Value, error)

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

type TagClient

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

TagClient is a client for the Tag schema.

func NewTagClient

func NewTagClient(c config) *TagClient

NewTagClient returns a client for the Tag from the given config.

func (*TagClient) Create

func (c *TagClient) Create() *TagCreate

Create returns a builder for creating a Tag entity.

func (*TagClient) CreateBulk

func (c *TagClient) CreateBulk(builders ...*TagCreate) *TagCreateBulk

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

func (*TagClient) CreateBulkDomain

func (c *TagClient) CreateBulkDomain(ctx context.Context, ds domain.TagList, opts ...entdomain.ApplyOption) (*TagCreateBulk, error)

CreateBulkDomain creates a TagCreateBulk from domain.TagList.

If any per-row transformer returns an error, the first such error is returned immediately and partial bulk is discarded.

func (*TagClient) CreateBulkDomainX

func (c *TagClient) CreateBulkDomainX(ctx context.Context, ds domain.TagList, opts ...entdomain.ApplyOption) *TagCreateBulk

CreateBulkDomainX is the panicking variant of CreateBulkDomain. See *TagCreate.ApplyDomainX for the convention.

func (*TagClient) Delete

func (c *TagClient) Delete() *TagDelete

Delete returns a delete builder for Tag.

func (*TagClient) DeleteOne

func (c *TagClient) DeleteOne(_m *Tag) *TagDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*TagClient) DeleteOneID

func (c *TagClient) DeleteOneID(id int) *TagDeleteOne

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

func (*TagClient) Get

func (c *TagClient) Get(ctx context.Context, id int) (*Tag, error)

Get returns a Tag entity by its id.

func (*TagClient) GetX

func (c *TagClient) GetX(ctx context.Context, id int) *Tag

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

func (*TagClient) Hooks

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

Hooks returns the client hooks.

func (*TagClient) Intercept

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

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

func (*TagClient) Interceptors

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

Interceptors returns the client interceptors.

func (*TagClient) MapCreateBulk

func (c *TagClient) MapCreateBulk(slice any, setFunc func(*TagCreate, int)) *TagCreateBulk

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

func (c *TagClient) Query() *TagQuery

Query returns a query builder for Tag.

func (*TagClient) QueryUsers

func (c *TagClient) QueryUsers(_m *Tag) *UserQuery

QueryUsers queries the users edge of a Tag.

func (*TagClient) Update

func (c *TagClient) Update() *TagUpdate

Update returns an update builder for Tag.

func (*TagClient) UpdateBulkDomain

func (c *TagClient) UpdateBulkDomain(ctx context.Context, ds domain.TagList, opts ...entdomain.ApplyOption) (*TagUpdateOneBulk, error)

UpdateBulkDomain returns a TagUpdateOneBulk from domain.TagList. Each builder is keyed on ds[i].ID.

If any per-row transformer returns an error, the first such error is returned immediately and partial bulk is discarded.

func (*TagClient) UpdateBulkDomainX

func (c *TagClient) UpdateBulkDomainX(ctx context.Context, ds domain.TagList, opts ...entdomain.ApplyOption) *TagUpdateOneBulk

UpdateBulkDomainX is the panicking variant of UpdateBulkDomain. See *TagCreate.ApplyDomainX for the convention.

func (*TagClient) UpdateOne

func (c *TagClient) UpdateOne(_m *Tag) *TagUpdateOne

UpdateOne returns an update builder for the given entity.

func (*TagClient) UpdateOneID

func (c *TagClient) UpdateOneID(id int) *TagUpdateOne

UpdateOneID returns an update builder for the given id.

func (*TagClient) Use

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

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

type TagCreate

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

TagCreate is the builder for creating a Tag entity.

func (*TagCreate) AddUserIDs

func (_c *TagCreate) AddUserIDs(ids ...int) *TagCreate

AddUserIDs adds the "users" edge to the User entity by IDs.

func (*TagCreate) AddUsers

func (_c *TagCreate) AddUsers(v ...*User) *TagCreate

AddUsers adds the "users" edges to the User entity.

func (*TagCreate) ApplyDomain

func (c *TagCreate) ApplyDomain(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) (*TagCreate, error)

ApplyDomain applies domain.Tag fields to the TagCreate builder.

func (*TagCreate) ApplyDomainX

func (c *TagCreate) ApplyDomainX(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) *TagCreate

ApplyDomainX is the panicking variant of ApplyDomain. It enables fluent chaining at the cost of converting transformer errors into panics. Mirrors ent's SaveX/FirstX/OnlyX convention: use in tests and scripts, prefer ApplyDomain on request paths where transformer errors (e.g. KMS failures) must be recoverable.

func (*TagCreate) Exec

func (_c *TagCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*TagCreate) ExecX

func (_c *TagCreate) ExecX(ctx context.Context)

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

func (*TagCreate) Mutation

func (_c *TagCreate) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagCreate) OnConflict

func (_c *TagCreate) OnConflict(opts ...sql.ConflictOption) *TagUpsertOne

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.Tag.Create().
	SetName(v).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.TagUpsert) {
		SetName(v+v).
	}).
	Exec(ctx)

func (*TagCreate) OnConflictColumns

func (_c *TagCreate) OnConflictColumns(columns ...string) *TagUpsertOne

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.Tag.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*TagCreate) Save

func (_c *TagCreate) Save(ctx context.Context) (*Tag, error)

Save creates the Tag in the database.

func (*TagCreate) SaveX

func (_c *TagCreate) SaveX(ctx context.Context) *Tag

SaveX calls Save and panics if Save returns an error.

func (*TagCreate) SetName

func (_c *TagCreate) SetName(v string) *TagCreate

SetName sets the "name" field.

type TagCreateBulk

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

TagCreateBulk is the builder for creating many Tag entities in bulk.

func (*TagCreateBulk) Exec

func (_c *TagCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*TagCreateBulk) ExecX

func (_c *TagCreateBulk) ExecX(ctx context.Context)

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

func (*TagCreateBulk) OnConflict

func (_c *TagCreateBulk) OnConflict(opts ...sql.ConflictOption) *TagUpsertBulk

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.Tag.CreateBulk(builders...).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.TagUpsert) {
		SetName(v+v).
	}).
	Exec(ctx)

func (*TagCreateBulk) OnConflictColumns

func (_c *TagCreateBulk) OnConflictColumns(columns ...string) *TagUpsertBulk

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.Tag.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*TagCreateBulk) Save

func (_c *TagCreateBulk) Save(ctx context.Context) ([]*Tag, error)

Save creates the Tag entities in the database.

func (*TagCreateBulk) SaveX

func (_c *TagCreateBulk) SaveX(ctx context.Context) []*Tag

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

type TagDelete

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

TagDelete is the builder for deleting a Tag entity.

func (*TagDelete) Exec

func (_d *TagDelete) Exec(ctx context.Context) (int, error)

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

func (*TagDelete) ExecX

func (_d *TagDelete) ExecX(ctx context.Context) int

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

func (*TagDelete) Where

func (_d *TagDelete) Where(ps ...predicate.Tag) *TagDelete

Where appends a list predicates to the TagDelete builder.

type TagDeleteOne

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

TagDeleteOne is the builder for deleting a single Tag entity.

func (*TagDeleteOne) Exec

func (_d *TagDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*TagDeleteOne) ExecX

func (_d *TagDeleteOne) ExecX(ctx context.Context)

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

func (*TagDeleteOne) Where

func (_d *TagDeleteOne) Where(ps ...predicate.Tag) *TagDeleteOne

Where appends a list predicates to the TagDelete builder.

type TagDomainField

type TagDomainField = string

TagDomainField is the type for Tag domain field constants.

const (
	TagDomainFieldName    TagDomainField = "name"
	TagDomainFieldUserIDs TagDomainField = "user_ids"
)

type TagDomainTransformer

type TagDomainTransformer struct {
}

TagDomainTransformer holds optional transformer functions for Tag → domain mapping.

Get* functions are pure synchronous projections invoked by ToDomain. Set*OnCreate / Set*OnUpdate are invoked during ApplyDomain and may perform I/O (e.g. KMS-backed field encryption); they receive ctx + the full domain struct so they can access sibling fields and propagate cancellation.

var TagTransformer *TagDomainTransformer

TagTransformer is the package-level transformer for Tag (nil by default).

type TagEdges

type TagEdges struct {
	// Users holds the value of the users edge.
	Users []*User `json:"users,omitempty"`
	// contains filtered or unexported fields
}

TagEdges holds the relations/edges for other nodes in the graph.

func (TagEdges) UsersOrErr

func (e TagEdges) UsersOrErr() ([]*User, error)

UsersOrErr returns the Users value or an error if the edge was not loaded in eager-loading.

type TagGroupBy

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

TagGroupBy is the group-by builder for Tag entities.

func (*TagGroupBy) Aggregate

func (_g *TagGroupBy) Aggregate(fns ...AggregateFunc) *TagGroupBy

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

func (*TagGroupBy) Bool

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

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

func (*TagGroupBy) BoolX

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

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

func (*TagGroupBy) Bools

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

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

func (*TagGroupBy) BoolsX

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

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

func (*TagGroupBy) Float64

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

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

func (*TagGroupBy) Float64X

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

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

func (*TagGroupBy) Float64s

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

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

func (*TagGroupBy) Float64sX

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

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

func (*TagGroupBy) Int

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

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

func (*TagGroupBy) IntX

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

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

func (*TagGroupBy) Ints

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

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

func (*TagGroupBy) IntsX

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

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

func (*TagGroupBy) Scan

func (_g *TagGroupBy) Scan(ctx context.Context, v any) error

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

func (*TagGroupBy) ScanX

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

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

func (*TagGroupBy) String

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

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

func (*TagGroupBy) StringX

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

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

func (*TagGroupBy) Strings

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

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

func (*TagGroupBy) StringsX

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

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

type TagMutation

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

TagMutation represents an operation that mutates the Tag nodes in the graph.

func (*TagMutation) AddField

func (m *TagMutation) 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 (*TagMutation) AddUserIDs

func (m *TagMutation) AddUserIDs(ids ...int)

AddUserIDs adds the "users" edge to the User entity by ids.

func (*TagMutation) AddedEdges

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

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

func (*TagMutation) AddedField

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

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

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

func (*TagMutation) AddedIDs

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

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

func (*TagMutation) ClearEdge

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

func (m *TagMutation) 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 (*TagMutation) ClearUsers

func (m *TagMutation) ClearUsers()

ClearUsers clears the "users" edge to the User entity.

func (*TagMutation) ClearedEdges

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

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

func (*TagMutation) ClearedFields

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

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

func (TagMutation) Client

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

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

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

func (*TagMutation) Field

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

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

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

func (*TagMutation) Fields

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

func (m *TagMutation) ID() (id int, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.

func (*TagMutation) IDs

func (m *TagMutation) IDs(ctx context.Context) ([]int, error)

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

func (*TagMutation) Name

func (m *TagMutation) Name() (r string, exists bool)

Name returns the value of the "name" field in the mutation.

func (*TagMutation) OldField

func (m *TagMutation) 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 (*TagMutation) OldName

func (m *TagMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the Tag entity. If the Tag 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 (*TagMutation) Op

func (m *TagMutation) Op() Op

Op returns the operation name.

func (*TagMutation) RemoveUserIDs

func (m *TagMutation) RemoveUserIDs(ids ...int)

RemoveUserIDs removes the "users" edge to the User entity by IDs.

func (*TagMutation) RemovedEdges

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

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

func (*TagMutation) RemovedIDs

func (m *TagMutation) 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 (*TagMutation) RemovedUsersIDs

func (m *TagMutation) RemovedUsersIDs() (ids []int)

RemovedUsers returns the removed IDs of the "users" edge to the User entity.

func (*TagMutation) ResetEdge

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

func (m *TagMutation) 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 (*TagMutation) ResetName

func (m *TagMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*TagMutation) ResetUsers

func (m *TagMutation) ResetUsers()

ResetUsers resets all changes to the "users" edge.

func (*TagMutation) SetField

func (m *TagMutation) 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 (*TagMutation) SetName

func (m *TagMutation) SetName(s string)

SetName sets the "name" field.

func (*TagMutation) SetOp

func (m *TagMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (TagMutation) Tx

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

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

func (*TagMutation) Type

func (m *TagMutation) Type() string

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

func (*TagMutation) UsersCleared

func (m *TagMutation) UsersCleared() bool

UsersCleared reports if the "users" edge to the User entity was cleared.

func (*TagMutation) UsersIDs

func (m *TagMutation) UsersIDs() (ids []int)

UsersIDs returns the "users" edge IDs in the mutation.

func (*TagMutation) Where

func (m *TagMutation) Where(ps ...predicate.Tag)

Where appends a list predicates to the TagMutation builder.

func (*TagMutation) WhereP

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

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

type TagQuery

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

TagQuery is the builder for querying Tag entities.

func (*TagQuery) Aggregate

func (_q *TagQuery) Aggregate(fns ...AggregateFunc) *TagSelect

Aggregate returns a TagSelect configured with the given aggregations.

func (*TagQuery) All

func (_q *TagQuery) All(ctx context.Context) ([]*Tag, error)

All executes the query and returns a list of Tags.

func (*TagQuery) AllX

func (_q *TagQuery) AllX(ctx context.Context) []*Tag

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

func (*TagQuery) Clone

func (_q *TagQuery) Clone() *TagQuery

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

func (*TagQuery) Count

func (_q *TagQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*TagQuery) CountX

func (_q *TagQuery) CountX(ctx context.Context) int

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

func (*TagQuery) Exist

func (_q *TagQuery) Exist(ctx context.Context) (bool, error)

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

func (*TagQuery) ExistX

func (_q *TagQuery) ExistX(ctx context.Context) bool

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

func (*TagQuery) First

func (_q *TagQuery) First(ctx context.Context) (*Tag, error)

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

func (*TagQuery) FirstID

func (_q *TagQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*TagQuery) FirstIDX

func (_q *TagQuery) FirstIDX(ctx context.Context) int

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

func (*TagQuery) FirstX

func (_q *TagQuery) FirstX(ctx context.Context) *Tag

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

func (*TagQuery) GroupBy

func (_q *TagQuery) GroupBy(field string, fields ...string) *TagGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Tag.Query().
	GroupBy(tag.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*TagQuery) IDs

func (_q *TagQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*TagQuery) IDsX

func (_q *TagQuery) IDsX(ctx context.Context) []int

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

func (*TagQuery) Limit

func (_q *TagQuery) Limit(limit int) *TagQuery

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

func (*TagQuery) Offset

func (_q *TagQuery) Offset(offset int) *TagQuery

Offset to start from.

func (*TagQuery) Only

func (_q *TagQuery) Only(ctx context.Context) (*Tag, error)

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

func (*TagQuery) OnlyID

func (_q *TagQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*TagQuery) OnlyIDX

func (_q *TagQuery) OnlyIDX(ctx context.Context) int

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

func (*TagQuery) OnlyX

func (_q *TagQuery) OnlyX(ctx context.Context) *Tag

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

func (*TagQuery) Order

func (_q *TagQuery) Order(o ...tag.OrderOption) *TagQuery

Order specifies how the records should be ordered.

func (*TagQuery) QueryUsers

func (_q *TagQuery) QueryUsers() *UserQuery

QueryUsers chains the current query on the "users" edge.

func (*TagQuery) Select

func (_q *TagQuery) Select(fields ...string) *TagSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.Tag.Query().
	Select(tag.FieldName).
	Scan(ctx, &v)

func (*TagQuery) Unique

func (_q *TagQuery) Unique(unique bool) *TagQuery

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

func (_q *TagQuery) Where(ps ...predicate.Tag) *TagQuery

Where adds a new predicate for the TagQuery builder.

func (*TagQuery) WithUsers

func (_q *TagQuery) WithUsers(opts ...func(*UserQuery)) *TagQuery

WithUsers tells the query-builder to eager-load the nodes that are connected to the "users" edge. The optional arguments are used to configure the query builder of the edge.

type TagSelect

type TagSelect struct {
	*TagQuery
	// contains filtered or unexported fields
}

TagSelect is the builder for selecting fields of Tag entities.

func (*TagSelect) Aggregate

func (_s *TagSelect) Aggregate(fns ...AggregateFunc) *TagSelect

Aggregate adds the given aggregation functions to the selector query.

func (*TagSelect) Bool

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

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

func (*TagSelect) BoolX

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

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

func (*TagSelect) Bools

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

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

func (*TagSelect) BoolsX

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

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

func (*TagSelect) Float64

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

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

func (*TagSelect) Float64X

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

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

func (*TagSelect) Float64s

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

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

func (*TagSelect) Float64sX

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

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

func (*TagSelect) Int

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

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

func (*TagSelect) IntX

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

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

func (*TagSelect) Ints

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

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

func (*TagSelect) IntsX

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

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

func (*TagSelect) Scan

func (_s *TagSelect) Scan(ctx context.Context, v any) error

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

func (*TagSelect) ScanX

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

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

func (*TagSelect) String

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

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

func (*TagSelect) StringX

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

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

func (*TagSelect) Strings

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

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

func (*TagSelect) StringsX

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

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

type TagUpdate

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

TagUpdate is the builder for updating Tag entities.

func (*TagUpdate) AddUserIDs

func (_u *TagUpdate) AddUserIDs(ids ...int) *TagUpdate

AddUserIDs adds the "users" edge to the User entity by IDs.

func (*TagUpdate) AddUsers

func (_u *TagUpdate) AddUsers(v ...*User) *TagUpdate

AddUsers adds the "users" edges to the User entity.

func (*TagUpdate) ApplyDomain

func (u *TagUpdate) ApplyDomain(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) (*TagUpdate, error)

ApplyDomain applies domain.Tag fields to the TagUpdate builder. Chain .Where(...) conditions to target specific records.

Note: ctx is accepted for API symmetry with ApplyDomainCreate/UpdateOne and to allow future ctx-aware field transformers. Currently no transformer hooks fire here — the error return is always nil.

func (*TagUpdate) ApplyDomainX

func (u *TagUpdate) ApplyDomainX(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) *TagUpdate

ApplyDomainX is the panicking variant of ApplyDomain. See *TagCreate.ApplyDomainX.

func (*TagUpdate) ClearUsers

func (_u *TagUpdate) ClearUsers() *TagUpdate

ClearUsers clears all "users" edges to the User entity.

func (*TagUpdate) Exec

func (_u *TagUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*TagUpdate) ExecX

func (_u *TagUpdate) ExecX(ctx context.Context)

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

func (*TagUpdate) Mutation

func (_u *TagUpdate) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagUpdate) RemoveUserIDs

func (_u *TagUpdate) RemoveUserIDs(ids ...int) *TagUpdate

RemoveUserIDs removes the "users" edge to User entities by IDs.

func (*TagUpdate) RemoveUsers

func (_u *TagUpdate) RemoveUsers(v ...*User) *TagUpdate

RemoveUsers removes "users" edges to User entities.

func (*TagUpdate) Save

func (_u *TagUpdate) Save(ctx context.Context) (int, error)

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

func (*TagUpdate) SaveX

func (_u *TagUpdate) SaveX(ctx context.Context) int

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

func (*TagUpdate) SetName

func (_u *TagUpdate) SetName(v string) *TagUpdate

SetName sets the "name" field.

func (*TagUpdate) SetNillableName

func (_u *TagUpdate) SetNillableName(v *string) *TagUpdate

SetNillableName sets the "name" field if the given value is not nil.

func (*TagUpdate) Where

func (_u *TagUpdate) Where(ps ...predicate.Tag) *TagUpdate

Where appends a list predicates to the TagUpdate builder.

type TagUpdateOne

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

TagUpdateOne is the builder for updating a single Tag entity.

func (*TagUpdateOne) AddUserIDs

func (_u *TagUpdateOne) AddUserIDs(ids ...int) *TagUpdateOne

AddUserIDs adds the "users" edge to the User entity by IDs.

func (*TagUpdateOne) AddUsers

func (_u *TagUpdateOne) AddUsers(v ...*User) *TagUpdateOne

AddUsers adds the "users" edges to the User entity.

func (*TagUpdateOne) ApplyDomain

func (u *TagUpdateOne) ApplyDomain(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) (*TagUpdateOne, error)

ApplyDomain applies domain.Tag fields to the TagUpdateOne builder.

func (*TagUpdateOne) ApplyDomainX

func (u *TagUpdateOne) ApplyDomainX(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) *TagUpdateOne

ApplyDomainX is the panicking variant of ApplyDomain. See *TagCreate.ApplyDomainX.

func (*TagUpdateOne) ClearUsers

func (_u *TagUpdateOne) ClearUsers() *TagUpdateOne

ClearUsers clears all "users" edges to the User entity.

func (*TagUpdateOne) Exec

func (_u *TagUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*TagUpdateOne) ExecX

func (_u *TagUpdateOne) ExecX(ctx context.Context)

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

func (*TagUpdateOne) Mutation

func (_u *TagUpdateOne) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagUpdateOne) RemoveUserIDs

func (_u *TagUpdateOne) RemoveUserIDs(ids ...int) *TagUpdateOne

RemoveUserIDs removes the "users" edge to User entities by IDs.

func (*TagUpdateOne) RemoveUsers

func (_u *TagUpdateOne) RemoveUsers(v ...*User) *TagUpdateOne

RemoveUsers removes "users" edges to User entities.

func (*TagUpdateOne) Save

func (_u *TagUpdateOne) Save(ctx context.Context) (*Tag, error)

Save executes the query and returns the updated Tag entity.

func (*TagUpdateOne) SaveX

func (_u *TagUpdateOne) SaveX(ctx context.Context) *Tag

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

func (*TagUpdateOne) Select

func (_u *TagUpdateOne) Select(field string, fields ...string) *TagUpdateOne

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

func (*TagUpdateOne) SetName

func (_u *TagUpdateOne) SetName(v string) *TagUpdateOne

SetName sets the "name" field.

func (*TagUpdateOne) SetNillableName

func (_u *TagUpdateOne) SetNillableName(v *string) *TagUpdateOne

SetNillableName sets the "name" field if the given value is not nil.

func (*TagUpdateOne) Where

func (_u *TagUpdateOne) Where(ps ...predicate.Tag) *TagUpdateOne

Where appends a list predicates to the TagUpdate builder.

type TagUpdateOneBulk

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

TagUpdateOneBulk holds a set of TagUpdateOne builders.

func (*TagUpdateOneBulk) Exec

func (b *TagUpdateOneBulk) Exec(ctx context.Context) error

Exec executes all builders without returning the updated entities.

func (*TagUpdateOneBulk) ExecX

func (b *TagUpdateOneBulk) ExecX(ctx context.Context)

ExecX is like Exec but panics on error.

func (*TagUpdateOneBulk) Save

Save executes all builders and returns the updated entities as domain.TagList.

func (*TagUpdateOneBulk) SaveX

SaveX is like Save but panics on error.

type TagUpsert

type TagUpsert struct {
	*sql.UpdateSet
}

TagUpsert is the "OnConflict" setter.

func (*TagUpsert) SetName

func (u *TagUpsert) SetName(v string) *TagUpsert

SetName sets the "name" field.

func (*TagUpsert) UpdateName

func (u *TagUpsert) UpdateName() *TagUpsert

UpdateName sets the "name" field to the value that was provided on create.

type TagUpsertBulk

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

TagUpsertBulk is the builder for "upsert"-ing a bulk of Tag nodes.

func (*TagUpsertBulk) ApplyDomain

func (u *TagUpsertBulk) ApplyDomain(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) (*TagUpsertBulk, error)

ApplyDomain applies domain.Tag fields to the TagUpsertBulk builder on conflict.

Note: ctx is accepted for API symmetry. Transformer hooks do not fire on upsert conflict paths; the error return is always nil.

func (*TagUpsertBulk) ApplyDomainX

func (u *TagUpsertBulk) ApplyDomainX(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) *TagUpsertBulk

ApplyDomainX is the panicking variant of ApplyDomain. See *TagCreate.ApplyDomainX.

func (*TagUpsertBulk) DoNothing

func (u *TagUpsertBulk) DoNothing() *TagUpsertBulk

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*TagUpsertBulk) Exec

func (u *TagUpsertBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*TagUpsertBulk) ExecX

func (u *TagUpsertBulk) ExecX(ctx context.Context)

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

func (*TagUpsertBulk) Ignore

func (u *TagUpsertBulk) Ignore() *TagUpsertBulk

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.Tag.Create().
	OnConflict(sql.ResolveWithIgnore()).
	Exec(ctx)

func (*TagUpsertBulk) SetName

func (u *TagUpsertBulk) SetName(v string) *TagUpsertBulk

SetName sets the "name" field.

func (*TagUpsertBulk) Update

func (u *TagUpsertBulk) Update(set func(*TagUpsert)) *TagUpsertBulk

Update allows overriding fields `UPDATE` values. See the TagCreateBulk.OnConflict documentation for more info.

func (*TagUpsertBulk) UpdateName

func (u *TagUpsertBulk) UpdateName() *TagUpsertBulk

UpdateName sets the "name" field to the value that was provided on create.

func (*TagUpsertBulk) UpdateNewValues

func (u *TagUpsertBulk) UpdateNewValues() *TagUpsertBulk

UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:

client.Tag.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

type TagUpsertOne

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

TagUpsertOne is the builder for "upsert"-ing

one Tag node.

func (*TagUpsertOne) ApplyDomain

func (u *TagUpsertOne) ApplyDomain(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) (*TagUpsertOne, error)

ApplyDomain applies domain.Tag fields to the TagUpsertOne builder on conflict.

Note: ctx is accepted for API symmetry. Transformer hooks do not fire on upsert conflict paths; the error return is always nil.

func (*TagUpsertOne) ApplyDomainX

func (u *TagUpsertOne) ApplyDomainX(ctx context.Context, d *domain.Tag, opts ...entdomain.ApplyOption) *TagUpsertOne

ApplyDomainX is the panicking variant of ApplyDomain. See *TagCreate.ApplyDomainX.

func (*TagUpsertOne) DoNothing

func (u *TagUpsertOne) DoNothing() *TagUpsertOne

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*TagUpsertOne) Exec

func (u *TagUpsertOne) Exec(ctx context.Context) error

Exec executes the query.

func (*TagUpsertOne) ExecX

func (u *TagUpsertOne) ExecX(ctx context.Context)

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

func (*TagUpsertOne) ID

func (u *TagUpsertOne) ID(ctx context.Context) (id int, err error)

Exec executes the UPSERT query and returns the inserted/updated ID.

func (*TagUpsertOne) IDX

func (u *TagUpsertOne) IDX(ctx context.Context) int

IDX is like ID, but panics if an error occurs.

func (*TagUpsertOne) Ignore

func (u *TagUpsertOne) Ignore() *TagUpsertOne

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.Tag.Create().
    OnConflict(sql.ResolveWithIgnore()).
    Exec(ctx)

func (*TagUpsertOne) SetName

func (u *TagUpsertOne) SetName(v string) *TagUpsertOne

SetName sets the "name" field.

func (*TagUpsertOne) Update

func (u *TagUpsertOne) Update(set func(*TagUpsert)) *TagUpsertOne

Update allows overriding fields `UPDATE` values. See the TagCreate.OnConflict documentation for more info.

func (*TagUpsertOne) UpdateName

func (u *TagUpsertOne) UpdateName() *TagUpsertOne

UpdateName sets the "name" field to the value that was provided on create.

func (*TagUpsertOne) UpdateNewValues

func (u *TagUpsertOne) UpdateNewValues() *TagUpsertOne

UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:

client.Tag.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

type Tags

type Tags []*Tag

Tags is a parsable slice of Tag.

func (Tags) ToDomain

func (es Tags) ToDomain() domain.TagList

ToDomain maps a slice of ent Tag to domain.TagList.

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 {

	// Post is the client for interacting with the Post builders.
	Post *PostClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// 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 User

type User struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Bio holds the value of the "bio" field.
	Bio string `json:"bio,omitempty"`
	// Status holds the value of the "status" field.
	Status user.Status `json:"status,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Username holds the value of the "username" field.
	Username string `json:"username,omitempty"`
	// Score holds the value of the "score" field.
	Score int `json:"score,omitempty"`
	// ExternalID holds the value of the "external_id" field.
	ExternalID uuid.UUID `json:"external_id,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Settings holds the value of the "settings" field.
	Settings map[string]interface{} `json:"settings,omitempty"`
	// Labels holds the value of the "labels" field.
	Labels map[string]interface{} `json:"labels,omitempty"`
	// TagNames holds the value of the "tag_names" field.
	TagNames []string `json:"tag_names,omitempty"`
	// Metadata holds the value of the "metadata" field.
	Metadata domain.UserMetadata `json:"metadata,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the UserQuery when eager-loading is set.
	Edges UserEdges `json:"edges"`
	// contains filtered or unexported fields
}

User is the model entity for the User schema.

func (*User) QueryPinnedPost

func (_m *User) QueryPinnedPost() *PostQuery

QueryPinnedPost queries the "pinned_post" edge of the User entity.

func (*User) QueryPosts

func (_m *User) QueryPosts() *PostQuery

QueryPosts queries the "posts" edge of the User entity.

func (*User) QueryTags

func (_m *User) QueryTags() *TagQuery

QueryTags queries the "tags" edge of the User entity.

func (*User) String

func (_m *User) String() string

String implements the fmt.Stringer.

func (*User) ToDomain

func (e *User) ToDomain() *domain.User

ToDomain maps the ent User to a domain.User.

func (*User) Unwrap

func (_m *User) Unwrap() *User

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

func (_m *User) Update() *UserUpdateOne

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

func (*User) Value

func (_m *User) Value(name string) (ent.Value, error)

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

NewUserClient returns a client for the User from the given config.

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a builder for creating a User entity.

func (*UserClient) CreateBulk

func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk

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

func (*UserClient) CreateBulkDomain

func (c *UserClient) CreateBulkDomain(ctx context.Context, ds domain.UserList, opts ...entdomain.ApplyOption) (*UserCreateBulk, error)

CreateBulkDomain creates a UserCreateBulk from domain.UserList.

If any per-row transformer returns an error, the first such error is returned immediately and partial bulk is discarded.

func (*UserClient) CreateBulkDomainX

func (c *UserClient) CreateBulkDomainX(ctx context.Context, ds domain.UserList, opts ...entdomain.ApplyOption) *UserCreateBulk

CreateBulkDomainX is the panicking variant of CreateBulkDomain. See *UserCreate.ApplyDomainX for the convention.

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*UserClient) DeleteOneID

func (c *UserClient) DeleteOneID(id int) *UserDeleteOne

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

func (*UserClient) Get

func (c *UserClient) Get(ctx context.Context, id int) (*User, error)

Get returns a User entity by its id.

func (*UserClient) GetX

func (c *UserClient) GetX(ctx context.Context, id int) *User

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

func (*UserClient) Hooks

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

Hooks returns the client hooks.

func (*UserClient) Intercept

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

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

func (*UserClient) Interceptors

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

Interceptors returns the client interceptors.

func (*UserClient) MapCreateBulk

func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk

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

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QueryPinnedPost

func (c *UserClient) QueryPinnedPost(_m *User) *PostQuery

QueryPinnedPost queries the pinned_post edge of a User.

func (*UserClient) QueryPosts

func (c *UserClient) QueryPosts(_m *User) *PostQuery

QueryPosts queries the posts edge of a User.

func (*UserClient) QueryTags

func (c *UserClient) QueryTags(_m *User) *TagQuery

QueryTags queries the tags edge of a User.

func (*UserClient) Update

func (c *UserClient) Update() *UserUpdate

Update returns an update builder for User.

func (*UserClient) UpdateBulkDomain

func (c *UserClient) UpdateBulkDomain(ctx context.Context, ds domain.UserList, opts ...entdomain.ApplyOption) (*UserUpdateOneBulk, error)

UpdateBulkDomain returns a UserUpdateOneBulk from domain.UserList. Each builder is keyed on ds[i].ID.

If any per-row transformer returns an error, the first such error is returned immediately and partial bulk is discarded.

func (*UserClient) UpdateBulkDomainX

func (c *UserClient) UpdateBulkDomainX(ctx context.Context, ds domain.UserList, opts ...entdomain.ApplyOption) *UserUpdateOneBulk

UpdateBulkDomainX is the panicking variant of UpdateBulkDomain. See *UserCreate.ApplyDomainX for the convention.

func (*UserClient) UpdateOne

func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne

UpdateOne returns an update builder for the given entity.

func (*UserClient) UpdateOneID

func (c *UserClient) UpdateOneID(id int) *UserUpdateOne

UpdateOneID returns an update builder for the given id.

func (*UserClient) Use

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

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

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddPostIDs

func (_c *UserCreate) AddPostIDs(ids ...int) *UserCreate

AddPostIDs adds the "posts" edge to the Post entity by IDs.

func (*UserCreate) AddPosts

func (_c *UserCreate) AddPosts(v ...*Post) *UserCreate

AddPosts adds the "posts" edges to the Post entity.

func (*UserCreate) AddTagIDs

func (_c *UserCreate) AddTagIDs(ids ...int) *UserCreate

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*UserCreate) AddTags

func (_c *UserCreate) AddTags(v ...*Tag) *UserCreate

AddTags adds the "tags" edges to the Tag entity.

func (*UserCreate) ApplyDomain

func (c *UserCreate) ApplyDomain(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) (*UserCreate, error)

ApplyDomain applies domain.User fields to the UserCreate builder.

func (*UserCreate) ApplyDomainX

func (c *UserCreate) ApplyDomainX(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) *UserCreate

ApplyDomainX is the panicking variant of ApplyDomain. It enables fluent chaining at the cost of converting transformer errors into panics. Mirrors ent's SaveX/FirstX/OnlyX convention: use in tests and scripts, prefer ApplyDomain on request paths where transformer errors (e.g. KMS failures) must be recoverable.

func (*UserCreate) Exec

func (_c *UserCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreate) ExecX

func (_c *UserCreate) ExecX(ctx context.Context)

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

func (*UserCreate) Mutation

func (_c *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) OnConflict

func (_c *UserCreate) OnConflict(opts ...sql.ConflictOption) *UserUpsertOne

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.User.Create().
	SetName(v).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.UserUpsert) {
		SetName(v+v).
	}).
	Exec(ctx)

func (*UserCreate) OnConflictColumns

func (_c *UserCreate) OnConflictColumns(columns ...string) *UserUpsertOne

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.User.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*UserCreate) Save

func (_c *UserCreate) Save(ctx context.Context) (*User, error)

Save creates the User in the database.

func (*UserCreate) SaveX

func (_c *UserCreate) SaveX(ctx context.Context) *User

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetBio

func (_c *UserCreate) SetBio(v string) *UserCreate

SetBio sets the "bio" field.

func (*UserCreate) SetCreatedAt

func (_c *UserCreate) SetCreatedAt(v time.Time) *UserCreate

SetCreatedAt sets the "created_at" field.

func (*UserCreate) SetExternalID

func (_c *UserCreate) SetExternalID(v uuid.UUID) *UserCreate

SetExternalID sets the "external_id" field.

func (*UserCreate) SetLabels

func (_c *UserCreate) SetLabels(v map[string]interface{}) *UserCreate

SetLabels sets the "labels" field.

func (*UserCreate) SetMetadata

func (_c *UserCreate) SetMetadata(v domain.UserMetadata) *UserCreate

SetMetadata sets the "metadata" field.

func (*UserCreate) SetName

func (_c *UserCreate) SetName(v string) *UserCreate

SetName sets the "name" field.

func (*UserCreate) SetNillableBio

func (_c *UserCreate) SetNillableBio(v *string) *UserCreate

SetNillableBio sets the "bio" field if the given value is not nil.

func (*UserCreate) SetNillableCreatedAt

func (_c *UserCreate) SetNillableCreatedAt(v *time.Time) *UserCreate

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

func (*UserCreate) SetNillablePinnedPostID

func (_c *UserCreate) SetNillablePinnedPostID(id *int) *UserCreate

SetNillablePinnedPostID sets the "pinned_post" edge to the Post entity by ID if the given value is not nil.

func (*UserCreate) SetNillableScore

func (_c *UserCreate) SetNillableScore(v *int) *UserCreate

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

func (*UserCreate) SetNillableStatus

func (_c *UserCreate) SetNillableStatus(v *user.Status) *UserCreate

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

func (*UserCreate) SetNillableUpdatedAt

func (_c *UserCreate) SetNillableUpdatedAt(v *time.Time) *UserCreate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*UserCreate) SetPinnedPost

func (_c *UserCreate) SetPinnedPost(v *Post) *UserCreate

SetPinnedPost sets the "pinned_post" edge to the Post entity.

func (*UserCreate) SetPinnedPostID

func (_c *UserCreate) SetPinnedPostID(id int) *UserCreate

SetPinnedPostID sets the "pinned_post" edge to the Post entity by ID.

func (*UserCreate) SetScore

func (_c *UserCreate) SetScore(v int) *UserCreate

SetScore sets the "score" field.

func (*UserCreate) SetSettings

func (_c *UserCreate) SetSettings(v map[string]interface{}) *UserCreate

SetSettings sets the "settings" field.

func (*UserCreate) SetStatus

func (_c *UserCreate) SetStatus(v user.Status) *UserCreate

SetStatus sets the "status" field.

func (*UserCreate) SetTagNames

func (_c *UserCreate) SetTagNames(v []string) *UserCreate

SetTagNames sets the "tag_names" field.

func (*UserCreate) SetUpdatedAt

func (_c *UserCreate) SetUpdatedAt(v time.Time) *UserCreate

SetUpdatedAt sets the "updated_at" field.

func (*UserCreate) SetUsername

func (_c *UserCreate) SetUsername(v string) *UserCreate

SetUsername sets the "username" field.

type UserCreateBulk

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

UserCreateBulk is the builder for creating many User entities in bulk.

func (*UserCreateBulk) Exec

func (_c *UserCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreateBulk) ExecX

func (_c *UserCreateBulk) ExecX(ctx context.Context)

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

func (*UserCreateBulk) OnConflict

func (_c *UserCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserUpsertBulk

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.User.CreateBulk(builders...).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.UserUpsert) {
		SetName(v+v).
	}).
	Exec(ctx)

func (*UserCreateBulk) OnConflictColumns

func (_c *UserCreateBulk) OnConflictColumns(columns ...string) *UserUpsertBulk

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.User.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*UserCreateBulk) Save

func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error)

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

func (_d *UserDelete) Exec(ctx context.Context) (int, error)

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

func (*UserDelete) ExecX

func (_d *UserDelete) ExecX(ctx context.Context) int

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

func (*UserDelete) Where

func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

func (_d *UserDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

func (_d *UserDeleteOne) ExecX(ctx context.Context)

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

func (*UserDeleteOne) Where

func (_d *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne

Where appends a list predicates to the UserDelete builder.

type UserDomainField

type UserDomainField = string

UserDomainField is the type for User domain field constants.

const (
	UserDomainFieldName         UserDomainField = "name"
	UserDomainFieldBio          UserDomainField = "bio"
	UserDomainFieldStatus       UserDomainField = "status"
	UserDomainFieldCreatedAt    UserDomainField = "created_at"
	UserDomainFieldUsername     UserDomainField = "username"
	UserDomainFieldScore        UserDomainField = "score"
	UserDomainFieldExternalID   UserDomainField = "external_id"
	UserDomainFieldUpdatedAt    UserDomainField = "updated_at"
	UserDomainFieldSettings     UserDomainField = "settings"
	UserDomainFieldLabels       UserDomainField = "labels"
	UserDomainFieldTagNames     UserDomainField = "tag_names"
	UserDomainFieldMetadata     UserDomainField = "metadata"
	UserDomainFieldPostIDs      UserDomainField = "post_ids"
	UserDomainFieldPinnedPostID UserDomainField = "pinned_post_id"
	UserDomainFieldTagIDs       UserDomainField = "tag_ids"
)

type UserDomainTransformer

type UserDomainTransformer struct {
	GetFullName                     func(e *User) string
	SetFullNameOnCreate             func(ctx context.Context, c *UserCreate, d *domain.User, val string) error
	SetFullNameOnUpdate             func(ctx context.Context, u *UserUpdateOne, d *domain.User, val string) error
	GetIsPremium                    func(e *User) bool
	SetIsPremiumOnCreate            func(ctx context.Context, c *UserCreate, d *domain.User, val bool) error
	SetIsPremiumOnUpdate            func(ctx context.Context, u *UserUpdateOne, d *domain.User, val bool) error
	GetExpiresAt                    func(e *User) time.Time
	SetExpiresAtOnCreate            func(ctx context.Context, c *UserCreate, d *domain.User, val time.Time) error
	SetExpiresAtOnUpdate            func(ctx context.Context, u *UserUpdateOne, d *domain.User, val time.Time) error
	GetSubscriptionDuration         func(e *User) time.Duration
	SetSubscriptionDurationOnCreate func(ctx context.Context, c *UserCreate, d *domain.User, val time.Duration) error
	SetSubscriptionDurationOnUpdate func(ctx context.Context, u *UserUpdateOne, d *domain.User, val time.Duration) error
}

UserDomainTransformer holds optional transformer functions for User → domain mapping.

Get* functions are pure synchronous projections invoked by ToDomain. Set*OnCreate / Set*OnUpdate are invoked during ApplyDomain and may perform I/O (e.g. KMS-backed field encryption); they receive ctx + the full domain struct so they can access sibling fields and propagate cancellation.

var UserTransformer *UserDomainTransformer

UserTransformer is the package-level transformer for User (nil by default).

type UserEdges

type UserEdges struct {
	// Posts holds the value of the posts edge.
	Posts []*Post `json:"posts,omitempty"`
	// PinnedPost holds the value of the pinned_post edge.
	PinnedPost *Post `json:"pinned_post,omitempty"`
	// Tags holds the value of the tags edge.
	Tags []*Tag `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

UserEdges holds the relations/edges for other nodes in the graph.

func (UserEdges) PinnedPostOrErr

func (e UserEdges) PinnedPostOrErr() (*Post, error)

PinnedPostOrErr returns the PinnedPost value or an error if the edge was not loaded in eager-loading, or loaded but was not found.

func (UserEdges) PostsOrErr

func (e UserEdges) PostsOrErr() ([]*Post, error)

PostsOrErr returns the Posts value or an error if the edge was not loaded in eager-loading.

func (UserEdges) TagsOrErr

func (e UserEdges) TagsOrErr() ([]*Tag, error)

TagsOrErr returns the Tags value or an error if the edge was not loaded in eager-loading.

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

func (_g *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy

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

func (*UserGroupBy) Bool

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

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

func (*UserGroupBy) BoolX

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

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

func (*UserGroupBy) Bools

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

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

func (*UserGroupBy) BoolsX

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

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

func (*UserGroupBy) Float64

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

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

func (*UserGroupBy) Float64X

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

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

func (*UserGroupBy) Float64s

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

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

func (*UserGroupBy) Float64sX

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

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

func (*UserGroupBy) Int

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

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

func (*UserGroupBy) IntX

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

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

func (*UserGroupBy) Ints

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

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

func (*UserGroupBy) IntsX

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

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

func (*UserGroupBy) Scan

func (_g *UserGroupBy) Scan(ctx context.Context, v any) error

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

func (*UserGroupBy) ScanX

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

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

func (*UserGroupBy) String

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

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

func (*UserGroupBy) StringX

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

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

func (*UserGroupBy) Strings

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

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

func (*UserGroupBy) StringsX

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

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

type UserMutation

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

UserMutation represents an operation that mutates the User nodes in the graph.

func (*UserMutation) AddField

func (m *UserMutation) 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 (*UserMutation) AddPostIDs

func (m *UserMutation) AddPostIDs(ids ...int)

AddPostIDs adds the "posts" edge to the Post entity by ids.

func (*UserMutation) AddScore

func (m *UserMutation) AddScore(i int)

AddScore adds i to the "score" field.

func (*UserMutation) AddTagIDs

func (m *UserMutation) AddTagIDs(ids ...int)

AddTagIDs adds the "tags" edge to the Tag entity by ids.

func (*UserMutation) AddedEdges

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

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

func (*UserMutation) AddedField

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

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

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

func (*UserMutation) AddedIDs

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

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

func (*UserMutation) AddedScore

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

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

func (*UserMutation) AppendTagNames

func (m *UserMutation) AppendTagNames(s []string)

AppendTagNames adds s to the "tag_names" field.

func (*UserMutation) AppendedTagNames

func (m *UserMutation) AppendedTagNames() ([]string, bool)

AppendedTagNames returns the list of values that were appended to the "tag_names" field in this mutation.

func (*UserMutation) Bio

func (m *UserMutation) Bio() (r string, exists bool)

Bio returns the value of the "bio" field in the mutation.

func (*UserMutation) BioCleared

func (m *UserMutation) BioCleared() bool

BioCleared returns if the "bio" field was cleared in this mutation.

func (*UserMutation) ClearBio

func (m *UserMutation) ClearBio()

ClearBio clears the value of the "bio" field.

func (*UserMutation) ClearEdge

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

func (m *UserMutation) 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 (*UserMutation) ClearPinnedPost

func (m *UserMutation) ClearPinnedPost()

ClearPinnedPost clears the "pinned_post" edge to the Post entity.

func (*UserMutation) ClearPosts

func (m *UserMutation) ClearPosts()

ClearPosts clears the "posts" edge to the Post entity.

func (*UserMutation) ClearScore

func (m *UserMutation) ClearScore()

ClearScore clears the value of the "score" field.

func (*UserMutation) ClearSettings

func (m *UserMutation) ClearSettings()

ClearSettings clears the value of the "settings" field.

func (*UserMutation) ClearTags

func (m *UserMutation) ClearTags()

ClearTags clears the "tags" edge to the Tag entity.

func (*UserMutation) ClearUpdatedAt

func (m *UserMutation) ClearUpdatedAt()

ClearUpdatedAt clears the value of the "updated_at" field.

func (*UserMutation) ClearedEdges

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

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

func (*UserMutation) ClearedFields

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

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

func (UserMutation) Client

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

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

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

func (*UserMutation) EdgeCleared

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

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

func (*UserMutation) ExternalID

func (m *UserMutation) ExternalID() (r uuid.UUID, exists bool)

ExternalID returns the value of the "external_id" field in the mutation.

func (*UserMutation) Field

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

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

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

func (*UserMutation) Fields

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

func (m *UserMutation) ID() (id int, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.

func (*UserMutation) IDs

func (m *UserMutation) IDs(ctx context.Context) ([]int, error)

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

func (*UserMutation) Labels

func (m *UserMutation) Labels() (r map[string]interface{}, exists bool)

Labels returns the value of the "labels" field in the mutation.

func (*UserMutation) Metadata

func (m *UserMutation) Metadata() (r domain.UserMetadata, exists bool)

Metadata returns the value of the "metadata" field in the mutation.

func (*UserMutation) Name

func (m *UserMutation) Name() (r string, exists bool)

Name returns the value of the "name" field in the mutation.

func (*UserMutation) OldBio

func (m *UserMutation) OldBio(ctx context.Context) (v string, err error)

OldBio returns the old "bio" field's value of the User entity. If the User 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 (*UserMutation) OldCreatedAt

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

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

func (m *UserMutation) OldExternalID(ctx context.Context) (v uuid.UUID, err error)

OldExternalID returns the old "external_id" field's value of the User entity. If the User 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 (*UserMutation) OldField

func (m *UserMutation) 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 (*UserMutation) OldLabels

func (m *UserMutation) OldLabels(ctx context.Context) (v map[string]interface{}, err error)

OldLabels returns the old "labels" field's value of the User entity. If the User 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 (*UserMutation) OldMetadata

func (m *UserMutation) OldMetadata(ctx context.Context) (v domain.UserMetadata, err error)

OldMetadata returns the old "metadata" field's value of the User entity. If the User 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 (*UserMutation) OldName

func (m *UserMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the User entity. If the User 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 (*UserMutation) OldScore

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

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

func (m *UserMutation) OldSettings(ctx context.Context) (v map[string]interface{}, err error)

OldSettings returns the old "settings" field's value of the User entity. If the User 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 (*UserMutation) OldStatus

func (m *UserMutation) OldStatus(ctx context.Context) (v user.Status, err error)

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

func (m *UserMutation) OldTagNames(ctx context.Context) (v []string, err error)

OldTagNames returns the old "tag_names" field's value of the User entity. If the User 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 (*UserMutation) OldUpdatedAt

func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)

OldUpdatedAt returns the old "updated_at" field's value of the User entity. If the User 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 (*UserMutation) OldUsername

func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error)

OldUsername returns the old "username" field's value of the User entity. If the User 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 (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) PinnedPostCleared

func (m *UserMutation) PinnedPostCleared() bool

PinnedPostCleared reports if the "pinned_post" edge to the Post entity was cleared.

func (*UserMutation) PinnedPostID

func (m *UserMutation) PinnedPostID() (id int, exists bool)

PinnedPostID returns the "pinned_post" edge ID in the mutation.

func (*UserMutation) PinnedPostIDs

func (m *UserMutation) PinnedPostIDs() (ids []int)

PinnedPostIDs returns the "pinned_post" edge IDs in the mutation. Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use PinnedPostID instead. It exists only for internal usage by the builders.

func (*UserMutation) PostsCleared

func (m *UserMutation) PostsCleared() bool

PostsCleared reports if the "posts" edge to the Post entity was cleared.

func (*UserMutation) PostsIDs

func (m *UserMutation) PostsIDs() (ids []int)

PostsIDs returns the "posts" edge IDs in the mutation.

func (*UserMutation) RemovePostIDs

func (m *UserMutation) RemovePostIDs(ids ...int)

RemovePostIDs removes the "posts" edge to the Post entity by IDs.

func (*UserMutation) RemoveTagIDs

func (m *UserMutation) RemoveTagIDs(ids ...int)

RemoveTagIDs removes the "tags" edge to the Tag entity by IDs.

func (*UserMutation) RemovedEdges

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

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

func (*UserMutation) RemovedIDs

func (m *UserMutation) 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 (*UserMutation) RemovedPostsIDs

func (m *UserMutation) RemovedPostsIDs() (ids []int)

RemovedPosts returns the removed IDs of the "posts" edge to the Post entity.

func (*UserMutation) RemovedTagsIDs

func (m *UserMutation) RemovedTagsIDs() (ids []int)

RemovedTags returns the removed IDs of the "tags" edge to the Tag entity.

func (*UserMutation) ResetBio

func (m *UserMutation) ResetBio()

ResetBio resets all changes to the "bio" field.

func (*UserMutation) ResetCreatedAt

func (m *UserMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*UserMutation) ResetEdge

func (m *UserMutation) 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 (*UserMutation) ResetExternalID

func (m *UserMutation) ResetExternalID()

ResetExternalID resets all changes to the "external_id" field.

func (*UserMutation) ResetField

func (m *UserMutation) 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 (*UserMutation) ResetLabels

func (m *UserMutation) ResetLabels()

ResetLabels resets all changes to the "labels" field.

func (*UserMutation) ResetMetadata

func (m *UserMutation) ResetMetadata()

ResetMetadata resets all changes to the "metadata" field.

func (*UserMutation) ResetName

func (m *UserMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*UserMutation) ResetPinnedPost

func (m *UserMutation) ResetPinnedPost()

ResetPinnedPost resets all changes to the "pinned_post" edge.

func (*UserMutation) ResetPosts

func (m *UserMutation) ResetPosts()

ResetPosts resets all changes to the "posts" edge.

func (*UserMutation) ResetScore

func (m *UserMutation) ResetScore()

ResetScore resets all changes to the "score" field.

func (*UserMutation) ResetSettings

func (m *UserMutation) ResetSettings()

ResetSettings resets all changes to the "settings" field.

func (*UserMutation) ResetStatus

func (m *UserMutation) ResetStatus()

ResetStatus resets all changes to the "status" field.

func (*UserMutation) ResetTagNames

func (m *UserMutation) ResetTagNames()

ResetTagNames resets all changes to the "tag_names" field.

func (*UserMutation) ResetTags

func (m *UserMutation) ResetTags()

ResetTags resets all changes to the "tags" edge.

func (*UserMutation) ResetUpdatedAt

func (m *UserMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*UserMutation) ResetUsername

func (m *UserMutation) ResetUsername()

ResetUsername resets all changes to the "username" field.

func (*UserMutation) Score

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

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

func (*UserMutation) ScoreCleared

func (m *UserMutation) ScoreCleared() bool

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

func (*UserMutation) SetBio

func (m *UserMutation) SetBio(s string)

SetBio sets the "bio" field.

func (*UserMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*UserMutation) SetExternalID

func (m *UserMutation) SetExternalID(u uuid.UUID)

SetExternalID sets the "external_id" field.

func (*UserMutation) SetField

func (m *UserMutation) 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 (*UserMutation) SetLabels

func (m *UserMutation) SetLabels(value map[string]interface{})

SetLabels sets the "labels" field.

func (*UserMutation) SetMetadata

func (m *UserMutation) SetMetadata(dm domain.UserMetadata)

SetMetadata sets the "metadata" field.

func (*UserMutation) SetName

func (m *UserMutation) SetName(s string)

SetName sets the "name" field.

func (*UserMutation) SetOp

func (m *UserMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*UserMutation) SetPinnedPostID

func (m *UserMutation) SetPinnedPostID(id int)

SetPinnedPostID sets the "pinned_post" edge to the Post entity by id.

func (*UserMutation) SetScore

func (m *UserMutation) SetScore(i int)

SetScore sets the "score" field.

func (*UserMutation) SetSettings

func (m *UserMutation) SetSettings(value map[string]interface{})

SetSettings sets the "settings" field.

func (*UserMutation) SetStatus

func (m *UserMutation) SetStatus(u user.Status)

SetStatus sets the "status" field.

func (*UserMutation) SetTagNames

func (m *UserMutation) SetTagNames(s []string)

SetTagNames sets the "tag_names" field.

func (*UserMutation) SetUpdatedAt

func (m *UserMutation) SetUpdatedAt(t time.Time)

SetUpdatedAt sets the "updated_at" field.

func (*UserMutation) SetUsername

func (m *UserMutation) SetUsername(s string)

SetUsername sets the "username" field.

func (*UserMutation) Settings

func (m *UserMutation) Settings() (r map[string]interface{}, exists bool)

Settings returns the value of the "settings" field in the mutation.

func (*UserMutation) SettingsCleared

func (m *UserMutation) SettingsCleared() bool

SettingsCleared returns if the "settings" field was cleared in this mutation.

func (*UserMutation) Status

func (m *UserMutation) Status() (r user.Status, exists bool)

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

func (*UserMutation) TagNames

func (m *UserMutation) TagNames() (r []string, exists bool)

TagNames returns the value of the "tag_names" field in the mutation.

func (*UserMutation) TagsCleared

func (m *UserMutation) TagsCleared() bool

TagsCleared reports if the "tags" edge to the Tag entity was cleared.

func (*UserMutation) TagsIDs

func (m *UserMutation) TagsIDs() (ids []int)

TagsIDs returns the "tags" edge IDs in the mutation.

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) UpdatedAt

func (m *UserMutation) UpdatedAt() (r time.Time, exists bool)

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (*UserMutation) UpdatedAtCleared

func (m *UserMutation) UpdatedAtCleared() bool

UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.

func (*UserMutation) Username

func (m *UserMutation) Username() (r string, exists bool)

Username returns the value of the "username" field in the mutation.

func (*UserMutation) Where

func (m *UserMutation) Where(ps ...predicate.User)

Where appends a list predicates to the UserMutation builder.

func (*UserMutation) WhereP

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

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

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) Aggregate

func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate returns a UserSelect configured with the given aggregations.

func (*UserQuery) All

func (_q *UserQuery) All(ctx context.Context) ([]*User, error)

All executes the query and returns a list of Users.

func (*UserQuery) AllX

func (_q *UserQuery) AllX(ctx context.Context) []*User

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

func (*UserQuery) Clone

func (_q *UserQuery) Clone() *UserQuery

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

func (*UserQuery) Count

func (_q *UserQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*UserQuery) CountX

func (_q *UserQuery) CountX(ctx context.Context) int

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

func (*UserQuery) Exist

func (_q *UserQuery) Exist(ctx context.Context) (bool, error)

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

func (*UserQuery) ExistX

func (_q *UserQuery) ExistX(ctx context.Context) bool

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

func (*UserQuery) First

func (_q *UserQuery) First(ctx context.Context) (*User, error)

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

func (*UserQuery) FirstID

func (_q *UserQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*UserQuery) FirstIDX

func (_q *UserQuery) FirstIDX(ctx context.Context) int

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

func (*UserQuery) FirstX

func (_q *UserQuery) FirstX(ctx context.Context) *User

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

func (*UserQuery) GroupBy

func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
	Count int `json:"count,omitempty"`
}

client.User.Query().
	GroupBy(user.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserQuery) IDs

func (_q *UserQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*UserQuery) IDsX

func (_q *UserQuery) IDsX(ctx context.Context) []int

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

func (*UserQuery) Limit

func (_q *UserQuery) Limit(limit int) *UserQuery

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

func (*UserQuery) Offset

func (_q *UserQuery) Offset(offset int) *UserQuery

Offset to start from.

func (*UserQuery) Only

func (_q *UserQuery) Only(ctx context.Context) (*User, error)

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

func (*UserQuery) OnlyID

func (_q *UserQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*UserQuery) OnlyIDX

func (_q *UserQuery) OnlyIDX(ctx context.Context) int

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

func (*UserQuery) OnlyX

func (_q *UserQuery) OnlyX(ctx context.Context) *User

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

func (*UserQuery) Order

func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery

Order specifies how the records should be ordered.

func (*UserQuery) QueryPinnedPost

func (_q *UserQuery) QueryPinnedPost() *PostQuery

QueryPinnedPost chains the current query on the "pinned_post" edge.

func (*UserQuery) QueryPosts

func (_q *UserQuery) QueryPosts() *PostQuery

QueryPosts chains the current query on the "posts" edge.

func (*UserQuery) QueryTags

func (_q *UserQuery) QueryTags() *TagQuery

QueryTags chains the current query on the "tags" edge.

func (*UserQuery) Select

func (_q *UserQuery) Select(fields ...string) *UserSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.User.Query().
	Select(user.FieldName).
	Scan(ctx, &v)

func (*UserQuery) Unique

func (_q *UserQuery) Unique(unique bool) *UserQuery

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

func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithPinnedPost

func (_q *UserQuery) WithPinnedPost(opts ...func(*PostQuery)) *UserQuery

WithPinnedPost tells the query-builder to eager-load the nodes that are connected to the "pinned_post" edge. The optional arguments are used to configure the query builder of the edge.

func (*UserQuery) WithPosts

func (_q *UserQuery) WithPosts(opts ...func(*PostQuery)) *UserQuery

WithPosts tells the query-builder to eager-load the nodes that are connected to the "posts" edge. The optional arguments are used to configure the query builder of the edge.

func (*UserQuery) WithTags

func (_q *UserQuery) WithTags(opts ...func(*TagQuery)) *UserQuery

WithTags tells the query-builder to eager-load the nodes that are connected to the "tags" edge. The optional arguments are used to configure the query builder of the edge.

type UserSelect

type UserSelect struct {
	*UserQuery
	// contains filtered or unexported fields
}

UserSelect is the builder for selecting fields of User entities.

func (*UserSelect) Aggregate

func (_s *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate adds the given aggregation functions to the selector query.

func (*UserSelect) Bool

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

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

func (*UserSelect) BoolX

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

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

func (*UserSelect) Bools

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

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

func (*UserSelect) BoolsX

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

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

func (*UserSelect) Float64

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

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

func (*UserSelect) Float64X

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

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

func (*UserSelect) Float64s

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

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

func (*UserSelect) Float64sX

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

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

func (*UserSelect) Int

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

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

func (*UserSelect) IntX

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

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

func (*UserSelect) Ints

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

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

func (*UserSelect) IntsX

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

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

func (*UserSelect) Scan

func (_s *UserSelect) Scan(ctx context.Context, v any) error

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

func (*UserSelect) ScanX

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

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

func (*UserSelect) String

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

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

func (*UserSelect) StringX

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

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

func (*UserSelect) Strings

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

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

func (*UserSelect) StringsX

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

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

type UserUpdate

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

UserUpdate is the builder for updating User entities.

func (*UserUpdate) AddPostIDs

func (_u *UserUpdate) AddPostIDs(ids ...int) *UserUpdate

AddPostIDs adds the "posts" edge to the Post entity by IDs.

func (*UserUpdate) AddPosts

func (_u *UserUpdate) AddPosts(v ...*Post) *UserUpdate

AddPosts adds the "posts" edges to the Post entity.

func (*UserUpdate) AddScore

func (_u *UserUpdate) AddScore(v int) *UserUpdate

AddScore adds value to the "score" field.

func (*UserUpdate) AddTagIDs

func (_u *UserUpdate) AddTagIDs(ids ...int) *UserUpdate

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*UserUpdate) AddTags

func (_u *UserUpdate) AddTags(v ...*Tag) *UserUpdate

AddTags adds the "tags" edges to the Tag entity.

func (*UserUpdate) AppendTagNames

func (_u *UserUpdate) AppendTagNames(v []string) *UserUpdate

AppendTagNames appends value to the "tag_names" field.

func (*UserUpdate) ApplyDomain

func (u *UserUpdate) ApplyDomain(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) (*UserUpdate, error)

ApplyDomain applies domain.User fields to the UserUpdate builder. Chain .Where(...) conditions to target specific records.

Note: ctx is accepted for API symmetry with ApplyDomainCreate/UpdateOne and to allow future ctx-aware field transformers. Currently no transformer hooks fire here — the error return is always nil.

func (*UserUpdate) ApplyDomainX

func (u *UserUpdate) ApplyDomainX(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) *UserUpdate

ApplyDomainX is the panicking variant of ApplyDomain. See *UserCreate.ApplyDomainX.

func (*UserUpdate) ClearBio

func (_u *UserUpdate) ClearBio() *UserUpdate

ClearBio clears the value of the "bio" field.

func (*UserUpdate) ClearPinnedPost

func (_u *UserUpdate) ClearPinnedPost() *UserUpdate

ClearPinnedPost clears the "pinned_post" edge to the Post entity.

func (*UserUpdate) ClearPosts

func (_u *UserUpdate) ClearPosts() *UserUpdate

ClearPosts clears all "posts" edges to the Post entity.

func (*UserUpdate) ClearScore

func (_u *UserUpdate) ClearScore() *UserUpdate

ClearScore clears the value of the "score" field.

func (*UserUpdate) ClearSettings

func (_u *UserUpdate) ClearSettings() *UserUpdate

ClearSettings clears the value of the "settings" field.

func (*UserUpdate) ClearTags

func (_u *UserUpdate) ClearTags() *UserUpdate

ClearTags clears all "tags" edges to the Tag entity.

func (*UserUpdate) ClearUpdatedAt

func (_u *UserUpdate) ClearUpdatedAt() *UserUpdate

ClearUpdatedAt clears the value of the "updated_at" field.

func (*UserUpdate) Exec

func (_u *UserUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpdate) ExecX

func (_u *UserUpdate) ExecX(ctx context.Context)

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

func (*UserUpdate) Mutation

func (_u *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemovePostIDs

func (_u *UserUpdate) RemovePostIDs(ids ...int) *UserUpdate

RemovePostIDs removes the "posts" edge to Post entities by IDs.

func (*UserUpdate) RemovePosts

func (_u *UserUpdate) RemovePosts(v ...*Post) *UserUpdate

RemovePosts removes "posts" edges to Post entities.

func (*UserUpdate) RemoveTagIDs

func (_u *UserUpdate) RemoveTagIDs(ids ...int) *UserUpdate

RemoveTagIDs removes the "tags" edge to Tag entities by IDs.

func (*UserUpdate) RemoveTags

func (_u *UserUpdate) RemoveTags(v ...*Tag) *UserUpdate

RemoveTags removes "tags" edges to Tag entities.

func (*UserUpdate) Save

func (_u *UserUpdate) Save(ctx context.Context) (int, error)

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

func (*UserUpdate) SaveX

func (_u *UserUpdate) SaveX(ctx context.Context) int

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

func (*UserUpdate) SetBio

func (_u *UserUpdate) SetBio(v string) *UserUpdate

SetBio sets the "bio" field.

func (*UserUpdate) SetExternalID

func (_u *UserUpdate) SetExternalID(v uuid.UUID) *UserUpdate

SetExternalID sets the "external_id" field.

func (*UserUpdate) SetLabels

func (_u *UserUpdate) SetLabels(v map[string]interface{}) *UserUpdate

SetLabels sets the "labels" field.

func (*UserUpdate) SetMetadata

func (_u *UserUpdate) SetMetadata(v domain.UserMetadata) *UserUpdate

SetMetadata sets the "metadata" field.

func (*UserUpdate) SetName

func (_u *UserUpdate) SetName(v string) *UserUpdate

SetName sets the "name" field.

func (*UserUpdate) SetNillableBio

func (_u *UserUpdate) SetNillableBio(v *string) *UserUpdate

SetNillableBio sets the "bio" field if the given value is not nil.

func (*UserUpdate) SetNillableExternalID

func (_u *UserUpdate) SetNillableExternalID(v *uuid.UUID) *UserUpdate

SetNillableExternalID sets the "external_id" field if the given value is not nil.

func (*UserUpdate) SetNillableMetadata

func (_u *UserUpdate) SetNillableMetadata(v *domain.UserMetadata) *UserUpdate

SetNillableMetadata sets the "metadata" field if the given value is not nil.

func (*UserUpdate) SetNillableName

func (_u *UserUpdate) SetNillableName(v *string) *UserUpdate

SetNillableName sets the "name" field if the given value is not nil.

func (*UserUpdate) SetNillablePinnedPostID

func (_u *UserUpdate) SetNillablePinnedPostID(id *int) *UserUpdate

SetNillablePinnedPostID sets the "pinned_post" edge to the Post entity by ID if the given value is not nil.

func (*UserUpdate) SetNillableScore

func (_u *UserUpdate) SetNillableScore(v *int) *UserUpdate

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

func (*UserUpdate) SetNillableStatus

func (_u *UserUpdate) SetNillableStatus(v *user.Status) *UserUpdate

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

func (*UserUpdate) SetNillableUpdatedAt

func (_u *UserUpdate) SetNillableUpdatedAt(v *time.Time) *UserUpdate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*UserUpdate) SetPinnedPost

func (_u *UserUpdate) SetPinnedPost(v *Post) *UserUpdate

SetPinnedPost sets the "pinned_post" edge to the Post entity.

func (*UserUpdate) SetPinnedPostID

func (_u *UserUpdate) SetPinnedPostID(id int) *UserUpdate

SetPinnedPostID sets the "pinned_post" edge to the Post entity by ID.

func (*UserUpdate) SetScore

func (_u *UserUpdate) SetScore(v int) *UserUpdate

SetScore sets the "score" field.

func (*UserUpdate) SetSettings

func (_u *UserUpdate) SetSettings(v map[string]interface{}) *UserUpdate

SetSettings sets the "settings" field.

func (*UserUpdate) SetStatus

func (_u *UserUpdate) SetStatus(v user.Status) *UserUpdate

SetStatus sets the "status" field.

func (*UserUpdate) SetTagNames

func (_u *UserUpdate) SetTagNames(v []string) *UserUpdate

SetTagNames sets the "tag_names" field.

func (*UserUpdate) SetUpdatedAt

func (_u *UserUpdate) SetUpdatedAt(v time.Time) *UserUpdate

SetUpdatedAt sets the "updated_at" field.

func (*UserUpdate) Where

func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOne

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

UserUpdateOne is the builder for updating a single User entity.

func (*UserUpdateOne) AddPostIDs

func (_u *UserUpdateOne) AddPostIDs(ids ...int) *UserUpdateOne

AddPostIDs adds the "posts" edge to the Post entity by IDs.

func (*UserUpdateOne) AddPosts

func (_u *UserUpdateOne) AddPosts(v ...*Post) *UserUpdateOne

AddPosts adds the "posts" edges to the Post entity.

func (*UserUpdateOne) AddScore

func (_u *UserUpdateOne) AddScore(v int) *UserUpdateOne

AddScore adds value to the "score" field.

func (*UserUpdateOne) AddTagIDs

func (_u *UserUpdateOne) AddTagIDs(ids ...int) *UserUpdateOne

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*UserUpdateOne) AddTags

func (_u *UserUpdateOne) AddTags(v ...*Tag) *UserUpdateOne

AddTags adds the "tags" edges to the Tag entity.

func (*UserUpdateOne) AppendTagNames

func (_u *UserUpdateOne) AppendTagNames(v []string) *UserUpdateOne

AppendTagNames appends value to the "tag_names" field.

func (*UserUpdateOne) ApplyDomain

func (u *UserUpdateOne) ApplyDomain(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) (*UserUpdateOne, error)

ApplyDomain applies domain.User fields to the UserUpdateOne builder.

func (*UserUpdateOne) ApplyDomainX

func (u *UserUpdateOne) ApplyDomainX(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) *UserUpdateOne

ApplyDomainX is the panicking variant of ApplyDomain. See *UserCreate.ApplyDomainX.

func (*UserUpdateOne) ClearBio

func (_u *UserUpdateOne) ClearBio() *UserUpdateOne

ClearBio clears the value of the "bio" field.

func (*UserUpdateOne) ClearPinnedPost

func (_u *UserUpdateOne) ClearPinnedPost() *UserUpdateOne

ClearPinnedPost clears the "pinned_post" edge to the Post entity.

func (*UserUpdateOne) ClearPosts

func (_u *UserUpdateOne) ClearPosts() *UserUpdateOne

ClearPosts clears all "posts" edges to the Post entity.

func (*UserUpdateOne) ClearScore

func (_u *UserUpdateOne) ClearScore() *UserUpdateOne

ClearScore clears the value of the "score" field.

func (*UserUpdateOne) ClearSettings

func (_u *UserUpdateOne) ClearSettings() *UserUpdateOne

ClearSettings clears the value of the "settings" field.

func (*UserUpdateOne) ClearTags

func (_u *UserUpdateOne) ClearTags() *UserUpdateOne

ClearTags clears all "tags" edges to the Tag entity.

func (*UserUpdateOne) ClearUpdatedAt

func (_u *UserUpdateOne) ClearUpdatedAt() *UserUpdateOne

ClearUpdatedAt clears the value of the "updated_at" field.

func (*UserUpdateOne) Exec

func (_u *UserUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

func (_u *UserUpdateOne) ExecX(ctx context.Context)

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

func (*UserUpdateOne) Mutation

func (_u *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemovePostIDs

func (_u *UserUpdateOne) RemovePostIDs(ids ...int) *UserUpdateOne

RemovePostIDs removes the "posts" edge to Post entities by IDs.

func (*UserUpdateOne) RemovePosts

func (_u *UserUpdateOne) RemovePosts(v ...*Post) *UserUpdateOne

RemovePosts removes "posts" edges to Post entities.

func (*UserUpdateOne) RemoveTagIDs

func (_u *UserUpdateOne) RemoveTagIDs(ids ...int) *UserUpdateOne

RemoveTagIDs removes the "tags" edge to Tag entities by IDs.

func (*UserUpdateOne) RemoveTags

func (_u *UserUpdateOne) RemoveTags(v ...*Tag) *UserUpdateOne

RemoveTags removes "tags" edges to Tag entities.

func (*UserUpdateOne) Save

func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (_u *UserUpdateOne) SaveX(ctx context.Context) *User

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

func (*UserUpdateOne) Select

func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne

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

func (*UserUpdateOne) SetBio

func (_u *UserUpdateOne) SetBio(v string) *UserUpdateOne

SetBio sets the "bio" field.

func (*UserUpdateOne) SetExternalID

func (_u *UserUpdateOne) SetExternalID(v uuid.UUID) *UserUpdateOne

SetExternalID sets the "external_id" field.

func (*UserUpdateOne) SetLabels

func (_u *UserUpdateOne) SetLabels(v map[string]interface{}) *UserUpdateOne

SetLabels sets the "labels" field.

func (*UserUpdateOne) SetMetadata

func (_u *UserUpdateOne) SetMetadata(v domain.UserMetadata) *UserUpdateOne

SetMetadata sets the "metadata" field.

func (*UserUpdateOne) SetName

func (_u *UserUpdateOne) SetName(v string) *UserUpdateOne

SetName sets the "name" field.

func (*UserUpdateOne) SetNillableBio

func (_u *UserUpdateOne) SetNillableBio(v *string) *UserUpdateOne

SetNillableBio sets the "bio" field if the given value is not nil.

func (*UserUpdateOne) SetNillableExternalID

func (_u *UserUpdateOne) SetNillableExternalID(v *uuid.UUID) *UserUpdateOne

SetNillableExternalID sets the "external_id" field if the given value is not nil.

func (*UserUpdateOne) SetNillableMetadata

func (_u *UserUpdateOne) SetNillableMetadata(v *domain.UserMetadata) *UserUpdateOne

SetNillableMetadata sets the "metadata" field if the given value is not nil.

func (*UserUpdateOne) SetNillableName

func (_u *UserUpdateOne) SetNillableName(v *string) *UserUpdateOne

SetNillableName sets the "name" field if the given value is not nil.

func (*UserUpdateOne) SetNillablePinnedPostID

func (_u *UserUpdateOne) SetNillablePinnedPostID(id *int) *UserUpdateOne

SetNillablePinnedPostID sets the "pinned_post" edge to the Post entity by ID if the given value is not nil.

func (*UserUpdateOne) SetNillableScore

func (_u *UserUpdateOne) SetNillableScore(v *int) *UserUpdateOne

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

func (*UserUpdateOne) SetNillableStatus

func (_u *UserUpdateOne) SetNillableStatus(v *user.Status) *UserUpdateOne

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

func (*UserUpdateOne) SetNillableUpdatedAt

func (_u *UserUpdateOne) SetNillableUpdatedAt(v *time.Time) *UserUpdateOne

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*UserUpdateOne) SetPinnedPost

func (_u *UserUpdateOne) SetPinnedPost(v *Post) *UserUpdateOne

SetPinnedPost sets the "pinned_post" edge to the Post entity.

func (*UserUpdateOne) SetPinnedPostID

func (_u *UserUpdateOne) SetPinnedPostID(id int) *UserUpdateOne

SetPinnedPostID sets the "pinned_post" edge to the Post entity by ID.

func (*UserUpdateOne) SetScore

func (_u *UserUpdateOne) SetScore(v int) *UserUpdateOne

SetScore sets the "score" field.

func (*UserUpdateOne) SetSettings

func (_u *UserUpdateOne) SetSettings(v map[string]interface{}) *UserUpdateOne

SetSettings sets the "settings" field.

func (*UserUpdateOne) SetStatus

func (_u *UserUpdateOne) SetStatus(v user.Status) *UserUpdateOne

SetStatus sets the "status" field.

func (*UserUpdateOne) SetTagNames

func (_u *UserUpdateOne) SetTagNames(v []string) *UserUpdateOne

SetTagNames sets the "tag_names" field.

func (*UserUpdateOne) SetUpdatedAt

func (_u *UserUpdateOne) SetUpdatedAt(v time.Time) *UserUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*UserUpdateOne) Where

func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOneBulk

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

UserUpdateOneBulk holds a set of UserUpdateOne builders.

func (*UserUpdateOneBulk) Exec

func (b *UserUpdateOneBulk) Exec(ctx context.Context) error

Exec executes all builders without returning the updated entities.

func (*UserUpdateOneBulk) ExecX

func (b *UserUpdateOneBulk) ExecX(ctx context.Context)

ExecX is like Exec but panics on error.

func (*UserUpdateOneBulk) Save

Save executes all builders and returns the updated entities as domain.UserList.

func (*UserUpdateOneBulk) SaveX

SaveX is like Save but panics on error.

type UserUpsert

type UserUpsert struct {
	*sql.UpdateSet
}

UserUpsert is the "OnConflict" setter.

func (*UserUpsert) AddScore

func (u *UserUpsert) AddScore(v int) *UserUpsert

AddScore adds v to the "score" field.

func (*UserUpsert) ClearBio

func (u *UserUpsert) ClearBio() *UserUpsert

ClearBio clears the value of the "bio" field.

func (*UserUpsert) ClearScore

func (u *UserUpsert) ClearScore() *UserUpsert

ClearScore clears the value of the "score" field.

func (*UserUpsert) ClearSettings

func (u *UserUpsert) ClearSettings() *UserUpsert

ClearSettings clears the value of the "settings" field.

func (*UserUpsert) ClearUpdatedAt

func (u *UserUpsert) ClearUpdatedAt() *UserUpsert

ClearUpdatedAt clears the value of the "updated_at" field.

func (*UserUpsert) SetBio

func (u *UserUpsert) SetBio(v string) *UserUpsert

SetBio sets the "bio" field.

func (*UserUpsert) SetExternalID

func (u *UserUpsert) SetExternalID(v uuid.UUID) *UserUpsert

SetExternalID sets the "external_id" field.

func (*UserUpsert) SetLabels

func (u *UserUpsert) SetLabels(v map[string]interface{}) *UserUpsert

SetLabels sets the "labels" field.

func (*UserUpsert) SetMetadata

func (u *UserUpsert) SetMetadata(v domain.UserMetadata) *UserUpsert

SetMetadata sets the "metadata" field.

func (*UserUpsert) SetName

func (u *UserUpsert) SetName(v string) *UserUpsert

SetName sets the "name" field.

func (*UserUpsert) SetScore

func (u *UserUpsert) SetScore(v int) *UserUpsert

SetScore sets the "score" field.

func (*UserUpsert) SetSettings

func (u *UserUpsert) SetSettings(v map[string]interface{}) *UserUpsert

SetSettings sets the "settings" field.

func (*UserUpsert) SetStatus

func (u *UserUpsert) SetStatus(v user.Status) *UserUpsert

SetStatus sets the "status" field.

func (*UserUpsert) SetTagNames

func (u *UserUpsert) SetTagNames(v []string) *UserUpsert

SetTagNames sets the "tag_names" field.

func (*UserUpsert) SetUpdatedAt

func (u *UserUpsert) SetUpdatedAt(v time.Time) *UserUpsert

SetUpdatedAt sets the "updated_at" field.

func (*UserUpsert) UpdateBio

func (u *UserUpsert) UpdateBio() *UserUpsert

UpdateBio sets the "bio" field to the value that was provided on create.

func (*UserUpsert) UpdateExternalID

func (u *UserUpsert) UpdateExternalID() *UserUpsert

UpdateExternalID sets the "external_id" field to the value that was provided on create.

func (*UserUpsert) UpdateLabels

func (u *UserUpsert) UpdateLabels() *UserUpsert

UpdateLabels sets the "labels" field to the value that was provided on create.

func (*UserUpsert) UpdateMetadata

func (u *UserUpsert) UpdateMetadata() *UserUpsert

UpdateMetadata sets the "metadata" field to the value that was provided on create.

func (*UserUpsert) UpdateName

func (u *UserUpsert) UpdateName() *UserUpsert

UpdateName sets the "name" field to the value that was provided on create.

func (*UserUpsert) UpdateScore

func (u *UserUpsert) UpdateScore() *UserUpsert

UpdateScore sets the "score" field to the value that was provided on create.

func (*UserUpsert) UpdateSettings

func (u *UserUpsert) UpdateSettings() *UserUpsert

UpdateSettings sets the "settings" field to the value that was provided on create.

func (*UserUpsert) UpdateStatus

func (u *UserUpsert) UpdateStatus() *UserUpsert

UpdateStatus sets the "status" field to the value that was provided on create.

func (*UserUpsert) UpdateTagNames

func (u *UserUpsert) UpdateTagNames() *UserUpsert

UpdateTagNames sets the "tag_names" field to the value that was provided on create.

func (*UserUpsert) UpdateUpdatedAt

func (u *UserUpsert) UpdateUpdatedAt() *UserUpsert

UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.

type UserUpsertBulk

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

UserUpsertBulk is the builder for "upsert"-ing a bulk of User nodes.

func (*UserUpsertBulk) AddScore

func (u *UserUpsertBulk) AddScore(v int) *UserUpsertBulk

AddScore adds v to the "score" field.

func (*UserUpsertBulk) ApplyDomain

func (u *UserUpsertBulk) ApplyDomain(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) (*UserUpsertBulk, error)

ApplyDomain applies domain.User fields to the UserUpsertBulk builder on conflict.

Note: ctx is accepted for API symmetry. Transformer hooks do not fire on upsert conflict paths; the error return is always nil.

func (*UserUpsertBulk) ApplyDomainX

func (u *UserUpsertBulk) ApplyDomainX(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) *UserUpsertBulk

ApplyDomainX is the panicking variant of ApplyDomain. See *UserCreate.ApplyDomainX.

func (*UserUpsertBulk) ClearBio

func (u *UserUpsertBulk) ClearBio() *UserUpsertBulk

ClearBio clears the value of the "bio" field.

func (*UserUpsertBulk) ClearScore

func (u *UserUpsertBulk) ClearScore() *UserUpsertBulk

ClearScore clears the value of the "score" field.

func (*UserUpsertBulk) ClearSettings

func (u *UserUpsertBulk) ClearSettings() *UserUpsertBulk

ClearSettings clears the value of the "settings" field.

func (*UserUpsertBulk) ClearUpdatedAt

func (u *UserUpsertBulk) ClearUpdatedAt() *UserUpsertBulk

ClearUpdatedAt clears the value of the "updated_at" field.

func (*UserUpsertBulk) DoNothing

func (u *UserUpsertBulk) DoNothing() *UserUpsertBulk

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*UserUpsertBulk) Exec

func (u *UserUpsertBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpsertBulk) ExecX

func (u *UserUpsertBulk) ExecX(ctx context.Context)

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

func (*UserUpsertBulk) Ignore

func (u *UserUpsertBulk) Ignore() *UserUpsertBulk

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.User.Create().
	OnConflict(sql.ResolveWithIgnore()).
	Exec(ctx)

func (*UserUpsertBulk) SetBio

func (u *UserUpsertBulk) SetBio(v string) *UserUpsertBulk

SetBio sets the "bio" field.

func (*UserUpsertBulk) SetExternalID

func (u *UserUpsertBulk) SetExternalID(v uuid.UUID) *UserUpsertBulk

SetExternalID sets the "external_id" field.

func (*UserUpsertBulk) SetLabels

func (u *UserUpsertBulk) SetLabels(v map[string]interface{}) *UserUpsertBulk

SetLabels sets the "labels" field.

func (*UserUpsertBulk) SetMetadata

func (u *UserUpsertBulk) SetMetadata(v domain.UserMetadata) *UserUpsertBulk

SetMetadata sets the "metadata" field.

func (*UserUpsertBulk) SetName

func (u *UserUpsertBulk) SetName(v string) *UserUpsertBulk

SetName sets the "name" field.

func (*UserUpsertBulk) SetScore

func (u *UserUpsertBulk) SetScore(v int) *UserUpsertBulk

SetScore sets the "score" field.

func (*UserUpsertBulk) SetSettings

func (u *UserUpsertBulk) SetSettings(v map[string]interface{}) *UserUpsertBulk

SetSettings sets the "settings" field.

func (*UserUpsertBulk) SetStatus

func (u *UserUpsertBulk) SetStatus(v user.Status) *UserUpsertBulk

SetStatus sets the "status" field.

func (*UserUpsertBulk) SetTagNames

func (u *UserUpsertBulk) SetTagNames(v []string) *UserUpsertBulk

SetTagNames sets the "tag_names" field.

func (*UserUpsertBulk) SetUpdatedAt

func (u *UserUpsertBulk) SetUpdatedAt(v time.Time) *UserUpsertBulk

SetUpdatedAt sets the "updated_at" field.

func (*UserUpsertBulk) Update

func (u *UserUpsertBulk) Update(set func(*UserUpsert)) *UserUpsertBulk

Update allows overriding fields `UPDATE` values. See the UserCreateBulk.OnConflict documentation for more info.

func (*UserUpsertBulk) UpdateBio

func (u *UserUpsertBulk) UpdateBio() *UserUpsertBulk

UpdateBio sets the "bio" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateExternalID

func (u *UserUpsertBulk) UpdateExternalID() *UserUpsertBulk

UpdateExternalID sets the "external_id" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateLabels

func (u *UserUpsertBulk) UpdateLabels() *UserUpsertBulk

UpdateLabels sets the "labels" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateMetadata

func (u *UserUpsertBulk) UpdateMetadata() *UserUpsertBulk

UpdateMetadata sets the "metadata" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateName

func (u *UserUpsertBulk) UpdateName() *UserUpsertBulk

UpdateName sets the "name" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateNewValues

func (u *UserUpsertBulk) UpdateNewValues() *UserUpsertBulk

UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:

client.User.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

func (*UserUpsertBulk) UpdateScore

func (u *UserUpsertBulk) UpdateScore() *UserUpsertBulk

UpdateScore sets the "score" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateSettings

func (u *UserUpsertBulk) UpdateSettings() *UserUpsertBulk

UpdateSettings sets the "settings" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateStatus

func (u *UserUpsertBulk) UpdateStatus() *UserUpsertBulk

UpdateStatus sets the "status" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateTagNames

func (u *UserUpsertBulk) UpdateTagNames() *UserUpsertBulk

UpdateTagNames sets the "tag_names" field to the value that was provided on create.

func (*UserUpsertBulk) UpdateUpdatedAt

func (u *UserUpsertBulk) UpdateUpdatedAt() *UserUpsertBulk

UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.

type UserUpsertOne

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

UserUpsertOne is the builder for "upsert"-ing

one User node.

func (*UserUpsertOne) AddScore

func (u *UserUpsertOne) AddScore(v int) *UserUpsertOne

AddScore adds v to the "score" field.

func (*UserUpsertOne) ApplyDomain

func (u *UserUpsertOne) ApplyDomain(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) (*UserUpsertOne, error)

ApplyDomain applies domain.User fields to the UserUpsertOne builder on conflict.

Note: ctx is accepted for API symmetry. Transformer hooks do not fire on upsert conflict paths; the error return is always nil.

func (*UserUpsertOne) ApplyDomainX

func (u *UserUpsertOne) ApplyDomainX(ctx context.Context, d *domain.User, opts ...entdomain.ApplyOption) *UserUpsertOne

ApplyDomainX is the panicking variant of ApplyDomain. See *UserCreate.ApplyDomainX.

func (*UserUpsertOne) ClearBio

func (u *UserUpsertOne) ClearBio() *UserUpsertOne

ClearBio clears the value of the "bio" field.

func (*UserUpsertOne) ClearScore

func (u *UserUpsertOne) ClearScore() *UserUpsertOne

ClearScore clears the value of the "score" field.

func (*UserUpsertOne) ClearSettings

func (u *UserUpsertOne) ClearSettings() *UserUpsertOne

ClearSettings clears the value of the "settings" field.

func (*UserUpsertOne) ClearUpdatedAt

func (u *UserUpsertOne) ClearUpdatedAt() *UserUpsertOne

ClearUpdatedAt clears the value of the "updated_at" field.

func (*UserUpsertOne) DoNothing

func (u *UserUpsertOne) DoNothing() *UserUpsertOne

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*UserUpsertOne) Exec

func (u *UserUpsertOne) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpsertOne) ExecX

func (u *UserUpsertOne) ExecX(ctx context.Context)

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

func (*UserUpsertOne) ID

func (u *UserUpsertOne) ID(ctx context.Context) (id int, err error)

Exec executes the UPSERT query and returns the inserted/updated ID.

func (*UserUpsertOne) IDX

func (u *UserUpsertOne) IDX(ctx context.Context) int

IDX is like ID, but panics if an error occurs.

func (*UserUpsertOne) Ignore

func (u *UserUpsertOne) Ignore() *UserUpsertOne

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.User.Create().
    OnConflict(sql.ResolveWithIgnore()).
    Exec(ctx)

func (*UserUpsertOne) SetBio

func (u *UserUpsertOne) SetBio(v string) *UserUpsertOne

SetBio sets the "bio" field.

func (*UserUpsertOne) SetExternalID

func (u *UserUpsertOne) SetExternalID(v uuid.UUID) *UserUpsertOne

SetExternalID sets the "external_id" field.

func (*UserUpsertOne) SetLabels

func (u *UserUpsertOne) SetLabels(v map[string]interface{}) *UserUpsertOne

SetLabels sets the "labels" field.

func (*UserUpsertOne) SetMetadata

func (u *UserUpsertOne) SetMetadata(v domain.UserMetadata) *UserUpsertOne

SetMetadata sets the "metadata" field.

func (*UserUpsertOne) SetName

func (u *UserUpsertOne) SetName(v string) *UserUpsertOne

SetName sets the "name" field.

func (*UserUpsertOne) SetScore

func (u *UserUpsertOne) SetScore(v int) *UserUpsertOne

SetScore sets the "score" field.

func (*UserUpsertOne) SetSettings

func (u *UserUpsertOne) SetSettings(v map[string]interface{}) *UserUpsertOne

SetSettings sets the "settings" field.

func (*UserUpsertOne) SetStatus

func (u *UserUpsertOne) SetStatus(v user.Status) *UserUpsertOne

SetStatus sets the "status" field.

func (*UserUpsertOne) SetTagNames

func (u *UserUpsertOne) SetTagNames(v []string) *UserUpsertOne

SetTagNames sets the "tag_names" field.

func (*UserUpsertOne) SetUpdatedAt

func (u *UserUpsertOne) SetUpdatedAt(v time.Time) *UserUpsertOne

SetUpdatedAt sets the "updated_at" field.

func (*UserUpsertOne) Update

func (u *UserUpsertOne) Update(set func(*UserUpsert)) *UserUpsertOne

Update allows overriding fields `UPDATE` values. See the UserCreate.OnConflict documentation for more info.

func (*UserUpsertOne) UpdateBio

func (u *UserUpsertOne) UpdateBio() *UserUpsertOne

UpdateBio sets the "bio" field to the value that was provided on create.

func (*UserUpsertOne) UpdateExternalID

func (u *UserUpsertOne) UpdateExternalID() *UserUpsertOne

UpdateExternalID sets the "external_id" field to the value that was provided on create.

func (*UserUpsertOne) UpdateLabels

func (u *UserUpsertOne) UpdateLabels() *UserUpsertOne

UpdateLabels sets the "labels" field to the value that was provided on create.

func (*UserUpsertOne) UpdateMetadata

func (u *UserUpsertOne) UpdateMetadata() *UserUpsertOne

UpdateMetadata sets the "metadata" field to the value that was provided on create.

func (*UserUpsertOne) UpdateName

func (u *UserUpsertOne) UpdateName() *UserUpsertOne

UpdateName sets the "name" field to the value that was provided on create.

func (*UserUpsertOne) UpdateNewValues

func (u *UserUpsertOne) UpdateNewValues() *UserUpsertOne

UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:

client.User.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

func (*UserUpsertOne) UpdateScore

func (u *UserUpsertOne) UpdateScore() *UserUpsertOne

UpdateScore sets the "score" field to the value that was provided on create.

func (*UserUpsertOne) UpdateSettings

func (u *UserUpsertOne) UpdateSettings() *UserUpsertOne

UpdateSettings sets the "settings" field to the value that was provided on create.

func (*UserUpsertOne) UpdateStatus

func (u *UserUpsertOne) UpdateStatus() *UserUpsertOne

UpdateStatus sets the "status" field to the value that was provided on create.

func (*UserUpsertOne) UpdateTagNames

func (u *UserUpsertOne) UpdateTagNames() *UserUpsertOne

UpdateTagNames sets the "tag_names" field to the value that was provided on create.

func (*UserUpsertOne) UpdateUpdatedAt

func (u *UserUpsertOne) UpdateUpdatedAt() *UserUpsertOne

UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.

type Users

type Users []*User

Users is a parsable slice of User.

func (Users) ToDomain

func (es Users) ToDomain() domain.UserList

ToDomain maps a slice of ent User to domain.UserList.

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

Jump to

Keyboard shortcuts

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