ent

package
v0.0.0-...-e71670f Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 22 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.
	TypeCar  = "Car"
	TypePet  = "Pet"
	TypePost = "Post"
	TypeUser = "User"
)

Variables

This section is empty.

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.

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 Car

type Car struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Nickname holds the value of the "nickname" field.
	Nickname string `json:"nickname,omitempty"`
	// Brand holds the value of the "brand" field.
	Brand string `json:"brand,omitempty"`
	// ModelYear holds the value of the "model_year" field.
	ModelYear int `json:"model_year,omitempty"`
	// contains filtered or unexported fields
}

Car is the model entity for the Car schema.

func (*Car) String

func (c *Car) String() string

String implements the fmt.Stringer.

func (*Car) Unwrap

func (c *Car) Unwrap() *Car

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

func (c *Car) Update() *CarUpdateOne

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

func (*Car) Value

func (c *Car) Value(name string) (ent.Value, error)

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

type CarClient

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

CarClient is a client for the Car schema.

func NewCarClient

func NewCarClient(c config) *CarClient

NewCarClient returns a client for the Car from the given config.

func (*CarClient) Create

func (c *CarClient) Create() *CarCreate

Create returns a builder for creating a Car entity.

func (*CarClient) CreateBulk

func (c *CarClient) CreateBulk(builders ...*CarCreate) *CarCreateBulk

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

func (*CarClient) Delete

func (c *CarClient) Delete() *CarDelete

Delete returns a delete builder for Car.

func (*CarClient) DeleteOne

func (c *CarClient) DeleteOne(ca *Car) *CarDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*CarClient) DeleteOneID

func (c *CarClient) DeleteOneID(id int) *CarDeleteOne

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

func (*CarClient) Get

func (c *CarClient) Get(ctx context.Context, id int) (*Car, error)

Get returns a Car entity by its id.

func (*CarClient) GetX

func (c *CarClient) GetX(ctx context.Context, id int) *Car

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

func (*CarClient) Hooks

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

Hooks returns the client hooks.

func (*CarClient) Intercept

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

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

func (*CarClient) Interceptors

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

Interceptors returns the client interceptors.

func (*CarClient) Query

func (c *CarClient) Query() *CarQuery

Query returns a query builder for Car.

func (*CarClient) Update

func (c *CarClient) Update() *CarUpdate

Update returns an update builder for Car.

func (*CarClient) UpdateOne

func (c *CarClient) UpdateOne(ca *Car) *CarUpdateOne

UpdateOne returns an update builder for the given entity.

func (*CarClient) UpdateOneID

func (c *CarClient) UpdateOneID(id int) *CarUpdateOne

UpdateOneID returns an update builder for the given id.

func (*CarClient) Use

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

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

type CarCreate

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

CarCreate is the builder for creating a Car entity.

func (*CarCreate) Exec

func (cc *CarCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*CarCreate) ExecX

func (cc *CarCreate) ExecX(ctx context.Context)

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

func (*CarCreate) Mutation

func (cc *CarCreate) Mutation() *CarMutation

Mutation returns the CarMutation object of the builder.

func (*CarCreate) Save

func (cc *CarCreate) Save(ctx context.Context) (*Car, error)

Save creates the Car in the database.

func (*CarCreate) SaveX

func (cc *CarCreate) SaveX(ctx context.Context) *Car

SaveX calls Save and panics if Save returns an error.

func (*CarCreate) SetBrand

func (cc *CarCreate) SetBrand(s string) *CarCreate

SetBrand sets the "brand" field.

func (*CarCreate) SetModelYear

func (cc *CarCreate) SetModelYear(i int) *CarCreate

SetModelYear sets the "model_year" field.

func (*CarCreate) SetNickname

func (cc *CarCreate) SetNickname(s string) *CarCreate

SetNickname sets the "nickname" field.

type CarCreateBulk

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

CarCreateBulk is the builder for creating many Car entities in bulk.

func (*CarCreateBulk) Exec

func (ccb *CarCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*CarCreateBulk) ExecX

func (ccb *CarCreateBulk) ExecX(ctx context.Context)

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

func (*CarCreateBulk) Save

func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error)

Save creates the Car entities in the database.

func (*CarCreateBulk) SaveX

func (ccb *CarCreateBulk) SaveX(ctx context.Context) []*Car

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

type CarDelete

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

CarDelete is the builder for deleting a Car entity.

func (*CarDelete) Exec

func (cd *CarDelete) Exec(ctx context.Context) (int, error)

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

func (*CarDelete) ExecX

func (cd *CarDelete) ExecX(ctx context.Context) int

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

func (*CarDelete) Where

func (cd *CarDelete) Where(ps ...predicate.Car) *CarDelete

Where appends a list predicates to the CarDelete builder.

type CarDeleteOne

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

CarDeleteOne is the builder for deleting a single Car entity.

func (*CarDeleteOne) Exec

func (cdo *CarDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*CarDeleteOne) ExecX

func (cdo *CarDeleteOne) ExecX(ctx context.Context)

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

func (*CarDeleteOne) Where

func (cdo *CarDeleteOne) Where(ps ...predicate.Car) *CarDeleteOne

Where appends a list predicates to the CarDelete builder.

type CarGroupBy

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

CarGroupBy is the group-by builder for Car entities.

func (*CarGroupBy) Aggregate

func (cgb *CarGroupBy) Aggregate(fns ...AggregateFunc) *CarGroupBy

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

func (*CarGroupBy) Bool

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

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

func (*CarGroupBy) BoolX

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

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

func (*CarGroupBy) Bools

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

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

func (*CarGroupBy) BoolsX

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

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

func (*CarGroupBy) Float64

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

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

func (*CarGroupBy) Float64X

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

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

func (*CarGroupBy) Float64s

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

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

func (*CarGroupBy) Float64sX

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

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

func (*CarGroupBy) Int

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

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

func (*CarGroupBy) IntX

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

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

func (*CarGroupBy) Ints

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

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

func (*CarGroupBy) IntsX

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

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

func (*CarGroupBy) Scan

func (cgb *CarGroupBy) Scan(ctx context.Context, v any) error

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

func (*CarGroupBy) ScanX

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

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

func (*CarGroupBy) String

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

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

func (*CarGroupBy) StringX

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

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

func (*CarGroupBy) Strings

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

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

func (*CarGroupBy) StringsX

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

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

type CarMutation

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

CarMutation represents an operation that mutates the Car nodes in the graph.

func (*CarMutation) AddField

func (m *CarMutation) 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 (*CarMutation) AddModelYear

func (m *CarMutation) AddModelYear(i int)

AddModelYear adds i to the "model_year" field.

func (*CarMutation) AddedEdges

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

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

func (*CarMutation) AddedField

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

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

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

func (*CarMutation) AddedIDs

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

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

func (*CarMutation) AddedModelYear

func (m *CarMutation) AddedModelYear() (r int, exists bool)

AddedModelYear returns the value that was added to the "model_year" field in this mutation.

func (*CarMutation) Brand

func (m *CarMutation) Brand() (r string, exists bool)

Brand returns the value of the "brand" field in the mutation.

func (*CarMutation) ClearEdge

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

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

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

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

func (*CarMutation) ClearedFields

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

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

func (CarMutation) Client

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

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

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

func (*CarMutation) Field

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

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

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

func (*CarMutation) Fields

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

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

func (m *CarMutation) 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 (*CarMutation) ModelYear

func (m *CarMutation) ModelYear() (r int, exists bool)

ModelYear returns the value of the "model_year" field in the mutation.

func (*CarMutation) Nickname

func (m *CarMutation) Nickname() (r string, exists bool)

Nickname returns the value of the "nickname" field in the mutation.

func (*CarMutation) OldBrand

func (m *CarMutation) OldBrand(ctx context.Context) (v string, err error)

OldBrand returns the old "brand" field's value of the Car entity. If the Car 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 (*CarMutation) OldField

func (m *CarMutation) 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 (*CarMutation) OldModelYear

func (m *CarMutation) OldModelYear(ctx context.Context) (v int, err error)

OldModelYear returns the old "model_year" field's value of the Car entity. If the Car 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 (*CarMutation) OldNickname

func (m *CarMutation) OldNickname(ctx context.Context) (v string, err error)

OldNickname returns the old "nickname" field's value of the Car entity. If the Car 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 (*CarMutation) Op

func (m *CarMutation) Op() Op

Op returns the operation name.

func (*CarMutation) RemovedEdges

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

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

func (*CarMutation) RemovedIDs

func (m *CarMutation) 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 (*CarMutation) ResetBrand

func (m *CarMutation) ResetBrand()

ResetBrand resets all changes to the "brand" field.

func (*CarMutation) ResetEdge

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

func (m *CarMutation) 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 (*CarMutation) ResetModelYear

func (m *CarMutation) ResetModelYear()

ResetModelYear resets all changes to the "model_year" field.

func (*CarMutation) ResetNickname

func (m *CarMutation) ResetNickname()

ResetNickname resets all changes to the "nickname" field.

func (*CarMutation) SetBrand

func (m *CarMutation) SetBrand(s string)

SetBrand sets the "brand" field.

func (*CarMutation) SetField

func (m *CarMutation) 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 (*CarMutation) SetModelYear

func (m *CarMutation) SetModelYear(i int)

SetModelYear sets the "model_year" field.

func (*CarMutation) SetNickname

func (m *CarMutation) SetNickname(s string)

SetNickname sets the "nickname" field.

func (*CarMutation) SetOp

func (m *CarMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (CarMutation) Tx

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

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

func (*CarMutation) Type

func (m *CarMutation) Type() string

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

func (*CarMutation) Where

func (m *CarMutation) Where(ps ...predicate.Car)

Where appends a list predicates to the CarMutation builder.

func (*CarMutation) WhereP

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

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

type CarQuery

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

CarQuery is the builder for querying Car entities.

func (*CarQuery) Aggregate

func (cq *CarQuery) Aggregate(fns ...AggregateFunc) *CarSelect

Aggregate returns a CarSelect configured with the given aggregations.

func (*CarQuery) All

func (cq *CarQuery) All(ctx context.Context) ([]*Car, error)

All executes the query and returns a list of Cars.

func (*CarQuery) AllX

func (cq *CarQuery) AllX(ctx context.Context) []*Car

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

func (*CarQuery) Clone

func (cq *CarQuery) Clone() *CarQuery

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

func (*CarQuery) Count

func (cq *CarQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*CarQuery) CountX

func (cq *CarQuery) CountX(ctx context.Context) int

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

func (*CarQuery) Exist

func (cq *CarQuery) Exist(ctx context.Context) (bool, error)

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

func (*CarQuery) ExistX

func (cq *CarQuery) ExistX(ctx context.Context) bool

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

func (*CarQuery) First

func (cq *CarQuery) First(ctx context.Context) (*Car, error)

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

func (*CarQuery) FirstID

func (cq *CarQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*CarQuery) FirstIDX

func (cq *CarQuery) FirstIDX(ctx context.Context) int

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

func (*CarQuery) FirstX

func (cq *CarQuery) FirstX(ctx context.Context) *Car

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

func (*CarQuery) GroupBy

func (cq *CarQuery) GroupBy(field string, fields ...string) *CarGroupBy

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

client.Car.Query().
	GroupBy(car.FieldNickname).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*CarQuery) IDs

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

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

func (*CarQuery) IDsX

func (cq *CarQuery) IDsX(ctx context.Context) []int

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

func (*CarQuery) Limit

func (cq *CarQuery) Limit(limit int) *CarQuery

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

func (*CarQuery) Offset

func (cq *CarQuery) Offset(offset int) *CarQuery

Offset to start from.

func (*CarQuery) Only

func (cq *CarQuery) Only(ctx context.Context) (*Car, error)

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

func (*CarQuery) OnlyID

func (cq *CarQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*CarQuery) OnlyIDX

func (cq *CarQuery) OnlyIDX(ctx context.Context) int

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

func (*CarQuery) OnlyX

func (cq *CarQuery) OnlyX(ctx context.Context) *Car

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

func (*CarQuery) Order

func (cq *CarQuery) Order(o ...car.OrderOption) *CarQuery

Order specifies how the records should be ordered.

func (*CarQuery) Select

func (cq *CarQuery) Select(fields ...string) *CarSelect

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

client.Car.Query().
	Select(car.FieldNickname).
	Scan(ctx, &v)

func (*CarQuery) Unique

func (cq *CarQuery) Unique(unique bool) *CarQuery

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

func (cq *CarQuery) Where(ps ...predicate.Car) *CarQuery

Where adds a new predicate for the CarQuery builder.

type CarSelect

type CarSelect struct {
	*CarQuery
	// contains filtered or unexported fields
}

CarSelect is the builder for selecting fields of Car entities.

func (*CarSelect) Aggregate

func (cs *CarSelect) Aggregate(fns ...AggregateFunc) *CarSelect

Aggregate adds the given aggregation functions to the selector query.

func (*CarSelect) Bool

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

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

func (*CarSelect) BoolX

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

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

func (*CarSelect) Bools

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

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

func (*CarSelect) BoolsX

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

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

func (*CarSelect) Float64

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

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

func (*CarSelect) Float64X

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

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

func (*CarSelect) Float64s

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

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

func (*CarSelect) Float64sX

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

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

func (*CarSelect) Int

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

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

func (*CarSelect) IntX

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

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

func (*CarSelect) Ints

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

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

func (*CarSelect) IntsX

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

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

func (*CarSelect) Scan

func (cs *CarSelect) Scan(ctx context.Context, v any) error

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

func (*CarSelect) ScanX

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

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

func (*CarSelect) String

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

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

func (*CarSelect) StringX

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

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

func (*CarSelect) Strings

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

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

func (*CarSelect) StringsX

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

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

type CarUpdate

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

CarUpdate is the builder for updating Car entities.

func (*CarUpdate) AddModelYear

func (cu *CarUpdate) AddModelYear(i int) *CarUpdate

AddModelYear adds i to the "model_year" field.

func (*CarUpdate) Exec

func (cu *CarUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*CarUpdate) ExecX

func (cu *CarUpdate) ExecX(ctx context.Context)

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

func (*CarUpdate) Mutation

func (cu *CarUpdate) Mutation() *CarMutation

Mutation returns the CarMutation object of the builder.

func (*CarUpdate) Save

func (cu *CarUpdate) Save(ctx context.Context) (int, error)

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

func (*CarUpdate) SaveX

func (cu *CarUpdate) SaveX(ctx context.Context) int

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

func (*CarUpdate) SetBrand

func (cu *CarUpdate) SetBrand(s string) *CarUpdate

SetBrand sets the "brand" field.

func (*CarUpdate) SetModelYear

func (cu *CarUpdate) SetModelYear(i int) *CarUpdate

SetModelYear sets the "model_year" field.

func (*CarUpdate) SetNickname

func (cu *CarUpdate) SetNickname(s string) *CarUpdate

SetNickname sets the "nickname" field.

func (*CarUpdate) Where

func (cu *CarUpdate) Where(ps ...predicate.Car) *CarUpdate

Where appends a list predicates to the CarUpdate builder.

type CarUpdateOne

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

CarUpdateOne is the builder for updating a single Car entity.

func (*CarUpdateOne) AddModelYear

func (cuo *CarUpdateOne) AddModelYear(i int) *CarUpdateOne

AddModelYear adds i to the "model_year" field.

func (*CarUpdateOne) Exec

func (cuo *CarUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*CarUpdateOne) ExecX

func (cuo *CarUpdateOne) ExecX(ctx context.Context)

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

func (*CarUpdateOne) Mutation

func (cuo *CarUpdateOne) Mutation() *CarMutation

Mutation returns the CarMutation object of the builder.

func (*CarUpdateOne) Save

func (cuo *CarUpdateOne) Save(ctx context.Context) (*Car, error)

Save executes the query and returns the updated Car entity.

func (*CarUpdateOne) SaveX

func (cuo *CarUpdateOne) SaveX(ctx context.Context) *Car

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

func (*CarUpdateOne) Select

func (cuo *CarUpdateOne) Select(field string, fields ...string) *CarUpdateOne

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

func (*CarUpdateOne) SetBrand

func (cuo *CarUpdateOne) SetBrand(s string) *CarUpdateOne

SetBrand sets the "brand" field.

func (*CarUpdateOne) SetModelYear

func (cuo *CarUpdateOne) SetModelYear(i int) *CarUpdateOne

SetModelYear sets the "model_year" field.

func (*CarUpdateOne) SetNickname

func (cuo *CarUpdateOne) SetNickname(s string) *CarUpdateOne

SetNickname sets the "nickname" field.

func (*CarUpdateOne) Where

func (cuo *CarUpdateOne) Where(ps ...predicate.Car) *CarUpdateOne

Where appends a list predicates to the CarUpdate builder.

type Cars

type Cars []*Car

Cars is a parsable slice of Car.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Car is the client for interacting with the Car builders.
	Car *CarClient
	// Pet is the client for interacting with the Pet builders.
	Pet *PetClient
	// Post is the client for interacting with the Post builders.
	Post *PostClient
	// 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().
	Car.
	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 Pet

type Pet struct {

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

Pet is the model entity for the Pet schema.

func (*Pet) QueryOwner

func (pe *Pet) QueryOwner() *UserQuery

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

func (*Pet) String

func (pe *Pet) String() string

String implements the fmt.Stringer.

func (*Pet) Unwrap

func (pe *Pet) Unwrap() *Pet

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

func (pe *Pet) Update() *PetUpdateOne

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

func (*Pet) Value

func (pe *Pet) Value(name string) (ent.Value, error)

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

type PetClient

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

PetClient is a client for the Pet schema.

func NewPetClient

func NewPetClient(c config) *PetClient

NewPetClient returns a client for the Pet from the given config.

func (*PetClient) Create

func (c *PetClient) Create() *PetCreate

Create returns a builder for creating a Pet entity.

func (*PetClient) CreateBulk

func (c *PetClient) CreateBulk(builders ...*PetCreate) *PetCreateBulk

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

func (*PetClient) Delete

func (c *PetClient) Delete() *PetDelete

Delete returns a delete builder for Pet.

func (*PetClient) DeleteOne

func (c *PetClient) DeleteOne(pe *Pet) *PetDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*PetClient) DeleteOneID

func (c *PetClient) DeleteOneID(id int) *PetDeleteOne

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

func (*PetClient) Get

func (c *PetClient) Get(ctx context.Context, id int) (*Pet, error)

Get returns a Pet entity by its id.

func (*PetClient) GetX

func (c *PetClient) GetX(ctx context.Context, id int) *Pet

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

func (*PetClient) Hooks

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

Hooks returns the client hooks.

func (*PetClient) Intercept

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

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

func (*PetClient) Interceptors

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

Interceptors returns the client interceptors.

func (*PetClient) Query

func (c *PetClient) Query() *PetQuery

Query returns a query builder for Pet.

func (*PetClient) QueryOwner

func (c *PetClient) QueryOwner(pe *Pet) *UserQuery

QueryOwner queries the owner edge of a Pet.

func (*PetClient) Update

func (c *PetClient) Update() *PetUpdate

Update returns an update builder for Pet.

func (*PetClient) UpdateOne

func (c *PetClient) UpdateOne(pe *Pet) *PetUpdateOne

UpdateOne returns an update builder for the given entity.

func (*PetClient) UpdateOneID

func (c *PetClient) UpdateOneID(id int) *PetUpdateOne

UpdateOneID returns an update builder for the given id.

func (*PetClient) Use

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

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

type PetCreate

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

PetCreate is the builder for creating a Pet entity.

func (*PetCreate) Exec

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

Exec executes the query.

func (*PetCreate) ExecX

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

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

func (*PetCreate) Mutation

func (pc *PetCreate) Mutation() *PetMutation

Mutation returns the PetMutation object of the builder.

func (*PetCreate) Save

func (pc *PetCreate) Save(ctx context.Context) (*Pet, error)

Save creates the Pet in the database.

func (*PetCreate) SaveX

func (pc *PetCreate) SaveX(ctx context.Context) *Pet

SaveX calls Save and panics if Save returns an error.

func (*PetCreate) SetNillableOwnerID

func (pc *PetCreate) SetNillableOwnerID(id *int) *PetCreate

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

func (*PetCreate) SetOwner

func (pc *PetCreate) SetOwner(u *User) *PetCreate

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

func (*PetCreate) SetOwnerID

func (pc *PetCreate) SetOwnerID(id int) *PetCreate

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

type PetCreateBulk

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

PetCreateBulk is the builder for creating many Pet entities in bulk.

func (*PetCreateBulk) Exec

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

Exec executes the query.

func (*PetCreateBulk) ExecX

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

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

func (*PetCreateBulk) Save

func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error)

Save creates the Pet entities in the database.

func (*PetCreateBulk) SaveX

func (pcb *PetCreateBulk) SaveX(ctx context.Context) []*Pet

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

type PetDelete

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

PetDelete is the builder for deleting a Pet entity.

func (*PetDelete) Exec

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

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

func (*PetDelete) ExecX

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

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

func (*PetDelete) Where

func (pd *PetDelete) Where(ps ...predicate.Pet) *PetDelete

Where appends a list predicates to the PetDelete builder.

type PetDeleteOne

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

PetDeleteOne is the builder for deleting a single Pet entity.

func (*PetDeleteOne) Exec

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

Exec executes the deletion query.

func (*PetDeleteOne) ExecX

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

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

func (*PetDeleteOne) Where

func (pdo *PetDeleteOne) Where(ps ...predicate.Pet) *PetDeleteOne

Where appends a list predicates to the PetDelete builder.

type PetEdges

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

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

func (PetEdges) OwnerOrErr

func (e PetEdges) 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.

type PetGroupBy

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

PetGroupBy is the group-by builder for Pet entities.

func (*PetGroupBy) Aggregate

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

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

func (*PetGroupBy) Bool

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

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

func (*PetGroupBy) BoolX

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

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

func (*PetGroupBy) Bools

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

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

func (*PetGroupBy) BoolsX

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

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

func (*PetGroupBy) Float64

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

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

func (*PetGroupBy) Float64X

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

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

func (*PetGroupBy) Float64s

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

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

func (*PetGroupBy) Float64sX

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

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

func (*PetGroupBy) Int

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

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

func (*PetGroupBy) IntX

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

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

func (*PetGroupBy) Ints

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

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

func (*PetGroupBy) IntsX

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

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

func (*PetGroupBy) Scan

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

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

func (*PetGroupBy) ScanX

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

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

func (*PetGroupBy) String

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

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

func (*PetGroupBy) StringX

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

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

func (*PetGroupBy) Strings

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

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

func (*PetGroupBy) StringsX

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

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

type PetMutation

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

PetMutation represents an operation that mutates the Pet nodes in the graph.

func (*PetMutation) AddField

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

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

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

func (*PetMutation) AddedField

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

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

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

func (*PetMutation) AddedIDs

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

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

func (*PetMutation) ClearEdge

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

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

func (m *PetMutation) ClearOwner()

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

func (*PetMutation) ClearedEdges

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

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

func (*PetMutation) ClearedFields

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

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

func (PetMutation) Client

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

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

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

func (*PetMutation) Field

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

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

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

func (*PetMutation) Fields

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

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

func (m *PetMutation) 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 (*PetMutation) OldField

func (m *PetMutation) 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 (*PetMutation) Op

func (m *PetMutation) Op() Op

Op returns the operation name.

func (*PetMutation) OwnerCleared

func (m *PetMutation) OwnerCleared() bool

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

func (*PetMutation) OwnerID

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

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

func (*PetMutation) OwnerIDs

func (m *PetMutation) 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 (*PetMutation) RemovedEdges

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

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

func (*PetMutation) RemovedIDs

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

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

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

func (m *PetMutation) ResetOwner()

ResetOwner resets all changes to the "owner" edge.

func (*PetMutation) SetField

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

func (m *PetMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*PetMutation) SetOwnerID

func (m *PetMutation) SetOwnerID(id int)

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

func (PetMutation) Tx

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

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

func (*PetMutation) Type

func (m *PetMutation) Type() string

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

func (*PetMutation) Where

func (m *PetMutation) Where(ps ...predicate.Pet)

Where appends a list predicates to the PetMutation builder.

func (*PetMutation) WhereP

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

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

type PetQuery

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

PetQuery is the builder for querying Pet entities.

func (*PetQuery) Aggregate

func (pq *PetQuery) Aggregate(fns ...AggregateFunc) *PetSelect

Aggregate returns a PetSelect configured with the given aggregations.

func (*PetQuery) All

func (pq *PetQuery) All(ctx context.Context) ([]*Pet, error)

All executes the query and returns a list of Pets.

func (*PetQuery) AllX

func (pq *PetQuery) AllX(ctx context.Context) []*Pet

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

func (*PetQuery) Clone

func (pq *PetQuery) Clone() *PetQuery

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

func (*PetQuery) Count

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

Count returns the count of the given query.

func (*PetQuery) CountX

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

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

func (*PetQuery) Exist

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

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

func (*PetQuery) ExistX

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

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

func (*PetQuery) First

func (pq *PetQuery) First(ctx context.Context) (*Pet, error)

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

func (*PetQuery) FirstID

func (pq *PetQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*PetQuery) FirstIDX

func (pq *PetQuery) FirstIDX(ctx context.Context) int

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

func (*PetQuery) FirstX

func (pq *PetQuery) FirstX(ctx context.Context) *Pet

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

func (*PetQuery) GroupBy

func (pq *PetQuery) GroupBy(field string, fields ...string) *PetGroupBy

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.

func (*PetQuery) IDs

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

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

func (*PetQuery) IDsX

func (pq *PetQuery) IDsX(ctx context.Context) []int

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

func (*PetQuery) Limit

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

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

func (*PetQuery) Offset

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

Offset to start from.

func (*PetQuery) Only

func (pq *PetQuery) Only(ctx context.Context) (*Pet, error)

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

func (*PetQuery) OnlyID

func (pq *PetQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*PetQuery) OnlyIDX

func (pq *PetQuery) OnlyIDX(ctx context.Context) int

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

func (*PetQuery) OnlyX

func (pq *PetQuery) OnlyX(ctx context.Context) *Pet

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

func (*PetQuery) Order

func (pq *PetQuery) Order(o ...pet.OrderOption) *PetQuery

Order specifies how the records should be ordered.

func (*PetQuery) QueryOwner

func (pq *PetQuery) QueryOwner() *UserQuery

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

func (*PetQuery) Select

func (pq *PetQuery) Select(fields ...string) *PetSelect

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

func (*PetQuery) Unique

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

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

func (pq *PetQuery) Where(ps ...predicate.Pet) *PetQuery

Where adds a new predicate for the PetQuery builder.

func (*PetQuery) WithOwner

func (pq *PetQuery) WithOwner(opts ...func(*UserQuery)) *PetQuery

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.

type PetSelect

type PetSelect struct {
	*PetQuery
	// contains filtered or unexported fields
}

PetSelect is the builder for selecting fields of Pet entities.

func (*PetSelect) Aggregate

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

Aggregate adds the given aggregation functions to the selector query.

func (*PetSelect) Bool

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

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

func (*PetSelect) BoolX

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

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

func (*PetSelect) Bools

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

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

func (*PetSelect) BoolsX

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

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

func (*PetSelect) Float64

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

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

func (*PetSelect) Float64X

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

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

func (*PetSelect) Float64s

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

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

func (*PetSelect) Float64sX

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

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

func (*PetSelect) Int

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

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

func (*PetSelect) IntX

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

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

func (*PetSelect) Ints

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

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

func (*PetSelect) IntsX

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

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

func (*PetSelect) Scan

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

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

func (*PetSelect) ScanX

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

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

func (*PetSelect) String

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

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

func (*PetSelect) StringX

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

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

func (*PetSelect) Strings

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

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

func (*PetSelect) StringsX

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

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

type PetUpdate

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

PetUpdate is the builder for updating Pet entities.

func (*PetUpdate) ClearOwner

func (pu *PetUpdate) ClearOwner() *PetUpdate

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

func (*PetUpdate) Exec

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

Exec executes the query.

func (*PetUpdate) ExecX

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

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

func (*PetUpdate) Mutation

func (pu *PetUpdate) Mutation() *PetMutation

Mutation returns the PetMutation object of the builder.

func (*PetUpdate) Save

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

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

func (*PetUpdate) SaveX

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

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

func (*PetUpdate) SetNillableOwnerID

func (pu *PetUpdate) SetNillableOwnerID(id *int) *PetUpdate

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

func (*PetUpdate) SetOwner

func (pu *PetUpdate) SetOwner(u *User) *PetUpdate

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

func (*PetUpdate) SetOwnerID

func (pu *PetUpdate) SetOwnerID(id int) *PetUpdate

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

func (*PetUpdate) Where

func (pu *PetUpdate) Where(ps ...predicate.Pet) *PetUpdate

Where appends a list predicates to the PetUpdate builder.

type PetUpdateOne

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

PetUpdateOne is the builder for updating a single Pet entity.

func (*PetUpdateOne) ClearOwner

func (puo *PetUpdateOne) ClearOwner() *PetUpdateOne

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

func (*PetUpdateOne) Exec

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

Exec executes the query on the entity.

func (*PetUpdateOne) ExecX

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

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

func (*PetUpdateOne) Mutation

func (puo *PetUpdateOne) Mutation() *PetMutation

Mutation returns the PetMutation object of the builder.

func (*PetUpdateOne) Save

func (puo *PetUpdateOne) Save(ctx context.Context) (*Pet, error)

Save executes the query and returns the updated Pet entity.

func (*PetUpdateOne) SaveX

func (puo *PetUpdateOne) SaveX(ctx context.Context) *Pet

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

func (*PetUpdateOne) Select

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

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

func (*PetUpdateOne) SetNillableOwnerID

func (puo *PetUpdateOne) SetNillableOwnerID(id *int) *PetUpdateOne

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

func (*PetUpdateOne) SetOwner

func (puo *PetUpdateOne) SetOwner(u *User) *PetUpdateOne

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

func (*PetUpdateOne) SetOwnerID

func (puo *PetUpdateOne) SetOwnerID(id int) *PetUpdateOne

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

func (*PetUpdateOne) Where

func (puo *PetUpdateOne) Where(ps ...predicate.Pet) *PetUpdateOne

Where appends a list predicates to the PetUpdate builder.

type Pets

type Pets []*Pet

Pets is a parsable slice of Pet.

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"`
	// 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) QueryAuthor

func (po *Post) QueryAuthor() *UserQuery

QueryAuthor queries the "author" edge of the Post entity.

func (*Post) String

func (po *Post) String() string

String implements the fmt.Stringer.

func (*Post) Unwrap

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

func (c *PostClient) Query() *PostQuery

Query returns a query builder for Post.

func (*PostClient) QueryAuthor

func (c *PostClient) QueryAuthor(po *Post) *UserQuery

QueryAuthor queries the author 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(po *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) Exec

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

Exec executes the query.

func (*PostCreate) ExecX

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

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

func (*PostCreate) Mutation

func (pc *PostCreate) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostCreate) Save

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

Save creates the Post in the database.

func (*PostCreate) SaveX

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

SaveX calls Save and panics if Save returns an error.

func (*PostCreate) SetAuthor

func (pc *PostCreate) SetAuthor(u *User) *PostCreate

SetAuthor sets the "author" edge to the User entity.

func (*PostCreate) SetAuthorID

func (pc *PostCreate) SetAuthorID(id int) *PostCreate

SetAuthorID sets the "author" edge to the User entity by ID.

func (*PostCreate) SetNillableAuthorID

func (pc *PostCreate) SetNillableAuthorID(id *int) *PostCreate

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

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 (pcb *PostCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*PostCreateBulk) ExecX

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

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

func (*PostCreateBulk) Save

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

Save creates the Post entities in the database.

func (*PostCreateBulk) SaveX

func (pcb *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 (pd *PostDelete) Exec(ctx context.Context) (int, error)

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

func (*PostDelete) ExecX

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

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

func (*PostDelete) Where

func (pd *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 (pdo *PostDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*PostDeleteOne) ExecX

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

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

func (*PostDeleteOne) Where

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

Where appends a list predicates to the PostDelete builder.

type PostEdges

type PostEdges struct {
	// Author holds the value of the author edge.
	Author *User `json:"author,omitempty"`
	// contains filtered or unexported fields
}

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

func (PostEdges) AuthorOrErr

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

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

type PostGroupBy

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

PostGroupBy is the group-by builder for Post entities.

func (*PostGroupBy) Aggregate

func (pgb *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 (pgb *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) 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) AuthorCleared

func (m *PostMutation) AuthorCleared() bool

AuthorCleared reports if the "author" edge to the User entity was cleared.

func (*PostMutation) AuthorID

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

AuthorID returns the "author" edge ID in the mutation.

func (*PostMutation) AuthorIDs

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

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

func (*PostMutation) ClearAuthor

func (m *PostMutation) ClearAuthor()

ClearAuthor clears the "author" edge to the User entity.

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

func (m *PostMutation) Op() Op

Op returns the operation name.

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

func (m *PostMutation) ResetAuthor()

ResetAuthor resets all changes to the "author" edge.

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

func (m *PostMutation) SetAuthorID(id int)

SetAuthorID sets the "author" edge to the User entity by id.

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) 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 (pq *PostQuery) Aggregate(fns ...AggregateFunc) *PostSelect

Aggregate returns a PostSelect configured with the given aggregations.

func (*PostQuery) All

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

All executes the query and returns a list of Posts.

func (*PostQuery) AllX

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

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

func (*PostQuery) Clone

func (pq *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 (pq *PostQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*PostQuery) CountX

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

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

func (*PostQuery) Exist

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

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

func (*PostQuery) ExistX

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

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

func (*PostQuery) First

func (pq *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 (pq *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 (pq *PostQuery) FirstIDX(ctx context.Context) int

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

func (*PostQuery) FirstX

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

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

func (*PostQuery) GroupBy

func (pq *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.

func (*PostQuery) IDs

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

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

func (*PostQuery) IDsX

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

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

func (*PostQuery) Limit

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

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

func (*PostQuery) Offset

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

Offset to start from.

func (*PostQuery) Only

func (pq *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 (pq *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 (pq *PostQuery) OnlyIDX(ctx context.Context) int

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

func (*PostQuery) OnlyX

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

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

func (*PostQuery) Order

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

Order specifies how the records should be ordered.

func (*PostQuery) QueryAuthor

func (pq *PostQuery) QueryAuthor() *UserQuery

QueryAuthor chains the current query on the "author" edge.

func (*PostQuery) Select

func (pq *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.

func (*PostQuery) Unique

func (pq *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 (pq *PostQuery) Where(ps ...predicate.Post) *PostQuery

Where adds a new predicate for the PostQuery builder.

func (*PostQuery) WithAuthor

func (pq *PostQuery) WithAuthor(opts ...func(*UserQuery)) *PostQuery

WithAuthor tells the query-builder to eager-load the nodes that are connected to the "author" 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 (ps *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 (ps *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) ClearAuthor

func (pu *PostUpdate) ClearAuthor() *PostUpdate

ClearAuthor clears the "author" edge to the User entity.

func (*PostUpdate) Exec

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

Exec executes the query.

func (*PostUpdate) ExecX

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

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

func (*PostUpdate) Mutation

func (pu *PostUpdate) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostUpdate) Save

func (pu *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 (pu *PostUpdate) SaveX(ctx context.Context) int

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

func (*PostUpdate) SetAuthor

func (pu *PostUpdate) SetAuthor(u *User) *PostUpdate

SetAuthor sets the "author" edge to the User entity.

func (*PostUpdate) SetAuthorID

func (pu *PostUpdate) SetAuthorID(id int) *PostUpdate

SetAuthorID sets the "author" edge to the User entity by ID.

func (*PostUpdate) SetNillableAuthorID

func (pu *PostUpdate) SetNillableAuthorID(id *int) *PostUpdate

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

func (*PostUpdate) Where

func (pu *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) ClearAuthor

func (puo *PostUpdateOne) ClearAuthor() *PostUpdateOne

ClearAuthor clears the "author" edge to the User entity.

func (*PostUpdateOne) Exec

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

Exec executes the query on the entity.

func (*PostUpdateOne) ExecX

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

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

func (*PostUpdateOne) Mutation

func (puo *PostUpdateOne) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostUpdateOne) Save

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

Save executes the query and returns the updated Post entity.

func (*PostUpdateOne) SaveX

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

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

func (*PostUpdateOne) Select

func (puo *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) SetAuthor

func (puo *PostUpdateOne) SetAuthor(u *User) *PostUpdateOne

SetAuthor sets the "author" edge to the User entity.

func (*PostUpdateOne) SetAuthorID

func (puo *PostUpdateOne) SetAuthorID(id int) *PostUpdateOne

SetAuthorID sets the "author" edge to the User entity by ID.

func (*PostUpdateOne) SetNillableAuthorID

func (puo *PostUpdateOne) SetNillableAuthorID(id *int) *PostUpdateOne

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

func (*PostUpdateOne) Where

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

Where appends a list predicates to the PostUpdate builder.

type Posts

type Posts []*Post

Posts is a parsable slice of Post.

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

	// Car is the client for interacting with the Car builders.
	Car *CarClient
	// Pet is the client for interacting with the Pet builders.
	Pet *PetClient
	// Post is the client for interacting with the Post builders.
	Post *PostClient
	// 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"`
	// Email holds the value of the "email" field.
	Email string `json:"email,omitempty"`
	// Role holds the value of the "role" field.
	Role int8 `json:"role,omitempty"`
	// Created holds the value of the "created" field.
	Created time.Time `json:"created,omitempty"`
	// Age holds the value of the "age" field.
	Age *int `json:"age,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) QueryCars

func (u *User) QueryCars() *CarQuery

QueryCars queries the "cars" edge of the User entity.

func (*User) QueryParent

func (u *User) QueryParent() *UserQuery

QueryParent queries the "parent" edge of the User entity.

func (*User) QueryPets

func (u *User) QueryPets() *PetQuery

QueryPets queries the "pets" edge of the User entity.

func (*User) QueryPosts

func (u *User) QueryPosts() *PostQuery

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

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (u *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 (u *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 (u *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) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

func (c *UserClient) DeleteOne(u *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) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QueryCars

func (c *UserClient) QueryCars(u *User) *CarQuery

QueryCars queries the cars edge of a User.

func (*UserClient) QueryParent

func (c *UserClient) QueryParent(u *User) *UserQuery

QueryParent queries the parent edge of a User.

func (*UserClient) QueryPets

func (c *UserClient) QueryPets(u *User) *PetQuery

QueryPets queries the pets edge of a User.

func (*UserClient) QueryPosts

func (c *UserClient) QueryPosts(u *User) *PostQuery

QueryPosts queries the posts edge of a User.

func (*UserClient) Update

func (c *UserClient) Update() *UserUpdate

Update returns an update builder for User.

func (*UserClient) UpdateOne

func (c *UserClient) UpdateOne(u *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) AddCarIDs

func (uc *UserCreate) AddCarIDs(ids ...int) *UserCreate

AddCarIDs adds the "cars" edge to the Car entity by IDs.

func (*UserCreate) AddCars

func (uc *UserCreate) AddCars(c ...*Car) *UserCreate

AddCars adds the "cars" edges to the Car entity.

func (*UserCreate) AddPetIDs

func (uc *UserCreate) AddPetIDs(ids ...int) *UserCreate

AddPetIDs adds the "pets" edge to the Pet entity by IDs.

func (*UserCreate) AddPets

func (uc *UserCreate) AddPets(p ...*Pet) *UserCreate

AddPets adds the "pets" edges to the Pet entity.

func (*UserCreate) AddPostIDs

func (uc *UserCreate) AddPostIDs(ids ...int) *UserCreate

AddPostIDs adds the "posts" edge to the Post entity by IDs.

func (*UserCreate) AddPosts

func (uc *UserCreate) AddPosts(p ...*Post) *UserCreate

AddPosts adds the "posts" edges to the Post entity.

func (*UserCreate) Exec

func (uc *UserCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreate) ExecX

func (uc *UserCreate) ExecX(ctx context.Context)

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

func (*UserCreate) Mutation

func (uc *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) Save

func (uc *UserCreate) Save(ctx context.Context) (*User, error)

Save creates the User in the database.

func (*UserCreate) SaveX

func (uc *UserCreate) SaveX(ctx context.Context) *User

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetAge

func (uc *UserCreate) SetAge(i int) *UserCreate

SetAge sets the "age" field.

func (*UserCreate) SetCreated

func (uc *UserCreate) SetCreated(t time.Time) *UserCreate

SetCreated sets the "created" field.

func (*UserCreate) SetEmail

func (uc *UserCreate) SetEmail(s string) *UserCreate

SetEmail sets the "email" field.

func (*UserCreate) SetName

func (uc *UserCreate) SetName(s string) *UserCreate

SetName sets the "name" field.

func (*UserCreate) SetNillableAge

func (uc *UserCreate) SetNillableAge(i *int) *UserCreate

SetNillableAge sets the "age" field if the given value is not nil.

func (*UserCreate) SetNillableCreated

func (uc *UserCreate) SetNillableCreated(t *time.Time) *UserCreate

SetNillableCreated sets the "created" field if the given value is not nil.

func (*UserCreate) SetNillableParentID

func (uc *UserCreate) SetNillableParentID(id *int) *UserCreate

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

func (*UserCreate) SetParent

func (uc *UserCreate) SetParent(u *User) *UserCreate

SetParent sets the "parent" edge to the User entity.

func (*UserCreate) SetParentID

func (uc *UserCreate) SetParentID(id int) *UserCreate

SetParentID sets the "parent" edge to the User entity by ID.

func (*UserCreate) SetRole

func (uc *UserCreate) SetRole(i int8) *UserCreate

SetRole sets the "role" 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 (ucb *UserCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreateBulk) ExecX

func (ucb *UserCreateBulk) ExecX(ctx context.Context)

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

func (*UserCreateBulk) Save

func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error)

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

func (ucb *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 (ud *UserDelete) Exec(ctx context.Context) (int, error)

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

func (*UserDelete) ExecX

func (ud *UserDelete) ExecX(ctx context.Context) int

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

func (*UserDelete) Where

func (ud *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 (udo *UserDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

func (udo *UserDeleteOne) ExecX(ctx context.Context)

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

func (*UserDeleteOne) Where

func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne

Where appends a list predicates to the UserDelete builder.

type UserEdges

type UserEdges struct {
	// Pets holds the value of the pets edge.
	Pets []*Pet `json:"pets,omitempty"`
	// Posts holds the value of the posts edge.
	Posts []*Post `json:"posts,omitempty"`
	// Parent holds the value of the parent edge.
	Parent *User `json:"parent,omitempty"`
	// Cars holds the value of the cars edge.
	Cars []*Car `json:"cars,omitempty"`
	// contains filtered or unexported fields
}

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

func (UserEdges) CarsOrErr

func (e UserEdges) CarsOrErr() ([]*Car, error)

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

func (UserEdges) ParentOrErr

func (e UserEdges) ParentOrErr() (*User, error)

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

func (UserEdges) PetsOrErr

func (e UserEdges) PetsOrErr() ([]*Pet, error)

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

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.

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

func (ugb *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 (ugb *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) AddAge

func (m *UserMutation) AddAge(i int)

AddAge adds i to the "age" field.

func (*UserMutation) AddCarIDs

func (m *UserMutation) AddCarIDs(ids ...int)

AddCarIDs adds the "cars" edge to the Car entity by ids.

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

func (m *UserMutation) AddPetIDs(ids ...int)

AddPetIDs adds the "pets" edge to the Pet entity by ids.

func (*UserMutation) AddPostIDs

func (m *UserMutation) AddPostIDs(ids ...int)

AddPostIDs adds the "posts" edge to the Post entity by ids.

func (*UserMutation) AddRole

func (m *UserMutation) AddRole(i int8)

AddRole adds i to the "role" field.

func (*UserMutation) AddedAge

func (m *UserMutation) AddedAge() (r int, exists bool)

AddedAge returns the value that was added to the "age" field in this mutation.

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

func (m *UserMutation) AddedRole() (r int8, exists bool)

AddedRole returns the value that was added to the "role" field in this mutation.

func (*UserMutation) Age

func (m *UserMutation) Age() (r int, exists bool)

Age returns the value of the "age" field in the mutation.

func (*UserMutation) AgeCleared

func (m *UserMutation) AgeCleared() bool

AgeCleared returns if the "age" field was cleared in this mutation.

func (*UserMutation) CarsCleared

func (m *UserMutation) CarsCleared() bool

CarsCleared reports if the "cars" edge to the Car entity was cleared.

func (*UserMutation) CarsIDs

func (m *UserMutation) CarsIDs() (ids []int)

CarsIDs returns the "cars" edge IDs in the mutation.

func (*UserMutation) ClearAge

func (m *UserMutation) ClearAge()

ClearAge clears the value of the "age" field.

func (*UserMutation) ClearCars

func (m *UserMutation) ClearCars()

ClearCars clears the "cars" edge to the Car entity.

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

func (m *UserMutation) ClearParent()

ClearParent clears the "parent" edge to the User entity.

func (*UserMutation) ClearPets

func (m *UserMutation) ClearPets()

ClearPets clears the "pets" edge to the Pet entity.

func (*UserMutation) ClearPosts

func (m *UserMutation) ClearPosts()

ClearPosts clears the "posts" edge to the Post entity.

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

func (m *UserMutation) Created() (r time.Time, exists bool)

Created returns the value of the "created" 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) Email

func (m *UserMutation) Email() (r string, exists bool)

Email returns the value of the "email" 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) Name

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

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

func (*UserMutation) OldAge

func (m *UserMutation) OldAge(ctx context.Context) (v *int, err error)

OldAge returns the old "age" 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) OldCreated

func (m *UserMutation) OldCreated(ctx context.Context) (v time.Time, err error)

OldCreated returns the old "created" 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) OldEmail

func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error)

OldEmail returns the old "email" 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) 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) OldRole

func (m *UserMutation) OldRole(ctx context.Context) (v int8, err error)

OldRole returns the old "role" 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) ParentCleared

func (m *UserMutation) ParentCleared() bool

ParentCleared reports if the "parent" edge to the User entity was cleared.

func (*UserMutation) ParentID

func (m *UserMutation) ParentID() (id int, exists bool)

ParentID returns the "parent" edge ID in the mutation.

func (*UserMutation) ParentIDs

func (m *UserMutation) ParentIDs() (ids []int)

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

func (*UserMutation) PetsCleared

func (m *UserMutation) PetsCleared() bool

PetsCleared reports if the "pets" edge to the Pet entity was cleared.

func (*UserMutation) PetsIDs

func (m *UserMutation) PetsIDs() (ids []int)

PetsIDs returns the "pets" edge IDs in the mutation.

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

func (m *UserMutation) RemoveCarIDs(ids ...int)

RemoveCarIDs removes the "cars" edge to the Car entity by IDs.

func (*UserMutation) RemovePetIDs

func (m *UserMutation) RemovePetIDs(ids ...int)

RemovePetIDs removes the "pets" edge to the Pet entity by IDs.

func (*UserMutation) RemovePostIDs

func (m *UserMutation) RemovePostIDs(ids ...int)

RemovePostIDs removes the "posts" edge to the Post entity by IDs.

func (*UserMutation) RemovedCarsIDs

func (m *UserMutation) RemovedCarsIDs() (ids []int)

RemovedCars returns the removed IDs of the "cars" edge to the Car entity.

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

func (m *UserMutation) RemovedPetsIDs() (ids []int)

RemovedPets returns the removed IDs of the "pets" edge to the Pet entity.

func (*UserMutation) RemovedPostsIDs

func (m *UserMutation) RemovedPostsIDs() (ids []int)

RemovedPosts returns the removed IDs of the "posts" edge to the Post entity.

func (*UserMutation) ResetAge

func (m *UserMutation) ResetAge()

ResetAge resets all changes to the "age" field.

func (*UserMutation) ResetCars

func (m *UserMutation) ResetCars()

ResetCars resets all changes to the "cars" edge.

func (*UserMutation) ResetCreated

func (m *UserMutation) ResetCreated()

ResetCreated resets all changes to the "created" 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) ResetEmail

func (m *UserMutation) ResetEmail()

ResetEmail resets all changes to the "email" 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) ResetName

func (m *UserMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*UserMutation) ResetParent

func (m *UserMutation) ResetParent()

ResetParent resets all changes to the "parent" edge.

func (*UserMutation) ResetPets

func (m *UserMutation) ResetPets()

ResetPets resets all changes to the "pets" edge.

func (*UserMutation) ResetPosts

func (m *UserMutation) ResetPosts()

ResetPosts resets all changes to the "posts" edge.

func (*UserMutation) ResetRole

func (m *UserMutation) ResetRole()

ResetRole resets all changes to the "role" field.

func (*UserMutation) Role

func (m *UserMutation) Role() (r int8, exists bool)

Role returns the value of the "role" field in the mutation.

func (*UserMutation) SetAge

func (m *UserMutation) SetAge(i int)

SetAge sets the "age" field.

func (*UserMutation) SetCreated

func (m *UserMutation) SetCreated(t time.Time)

SetCreated sets the "created" field.

func (*UserMutation) SetEmail

func (m *UserMutation) SetEmail(s string)

SetEmail sets the "email" 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) 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) SetParentID

func (m *UserMutation) SetParentID(id int)

SetParentID sets the "parent" edge to the User entity by id.

func (*UserMutation) SetRole

func (m *UserMutation) SetRole(i int8)

SetRole sets the "role" field.

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) 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 (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate returns a UserSelect configured with the given aggregations.

func (*UserQuery) All

func (uq *UserQuery) All(ctx context.Context) ([]*User, error)

All executes the query and returns a list of Users.

func (*UserQuery) AllX

func (uq *UserQuery) AllX(ctx context.Context) []*User

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

func (*UserQuery) Clone

func (uq *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 (uq *UserQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*UserQuery) CountX

func (uq *UserQuery) CountX(ctx context.Context) int

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

func (*UserQuery) Exist

func (uq *UserQuery) Exist(ctx context.Context) (bool, error)

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

func (*UserQuery) ExistX

func (uq *UserQuery) ExistX(ctx context.Context) bool

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

func (*UserQuery) First

func (uq *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 (uq *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 (uq *UserQuery) FirstIDX(ctx context.Context) int

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

func (*UserQuery) FirstX

func (uq *UserQuery) FirstX(ctx context.Context) *User

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

func (*UserQuery) GroupBy

func (uq *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 (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*UserQuery) IDsX

func (uq *UserQuery) IDsX(ctx context.Context) []int

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

func (*UserQuery) Limit

func (uq *UserQuery) Limit(limit int) *UserQuery

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

func (*UserQuery) Offset

func (uq *UserQuery) Offset(offset int) *UserQuery

Offset to start from.

func (*UserQuery) Only

func (uq *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 (uq *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 (uq *UserQuery) OnlyIDX(ctx context.Context) int

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

func (*UserQuery) OnlyX

func (uq *UserQuery) OnlyX(ctx context.Context) *User

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

func (*UserQuery) Order

func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery

Order specifies how the records should be ordered.

func (*UserQuery) QueryCars

func (uq *UserQuery) QueryCars() *CarQuery

QueryCars chains the current query on the "cars" edge.

func (*UserQuery) QueryParent

func (uq *UserQuery) QueryParent() *UserQuery

QueryParent chains the current query on the "parent" edge.

func (*UserQuery) QueryPets

func (uq *UserQuery) QueryPets() *PetQuery

QueryPets chains the current query on the "pets" edge.

func (*UserQuery) QueryPosts

func (uq *UserQuery) QueryPosts() *PostQuery

QueryPosts chains the current query on the "posts" edge.

func (*UserQuery) Select

func (uq *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 (uq *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 (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithCars

func (uq *UserQuery) WithCars(opts ...func(*CarQuery)) *UserQuery

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

func (*UserQuery) WithParent

func (uq *UserQuery) WithParent(opts ...func(*UserQuery)) *UserQuery

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

func (*UserQuery) WithPets

func (uq *UserQuery) WithPets(opts ...func(*PetQuery)) *UserQuery

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

func (*UserQuery) WithPosts

func (uq *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.

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 (us *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 (us *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) AddAge

func (uu *UserUpdate) AddAge(i int) *UserUpdate

AddAge adds i to the "age" field.

func (*UserUpdate) AddCarIDs

func (uu *UserUpdate) AddCarIDs(ids ...int) *UserUpdate

AddCarIDs adds the "cars" edge to the Car entity by IDs.

func (*UserUpdate) AddCars

func (uu *UserUpdate) AddCars(c ...*Car) *UserUpdate

AddCars adds the "cars" edges to the Car entity.

func (*UserUpdate) AddPetIDs

func (uu *UserUpdate) AddPetIDs(ids ...int) *UserUpdate

AddPetIDs adds the "pets" edge to the Pet entity by IDs.

func (*UserUpdate) AddPets

func (uu *UserUpdate) AddPets(p ...*Pet) *UserUpdate

AddPets adds the "pets" edges to the Pet entity.

func (*UserUpdate) AddPostIDs

func (uu *UserUpdate) AddPostIDs(ids ...int) *UserUpdate

AddPostIDs adds the "posts" edge to the Post entity by IDs.

func (*UserUpdate) AddPosts

func (uu *UserUpdate) AddPosts(p ...*Post) *UserUpdate

AddPosts adds the "posts" edges to the Post entity.

func (*UserUpdate) AddRole

func (uu *UserUpdate) AddRole(i int8) *UserUpdate

AddRole adds i to the "role" field.

func (*UserUpdate) ClearAge

func (uu *UserUpdate) ClearAge() *UserUpdate

ClearAge clears the value of the "age" field.

func (*UserUpdate) ClearCars

func (uu *UserUpdate) ClearCars() *UserUpdate

ClearCars clears all "cars" edges to the Car entity.

func (*UserUpdate) ClearParent

func (uu *UserUpdate) ClearParent() *UserUpdate

ClearParent clears the "parent" edge to the User entity.

func (*UserUpdate) ClearPets

func (uu *UserUpdate) ClearPets() *UserUpdate

ClearPets clears all "pets" edges to the Pet entity.

func (*UserUpdate) ClearPosts

func (uu *UserUpdate) ClearPosts() *UserUpdate

ClearPosts clears all "posts" edges to the Post entity.

func (*UserUpdate) Exec

func (uu *UserUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpdate) ExecX

func (uu *UserUpdate) ExecX(ctx context.Context)

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

func (*UserUpdate) Mutation

func (uu *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemoveCarIDs

func (uu *UserUpdate) RemoveCarIDs(ids ...int) *UserUpdate

RemoveCarIDs removes the "cars" edge to Car entities by IDs.

func (*UserUpdate) RemoveCars

func (uu *UserUpdate) RemoveCars(c ...*Car) *UserUpdate

RemoveCars removes "cars" edges to Car entities.

func (*UserUpdate) RemovePetIDs

func (uu *UserUpdate) RemovePetIDs(ids ...int) *UserUpdate

RemovePetIDs removes the "pets" edge to Pet entities by IDs.

func (*UserUpdate) RemovePets

func (uu *UserUpdate) RemovePets(p ...*Pet) *UserUpdate

RemovePets removes "pets" edges to Pet entities.

func (*UserUpdate) RemovePostIDs

func (uu *UserUpdate) RemovePostIDs(ids ...int) *UserUpdate

RemovePostIDs removes the "posts" edge to Post entities by IDs.

func (*UserUpdate) RemovePosts

func (uu *UserUpdate) RemovePosts(p ...*Post) *UserUpdate

RemovePosts removes "posts" edges to Post entities.

func (*UserUpdate) Save

func (uu *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 (uu *UserUpdate) SaveX(ctx context.Context) int

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

func (*UserUpdate) SetAge

func (uu *UserUpdate) SetAge(i int) *UserUpdate

SetAge sets the "age" field.

func (*UserUpdate) SetCreated

func (uu *UserUpdate) SetCreated(t time.Time) *UserUpdate

SetCreated sets the "created" field.

func (*UserUpdate) SetEmail

func (uu *UserUpdate) SetEmail(s string) *UserUpdate

SetEmail sets the "email" field.

func (*UserUpdate) SetName

func (uu *UserUpdate) SetName(s string) *UserUpdate

SetName sets the "name" field.

func (*UserUpdate) SetNillableAge

func (uu *UserUpdate) SetNillableAge(i *int) *UserUpdate

SetNillableAge sets the "age" field if the given value is not nil.

func (*UserUpdate) SetNillableCreated

func (uu *UserUpdate) SetNillableCreated(t *time.Time) *UserUpdate

SetNillableCreated sets the "created" field if the given value is not nil.

func (*UserUpdate) SetNillableParentID

func (uu *UserUpdate) SetNillableParentID(id *int) *UserUpdate

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

func (*UserUpdate) SetParent

func (uu *UserUpdate) SetParent(u *User) *UserUpdate

SetParent sets the "parent" edge to the User entity.

func (*UserUpdate) SetParentID

func (uu *UserUpdate) SetParentID(id int) *UserUpdate

SetParentID sets the "parent" edge to the User entity by ID.

func (*UserUpdate) SetRole

func (uu *UserUpdate) SetRole(i int8) *UserUpdate

SetRole sets the "role" field.

func (*UserUpdate) Where

func (uu *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) AddAge

func (uuo *UserUpdateOne) AddAge(i int) *UserUpdateOne

AddAge adds i to the "age" field.

func (*UserUpdateOne) AddCarIDs

func (uuo *UserUpdateOne) AddCarIDs(ids ...int) *UserUpdateOne

AddCarIDs adds the "cars" edge to the Car entity by IDs.

func (*UserUpdateOne) AddCars

func (uuo *UserUpdateOne) AddCars(c ...*Car) *UserUpdateOne

AddCars adds the "cars" edges to the Car entity.

func (*UserUpdateOne) AddPetIDs

func (uuo *UserUpdateOne) AddPetIDs(ids ...int) *UserUpdateOne

AddPetIDs adds the "pets" edge to the Pet entity by IDs.

func (*UserUpdateOne) AddPets

func (uuo *UserUpdateOne) AddPets(p ...*Pet) *UserUpdateOne

AddPets adds the "pets" edges to the Pet entity.

func (*UserUpdateOne) AddPostIDs

func (uuo *UserUpdateOne) AddPostIDs(ids ...int) *UserUpdateOne

AddPostIDs adds the "posts" edge to the Post entity by IDs.

func (*UserUpdateOne) AddPosts

func (uuo *UserUpdateOne) AddPosts(p ...*Post) *UserUpdateOne

AddPosts adds the "posts" edges to the Post entity.

func (*UserUpdateOne) AddRole

func (uuo *UserUpdateOne) AddRole(i int8) *UserUpdateOne

AddRole adds i to the "role" field.

func (*UserUpdateOne) ClearAge

func (uuo *UserUpdateOne) ClearAge() *UserUpdateOne

ClearAge clears the value of the "age" field.

func (*UserUpdateOne) ClearCars

func (uuo *UserUpdateOne) ClearCars() *UserUpdateOne

ClearCars clears all "cars" edges to the Car entity.

func (*UserUpdateOne) ClearParent

func (uuo *UserUpdateOne) ClearParent() *UserUpdateOne

ClearParent clears the "parent" edge to the User entity.

func (*UserUpdateOne) ClearPets

func (uuo *UserUpdateOne) ClearPets() *UserUpdateOne

ClearPets clears all "pets" edges to the Pet entity.

func (*UserUpdateOne) ClearPosts

func (uuo *UserUpdateOne) ClearPosts() *UserUpdateOne

ClearPosts clears all "posts" edges to the Post entity.

func (*UserUpdateOne) Exec

func (uuo *UserUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

func (uuo *UserUpdateOne) ExecX(ctx context.Context)

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

func (*UserUpdateOne) Mutation

func (uuo *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemoveCarIDs

func (uuo *UserUpdateOne) RemoveCarIDs(ids ...int) *UserUpdateOne

RemoveCarIDs removes the "cars" edge to Car entities by IDs.

func (*UserUpdateOne) RemoveCars

func (uuo *UserUpdateOne) RemoveCars(c ...*Car) *UserUpdateOne

RemoveCars removes "cars" edges to Car entities.

func (*UserUpdateOne) RemovePetIDs

func (uuo *UserUpdateOne) RemovePetIDs(ids ...int) *UserUpdateOne

RemovePetIDs removes the "pets" edge to Pet entities by IDs.

func (*UserUpdateOne) RemovePets

func (uuo *UserUpdateOne) RemovePets(p ...*Pet) *UserUpdateOne

RemovePets removes "pets" edges to Pet entities.

func (*UserUpdateOne) RemovePostIDs

func (uuo *UserUpdateOne) RemovePostIDs(ids ...int) *UserUpdateOne

RemovePostIDs removes the "posts" edge to Post entities by IDs.

func (*UserUpdateOne) RemovePosts

func (uuo *UserUpdateOne) RemovePosts(p ...*Post) *UserUpdateOne

RemovePosts removes "posts" edges to Post entities.

func (*UserUpdateOne) Save

func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User

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

func (*UserUpdateOne) Select

func (uuo *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) SetAge

func (uuo *UserUpdateOne) SetAge(i int) *UserUpdateOne

SetAge sets the "age" field.

func (*UserUpdateOne) SetCreated

func (uuo *UserUpdateOne) SetCreated(t time.Time) *UserUpdateOne

SetCreated sets the "created" field.

func (*UserUpdateOne) SetEmail

func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne

SetEmail sets the "email" field.

func (*UserUpdateOne) SetName

func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne

SetName sets the "name" field.

func (*UserUpdateOne) SetNillableAge

func (uuo *UserUpdateOne) SetNillableAge(i *int) *UserUpdateOne

SetNillableAge sets the "age" field if the given value is not nil.

func (*UserUpdateOne) SetNillableCreated

func (uuo *UserUpdateOne) SetNillableCreated(t *time.Time) *UserUpdateOne

SetNillableCreated sets the "created" field if the given value is not nil.

func (*UserUpdateOne) SetNillableParentID

func (uuo *UserUpdateOne) SetNillableParentID(id *int) *UserUpdateOne

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

func (*UserUpdateOne) SetParent

func (uuo *UserUpdateOne) SetParent(u *User) *UserUpdateOne

SetParent sets the "parent" edge to the User entity.

func (*UserUpdateOne) SetParentID

func (uuo *UserUpdateOne) SetParentID(id int) *UserUpdateOne

SetParentID sets the "parent" edge to the User entity by ID.

func (*UserUpdateOne) SetRole

func (uuo *UserUpdateOne) SetRole(i int8) *UserUpdateOne

SetRole sets the "role" field.

func (*UserUpdateOne) Where

func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne

Where appends a list predicates to the UserUpdate builder.

type Users

type Users []*User

Users is a parsable slice of User.

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