ent

package
v0.0.0-...-bd7f934 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 21 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.
	TypeAccessToken = "AccessToken"
	TypePost        = "Post"
	TypeUser        = "User"
)

Variables

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

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

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 AccessToken

type AccessToken struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// CreateTime holds the value of the "create_time" field.
	CreateTime time.Time `json:"create_time,omitempty"`
	// UpdateTime holds the value of the "update_time" field.
	UpdateTime time.Time `json:"update_time,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Value holds the value of the "value" field.
	Value string `json:"-"`
	// Owner holds the value of the "owner" field.
	Owner int `json:"owner,omitempty"`
	// ExpireTime holds the value of the "expire_time" field.
	ExpireTime int64 `json:"expire_time,omitempty"`
	// Creator holds the value of the "creator" field.
	Creator int `json:"creator,omitempty"`
	// contains filtered or unexported fields
}

AccessToken table stores all access token information.

func (*AccessToken) GetValue

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

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

func (*AccessToken) IntoEntity

func (a *AccessToken) IntoEntity() *AccessTokenEntity

IntoEntity converts ent AccessToken to AccessTokenEntity.

func (*AccessToken) String

func (_m *AccessToken) String() string

String implements the fmt.Stringer.

func (*AccessToken) Unwrap

func (_m *AccessToken) Unwrap() *AccessToken

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

func (_m *AccessToken) Update() *AccessTokenUpdateOne

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

type AccessTokenClient

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

AccessTokenClient is a client for the AccessToken schema.

func NewAccessTokenClient

func NewAccessTokenClient(c config) *AccessTokenClient

NewAccessTokenClient returns a client for the AccessToken from the given config.

func (*AccessTokenClient) Create

func (c *AccessTokenClient) Create() *AccessTokenCreate

Create returns a builder for creating a AccessToken entity.

func (*AccessTokenClient) CreateBulk

func (c *AccessTokenClient) CreateBulk(builders ...*AccessTokenCreate) *AccessTokenCreateBulk

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

func (*AccessTokenClient) Delete

func (c *AccessTokenClient) Delete() *AccessTokenDelete

Delete returns a delete builder for AccessToken.

func (*AccessTokenClient) DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*AccessTokenClient) DeleteOneID

func (c *AccessTokenClient) DeleteOneID(id int) *AccessTokenDeleteOne

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

func (*AccessTokenClient) Get

func (c *AccessTokenClient) Get(ctx context.Context, id int) (*AccessToken, error)

Get returns a AccessToken entity by its id.

func (*AccessTokenClient) GetX

func (c *AccessTokenClient) GetX(ctx context.Context, id int) *AccessToken

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

func (*AccessTokenClient) Hooks

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

Hooks returns the client hooks.

func (*AccessTokenClient) Intercept

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

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

func (*AccessTokenClient) Interceptors

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

Interceptors returns the client interceptors.

func (*AccessTokenClient) MapCreateBulk

func (c *AccessTokenClient) MapCreateBulk(slice any, setFunc func(*AccessTokenCreate, int)) *AccessTokenCreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*AccessTokenClient) Query

func (c *AccessTokenClient) Query() *AccessTokenQuery

Query returns a query builder for AccessToken.

func (*AccessTokenClient) Update

func (c *AccessTokenClient) Update() *AccessTokenUpdate

Update returns an update builder for AccessToken.

func (*AccessTokenClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*AccessTokenClient) UpdateOneID

func (c *AccessTokenClient) UpdateOneID(id int) *AccessTokenUpdateOne

UpdateOneID returns an update builder for the given id.

func (*AccessTokenClient) Use

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

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

type AccessTokenCreate

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

AccessTokenCreate is the builder for creating a AccessToken entity.

func (*AccessTokenCreate) Exec

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

Exec executes the query.

func (*AccessTokenCreate) ExecX

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

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

func (*AccessTokenCreate) Mutation

func (_c *AccessTokenCreate) Mutation() *AccessTokenMutation

Mutation returns the AccessTokenMutation object of the builder.

func (*AccessTokenCreate) Save

Save creates the AccessToken in the database.

func (*AccessTokenCreate) SaveX

func (_c *AccessTokenCreate) SaveX(ctx context.Context) *AccessToken

SaveX calls Save and panics if Save returns an error.

func (*AccessTokenCreate) SetCreateTime

func (_c *AccessTokenCreate) SetCreateTime(v time.Time) *AccessTokenCreate

SetCreateTime sets the "create_time" field.

func (*AccessTokenCreate) SetCreator

func (_c *AccessTokenCreate) SetCreator(v int) *AccessTokenCreate

SetCreator sets the "creator" field.

func (*AccessTokenCreate) SetExpireTime

func (_c *AccessTokenCreate) SetExpireTime(v int64) *AccessTokenCreate

SetExpireTime sets the "expire_time" field.

func (*AccessTokenCreate) SetName

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

SetName sets the "name" field.

func (*AccessTokenCreate) SetNillableCreateTime

func (_c *AccessTokenCreate) SetNillableCreateTime(v *time.Time) *AccessTokenCreate

SetNillableCreateTime sets the "create_time" field if the given value is not nil.

func (*AccessTokenCreate) SetNillableUpdateTime

func (_c *AccessTokenCreate) SetNillableUpdateTime(v *time.Time) *AccessTokenCreate

SetNillableUpdateTime sets the "update_time" field if the given value is not nil.

func (*AccessTokenCreate) SetOwner

func (_c *AccessTokenCreate) SetOwner(v int) *AccessTokenCreate

SetOwner sets the "owner" field.

func (*AccessTokenCreate) SetUpdateTime

func (_c *AccessTokenCreate) SetUpdateTime(v time.Time) *AccessTokenCreate

SetUpdateTime sets the "update_time" field.

func (*AccessTokenCreate) SetValue

func (_c *AccessTokenCreate) SetValue(v string) *AccessTokenCreate

SetValue sets the "value" field.

type AccessTokenCreateBulk

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

AccessTokenCreateBulk is the builder for creating many AccessToken entities in bulk.

func (*AccessTokenCreateBulk) Exec

Exec executes the query.

func (*AccessTokenCreateBulk) ExecX

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

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

func (*AccessTokenCreateBulk) Save

Save creates the AccessToken entities in the database.

func (*AccessTokenCreateBulk) SaveX

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

type AccessTokenDelete

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

AccessTokenDelete is the builder for deleting a AccessToken entity.

func (*AccessTokenDelete) Exec

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

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

func (*AccessTokenDelete) ExecX

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

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

func (*AccessTokenDelete) Where

Where appends a list predicates to the AccessTokenDelete builder.

type AccessTokenDeleteOne

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

AccessTokenDeleteOne is the builder for deleting a single AccessToken entity.

func (*AccessTokenDeleteOne) Exec

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

Exec executes the deletion query.

func (*AccessTokenDeleteOne) ExecX

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

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

func (*AccessTokenDeleteOne) Where

Where appends a list predicates to the AccessTokenDelete builder.

type AccessTokenEntity

type AccessTokenEntity struct {
	ID         int    `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	Owner      int    `json:"owner,omitempty"`
	Creator    int    `json:"creator,omitempty"`
	CreateTime string `json:"createTime,omitempty"`
	UpdateTime string `json:"updateTime,omitempty"`
}

AccessTokenEntity -.

type AccessTokenGroupBy

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

AccessTokenGroupBy is the group-by builder for AccessToken entities.

func (*AccessTokenGroupBy) Aggregate

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

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

func (*AccessTokenGroupBy) Bool

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

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

func (*AccessTokenGroupBy) BoolX

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

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

func (*AccessTokenGroupBy) Bools

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

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

func (*AccessTokenGroupBy) BoolsX

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

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

func (*AccessTokenGroupBy) Float64

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

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

func (*AccessTokenGroupBy) Float64X

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

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

func (*AccessTokenGroupBy) Float64s

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

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

func (*AccessTokenGroupBy) Float64sX

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

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

func (*AccessTokenGroupBy) Int

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

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

func (*AccessTokenGroupBy) IntX

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

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

func (*AccessTokenGroupBy) Ints

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

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

func (*AccessTokenGroupBy) IntsX

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

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

func (*AccessTokenGroupBy) Scan

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

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

func (*AccessTokenGroupBy) ScanX

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

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

func (*AccessTokenGroupBy) String

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

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

func (*AccessTokenGroupBy) StringX

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

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

func (*AccessTokenGroupBy) Strings

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

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

func (*AccessTokenGroupBy) StringsX

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

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

type AccessTokenMutation

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

AccessTokenMutation represents an operation that mutates the AccessToken nodes in the graph.

func (*AccessTokenMutation) AddCreator

func (m *AccessTokenMutation) AddCreator(i int)

AddCreator adds i to the "creator" field.

func (*AccessTokenMutation) AddExpireTime

func (m *AccessTokenMutation) AddExpireTime(i int64)

AddExpireTime adds i to the "expire_time" field.

func (*AccessTokenMutation) AddField

func (m *AccessTokenMutation) 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 (*AccessTokenMutation) AddOwner

func (m *AccessTokenMutation) AddOwner(i int)

AddOwner adds i to the "owner" field.

func (*AccessTokenMutation) AddedCreator

func (m *AccessTokenMutation) AddedCreator() (r int, exists bool)

AddedCreator returns the value that was added to the "creator" field in this mutation.

func (*AccessTokenMutation) AddedEdges

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

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

func (*AccessTokenMutation) AddedExpireTime

func (m *AccessTokenMutation) AddedExpireTime() (r int64, exists bool)

AddedExpireTime returns the value that was added to the "expire_time" field in this mutation.

func (*AccessTokenMutation) AddedField

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

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

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

func (*AccessTokenMutation) AddedIDs

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

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

func (*AccessTokenMutation) AddedOwner

func (m *AccessTokenMutation) AddedOwner() (r int, exists bool)

AddedOwner returns the value that was added to the "owner" field in this mutation.

func (*AccessTokenMutation) ClearEdge

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

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

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

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

func (*AccessTokenMutation) ClearedFields

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

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

func (AccessTokenMutation) Client

func (m AccessTokenMutation) 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 (*AccessTokenMutation) CreateTime

func (m *AccessTokenMutation) CreateTime() (r time.Time, exists bool)

CreateTime returns the value of the "create_time" field in the mutation.

func (*AccessTokenMutation) Creator

func (m *AccessTokenMutation) Creator() (r int, exists bool)

Creator returns the value of the "creator" field in the mutation.

func (*AccessTokenMutation) EdgeCleared

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

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

func (*AccessTokenMutation) ExpireTime

func (m *AccessTokenMutation) ExpireTime() (r int64, exists bool)

ExpireTime returns the value of the "expire_time" field in the mutation.

func (*AccessTokenMutation) Field

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

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

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

func (*AccessTokenMutation) Fields

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

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

func (m *AccessTokenMutation) 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 (*AccessTokenMutation) Name

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

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

func (*AccessTokenMutation) OldCreateTime

func (m *AccessTokenMutation) OldCreateTime(ctx context.Context) (v time.Time, err error)

OldCreateTime returns the old "create_time" field's value of the AccessToken entity. If the AccessToken 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 (*AccessTokenMutation) OldCreator

func (m *AccessTokenMutation) OldCreator(ctx context.Context) (v int, err error)

OldCreator returns the old "creator" field's value of the AccessToken entity. If the AccessToken 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 (*AccessTokenMutation) OldExpireTime

func (m *AccessTokenMutation) OldExpireTime(ctx context.Context) (v int64, err error)

OldExpireTime returns the old "expire_time" field's value of the AccessToken entity. If the AccessToken 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 (*AccessTokenMutation) OldField

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

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

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

func (m *AccessTokenMutation) OldOwner(ctx context.Context) (v int, err error)

OldOwner returns the old "owner" field's value of the AccessToken entity. If the AccessToken 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 (*AccessTokenMutation) OldUpdateTime

func (m *AccessTokenMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error)

OldUpdateTime returns the old "update_time" field's value of the AccessToken entity. If the AccessToken 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 (*AccessTokenMutation) OldValue

func (m *AccessTokenMutation) OldValue(ctx context.Context) (v string, err error)

OldValue returns the old "value" field's value of the AccessToken entity. If the AccessToken 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 (*AccessTokenMutation) Op

func (m *AccessTokenMutation) Op() Op

Op returns the operation name.

func (*AccessTokenMutation) Owner

func (m *AccessTokenMutation) Owner() (r int, exists bool)

Owner returns the value of the "owner" field in the mutation.

func (*AccessTokenMutation) RemovedEdges

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

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

func (*AccessTokenMutation) RemovedIDs

func (m *AccessTokenMutation) 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 (*AccessTokenMutation) ResetCreateTime

func (m *AccessTokenMutation) ResetCreateTime()

ResetCreateTime resets all changes to the "create_time" field.

func (*AccessTokenMutation) ResetCreator

func (m *AccessTokenMutation) ResetCreator()

ResetCreator resets all changes to the "creator" field.

func (*AccessTokenMutation) ResetEdge

func (m *AccessTokenMutation) 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 (*AccessTokenMutation) ResetExpireTime

func (m *AccessTokenMutation) ResetExpireTime()

ResetExpireTime resets all changes to the "expire_time" field.

func (*AccessTokenMutation) ResetField

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

func (m *AccessTokenMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*AccessTokenMutation) ResetOwner

func (m *AccessTokenMutation) ResetOwner()

ResetOwner resets all changes to the "owner" field.

func (*AccessTokenMutation) ResetUpdateTime

func (m *AccessTokenMutation) ResetUpdateTime()

ResetUpdateTime resets all changes to the "update_time" field.

func (*AccessTokenMutation) ResetValue

func (m *AccessTokenMutation) ResetValue()

ResetValue resets all changes to the "value" field.

func (*AccessTokenMutation) SetCreateTime

func (m *AccessTokenMutation) SetCreateTime(t time.Time)

SetCreateTime sets the "create_time" field.

func (*AccessTokenMutation) SetCreator

func (m *AccessTokenMutation) SetCreator(i int)

SetCreator sets the "creator" field.

func (*AccessTokenMutation) SetExpireTime

func (m *AccessTokenMutation) SetExpireTime(i int64)

SetExpireTime sets the "expire_time" field.

func (*AccessTokenMutation) SetField

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

func (m *AccessTokenMutation) SetName(s string)

SetName sets the "name" field.

func (*AccessTokenMutation) SetOp

func (m *AccessTokenMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*AccessTokenMutation) SetOwner

func (m *AccessTokenMutation) SetOwner(i int)

SetOwner sets the "owner" field.

func (*AccessTokenMutation) SetUpdateTime

func (m *AccessTokenMutation) SetUpdateTime(t time.Time)

SetUpdateTime sets the "update_time" field.

func (*AccessTokenMutation) SetValue

func (m *AccessTokenMutation) SetValue(s string)

SetValue sets the "value" field.

func (AccessTokenMutation) Tx

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

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

func (*AccessTokenMutation) Type

func (m *AccessTokenMutation) Type() string

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

func (*AccessTokenMutation) UpdateTime

func (m *AccessTokenMutation) UpdateTime() (r time.Time, exists bool)

UpdateTime returns the value of the "update_time" field in the mutation.

func (*AccessTokenMutation) Value

func (m *AccessTokenMutation) Value() (r string, exists bool)

Value returns the value of the "value" field in the mutation.

func (*AccessTokenMutation) Where

func (m *AccessTokenMutation) Where(ps ...predicate.AccessToken)

Where appends a list predicates to the AccessTokenMutation builder.

func (*AccessTokenMutation) WhereP

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

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

type AccessTokenQuery

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

AccessTokenQuery is the builder for querying AccessToken entities.

func (*AccessTokenQuery) Aggregate

func (_q *AccessTokenQuery) Aggregate(fns ...AggregateFunc) *AccessTokenSelect

Aggregate returns a AccessTokenSelect configured with the given aggregations.

func (*AccessTokenQuery) All

func (_q *AccessTokenQuery) All(ctx context.Context) ([]*AccessToken, error)

All executes the query and returns a list of AccessTokens.

func (*AccessTokenQuery) AllX

func (_q *AccessTokenQuery) AllX(ctx context.Context) []*AccessToken

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

func (*AccessTokenQuery) Clone

func (_q *AccessTokenQuery) Clone() *AccessTokenQuery

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

func (*AccessTokenQuery) Count

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

Count returns the count of the given query.

func (*AccessTokenQuery) CountX

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

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

func (*AccessTokenQuery) Exist

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

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

func (*AccessTokenQuery) ExistX

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

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

func (*AccessTokenQuery) First

func (_q *AccessTokenQuery) First(ctx context.Context) (*AccessToken, error)

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

func (*AccessTokenQuery) FirstID

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

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

func (*AccessTokenQuery) FirstIDX

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

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

func (*AccessTokenQuery) FirstX

func (_q *AccessTokenQuery) FirstX(ctx context.Context) *AccessToken

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

func (*AccessTokenQuery) GroupBy

func (_q *AccessTokenQuery) GroupBy(field string, fields ...string) *AccessTokenGroupBy

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 {
	CreateTime time.Time `json:"create_time,omitempty"`
	Count int `json:"count,omitempty"`
}

client.AccessToken.Query().
	GroupBy(accesstoken.FieldCreateTime).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*AccessTokenQuery) IDs

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

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

func (*AccessTokenQuery) IDsX

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

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

func (*AccessTokenQuery) Limit

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

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

func (*AccessTokenQuery) Offset

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

Offset to start from.

func (*AccessTokenQuery) Only

func (_q *AccessTokenQuery) Only(ctx context.Context) (*AccessToken, error)

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

func (*AccessTokenQuery) OnlyID

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

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

func (*AccessTokenQuery) OnlyIDX

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

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

func (*AccessTokenQuery) OnlyX

func (_q *AccessTokenQuery) OnlyX(ctx context.Context) *AccessToken

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

func (*AccessTokenQuery) Order

Order specifies how the records should be ordered.

func (*AccessTokenQuery) Select

func (_q *AccessTokenQuery) Select(fields ...string) *AccessTokenSelect

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 {
	CreateTime time.Time `json:"create_time,omitempty"`
}

client.AccessToken.Query().
	Select(accesstoken.FieldCreateTime).
	Scan(ctx, &v)

func (*AccessTokenQuery) Unique

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

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

Where adds a new predicate for the AccessTokenQuery builder.

type AccessTokenSelect

type AccessTokenSelect struct {
	*AccessTokenQuery
	// contains filtered or unexported fields
}

AccessTokenSelect is the builder for selecting fields of AccessToken entities.

func (*AccessTokenSelect) Aggregate

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

Aggregate adds the given aggregation functions to the selector query.

func (*AccessTokenSelect) Bool

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

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

func (*AccessTokenSelect) BoolX

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

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

func (*AccessTokenSelect) Bools

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

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

func (*AccessTokenSelect) BoolsX

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

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

func (*AccessTokenSelect) Float64

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

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

func (*AccessTokenSelect) Float64X

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

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

func (*AccessTokenSelect) Float64s

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

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

func (*AccessTokenSelect) Float64sX

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

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

func (*AccessTokenSelect) Int

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

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

func (*AccessTokenSelect) IntX

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

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

func (*AccessTokenSelect) Ints

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

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

func (*AccessTokenSelect) IntsX

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

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

func (*AccessTokenSelect) Scan

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

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

func (*AccessTokenSelect) ScanX

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

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

func (*AccessTokenSelect) String

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

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

func (*AccessTokenSelect) StringX

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

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

func (*AccessTokenSelect) Strings

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

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

func (*AccessTokenSelect) StringsX

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

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

type AccessTokenUpdate

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

AccessTokenUpdate is the builder for updating AccessToken entities.

func (*AccessTokenUpdate) AddCreator

func (_u *AccessTokenUpdate) AddCreator(v int) *AccessTokenUpdate

AddCreator adds value to the "creator" field.

func (*AccessTokenUpdate) AddExpireTime

func (_u *AccessTokenUpdate) AddExpireTime(v int64) *AccessTokenUpdate

AddExpireTime adds value to the "expire_time" field.

func (*AccessTokenUpdate) AddOwner

func (_u *AccessTokenUpdate) AddOwner(v int) *AccessTokenUpdate

AddOwner adds value to the "owner" field.

func (*AccessTokenUpdate) Exec

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

Exec executes the query.

func (*AccessTokenUpdate) ExecX

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

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

func (*AccessTokenUpdate) Mutation

func (_u *AccessTokenUpdate) Mutation() *AccessTokenMutation

Mutation returns the AccessTokenMutation object of the builder.

func (*AccessTokenUpdate) Save

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

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

func (*AccessTokenUpdate) SaveX

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

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

func (*AccessTokenUpdate) SetCreator

func (_u *AccessTokenUpdate) SetCreator(v int) *AccessTokenUpdate

SetCreator sets the "creator" field.

func (*AccessTokenUpdate) SetExpireTime

func (_u *AccessTokenUpdate) SetExpireTime(v int64) *AccessTokenUpdate

SetExpireTime sets the "expire_time" field.

func (*AccessTokenUpdate) SetName

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

SetName sets the "name" field.

func (*AccessTokenUpdate) SetNillableCreator

func (_u *AccessTokenUpdate) SetNillableCreator(v *int) *AccessTokenUpdate

SetNillableCreator sets the "creator" field if the given value is not nil.

func (*AccessTokenUpdate) SetNillableExpireTime

func (_u *AccessTokenUpdate) SetNillableExpireTime(v *int64) *AccessTokenUpdate

SetNillableExpireTime sets the "expire_time" field if the given value is not nil.

func (*AccessTokenUpdate) SetNillableName

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

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

func (*AccessTokenUpdate) SetNillableOwner

func (_u *AccessTokenUpdate) SetNillableOwner(v *int) *AccessTokenUpdate

SetNillableOwner sets the "owner" field if the given value is not nil.

func (*AccessTokenUpdate) SetNillableValue

func (_u *AccessTokenUpdate) SetNillableValue(v *string) *AccessTokenUpdate

SetNillableValue sets the "value" field if the given value is not nil.

func (*AccessTokenUpdate) SetOwner

func (_u *AccessTokenUpdate) SetOwner(v int) *AccessTokenUpdate

SetOwner sets the "owner" field.

func (*AccessTokenUpdate) SetUpdateTime

func (_u *AccessTokenUpdate) SetUpdateTime(v time.Time) *AccessTokenUpdate

SetUpdateTime sets the "update_time" field.

func (*AccessTokenUpdate) SetValue

func (_u *AccessTokenUpdate) SetValue(v string) *AccessTokenUpdate

SetValue sets the "value" field.

func (*AccessTokenUpdate) Where

Where appends a list predicates to the AccessTokenUpdate builder.

type AccessTokenUpdateOne

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

AccessTokenUpdateOne is the builder for updating a single AccessToken entity.

func (*AccessTokenUpdateOne) AddCreator

func (_u *AccessTokenUpdateOne) AddCreator(v int) *AccessTokenUpdateOne

AddCreator adds value to the "creator" field.

func (*AccessTokenUpdateOne) AddExpireTime

func (_u *AccessTokenUpdateOne) AddExpireTime(v int64) *AccessTokenUpdateOne

AddExpireTime adds value to the "expire_time" field.

func (*AccessTokenUpdateOne) AddOwner

AddOwner adds value to the "owner" field.

func (*AccessTokenUpdateOne) Exec

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

Exec executes the query on the entity.

func (*AccessTokenUpdateOne) ExecX

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

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

func (*AccessTokenUpdateOne) Mutation

func (_u *AccessTokenUpdateOne) Mutation() *AccessTokenMutation

Mutation returns the AccessTokenMutation object of the builder.

func (*AccessTokenUpdateOne) Save

Save executes the query and returns the updated AccessToken entity.

func (*AccessTokenUpdateOne) SaveX

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

func (*AccessTokenUpdateOne) Select

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

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

func (*AccessTokenUpdateOne) SetCreator

func (_u *AccessTokenUpdateOne) SetCreator(v int) *AccessTokenUpdateOne

SetCreator sets the "creator" field.

func (*AccessTokenUpdateOne) SetExpireTime

func (_u *AccessTokenUpdateOne) SetExpireTime(v int64) *AccessTokenUpdateOne

SetExpireTime sets the "expire_time" field.

func (*AccessTokenUpdateOne) SetName

SetName sets the "name" field.

func (*AccessTokenUpdateOne) SetNillableCreator

func (_u *AccessTokenUpdateOne) SetNillableCreator(v *int) *AccessTokenUpdateOne

SetNillableCreator sets the "creator" field if the given value is not nil.

func (*AccessTokenUpdateOne) SetNillableExpireTime

func (_u *AccessTokenUpdateOne) SetNillableExpireTime(v *int64) *AccessTokenUpdateOne

SetNillableExpireTime sets the "expire_time" field if the given value is not nil.

func (*AccessTokenUpdateOne) SetNillableName

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

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

func (*AccessTokenUpdateOne) SetNillableOwner

func (_u *AccessTokenUpdateOne) SetNillableOwner(v *int) *AccessTokenUpdateOne

SetNillableOwner sets the "owner" field if the given value is not nil.

func (*AccessTokenUpdateOne) SetNillableValue

func (_u *AccessTokenUpdateOne) SetNillableValue(v *string) *AccessTokenUpdateOne

SetNillableValue sets the "value" field if the given value is not nil.

func (*AccessTokenUpdateOne) SetOwner

SetOwner sets the "owner" field.

func (*AccessTokenUpdateOne) SetUpdateTime

func (_u *AccessTokenUpdateOne) SetUpdateTime(v time.Time) *AccessTokenUpdateOne

SetUpdateTime sets the "update_time" field.

func (*AccessTokenUpdateOne) SetValue

SetValue sets the "value" field.

func (*AccessTokenUpdateOne) Where

Where appends a list predicates to the AccessTokenUpdate builder.

type AccessTokens

type AccessTokens []*AccessToken

AccessTokens is a parsable slice of AccessToken.

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

GroupBy(field1, field2).
Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
Scan(ctx, &v)

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// AccessToken is the client for interacting with the AccessToken builders.
	AccessToken *AccessTokenClient
	// 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().
	AccessToken.
	Query().
	Count(ctx)

func (*Client) Intercept

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

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

func (*Client) Mutate

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

Mutate implements the ent.Mutator interface.

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

The CommitFunc type is an adapter to allow the use of ordinary function as a Committer. If f is a function with the appropriate signature, CommitFunc(f) is a Committer that calls f.

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

CommitHook defines the "commit middleware". A function that gets a Committer and returns a Committer. For example:

hook := func(next ent.Committer) ent.Committer {
	return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Commit(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

ConstraintError returns when trying to create/update one or more entities and one or more of their constraints failed. For example, violation of edge or field uniqueness.

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

NotFoundError returns when trying to fetch a specific entity and it was not found in the database.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

NotLoadedError returns when trying to get a node that was not loaded by the query.

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

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

type Policy

type Policy = ent.Policy

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

type Post

type Post struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// CreateTime holds the value of the "create_time" field.
	CreateTime time.Time `json:"create_time,omitempty"`
	// UpdateTime holds the value of the "update_time" field.
	UpdateTime time.Time `json:"update_time,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Content holds the value of the "content" field.
	Content string `json:"content,omitempty"`
	// Category holds the value of the "category" field.
	Category post.Category `json:"category,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 table stores all post information.

func (*Post) IntoEntity

func (p *Post) IntoEntity() *PostEntity

IntoEntity converts ent Post to PostEntity.

func (*Post) QueryOwner

func (_m *Post) QueryOwner() *UserQuery

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

func (*Post) String

func (_m *Post) String() string

String implements the fmt.Stringer.

func (*Post) Unwrap

func (_m *Post) Unwrap() *Post

Unwrap unwraps the Post entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.

func (*Post) Update

func (_m *Post) Update() *PostUpdateOne

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

func (*Post) Value

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

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

type PostClient

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

PostClient is a client for the Post schema.

func NewPostClient

func NewPostClient(c config) *PostClient

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

func (*PostClient) Create

func (c *PostClient) Create() *PostCreate

Create returns a builder for creating a Post entity.

func (*PostClient) CreateBulk

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

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

func (*PostClient) Delete

func (c *PostClient) Delete() *PostDelete

Delete returns a delete builder for Post.

func (*PostClient) DeleteOne

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

DeleteOne returns a builder for deleting the given entity.

func (*PostClient) DeleteOneID

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

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

func (*PostClient) Get

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

Get returns a Post entity by its id.

func (*PostClient) GetX

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

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

func (*PostClient) Hooks

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

Hooks returns the client hooks.

func (*PostClient) Intercept

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

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

func (*PostClient) Interceptors

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

Interceptors returns the client interceptors.

func (*PostClient) MapCreateBulk

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

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*PostClient) Query

func (c *PostClient) Query() *PostQuery

Query returns a query builder for Post.

func (*PostClient) QueryOwner

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

QueryOwner queries the owner edge of a Post.

func (*PostClient) Update

func (c *PostClient) Update() *PostUpdate

Update returns an update builder for Post.

func (*PostClient) UpdateOne

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

UpdateOne returns an update builder for the given entity.

func (*PostClient) UpdateOneID

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

UpdateOneID returns an update builder for the given id.

func (*PostClient) Use

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

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

type PostCreate

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

PostCreate is the builder for creating a Post entity.

func (*PostCreate) Exec

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

Exec executes the query.

func (*PostCreate) ExecX

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

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

func (*PostCreate) Mutation

func (_c *PostCreate) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostCreate) Save

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

Save creates the Post in the database.

func (*PostCreate) SaveX

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

SaveX calls Save and panics if Save returns an error.

func (*PostCreate) SetCategory

func (_c *PostCreate) SetCategory(v post.Category) *PostCreate

SetCategory sets the "category" field.

func (*PostCreate) SetContent

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

SetContent sets the "content" field.

func (*PostCreate) SetCreateTime

func (_c *PostCreate) SetCreateTime(v time.Time) *PostCreate

SetCreateTime sets the "create_time" field.

func (*PostCreate) SetNillableContent

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

SetNillableContent sets the "content" field if the given value is not nil.

func (*PostCreate) SetNillableCreateTime

func (_c *PostCreate) SetNillableCreateTime(v *time.Time) *PostCreate

SetNillableCreateTime sets the "create_time" field if the given value is not nil.

func (*PostCreate) SetNillableUpdateTime

func (_c *PostCreate) SetNillableUpdateTime(v *time.Time) *PostCreate

SetNillableUpdateTime sets the "update_time" field if the given value is not nil.

func (*PostCreate) SetOwner

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

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

func (*PostCreate) SetOwnerID

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

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

func (*PostCreate) SetTitle

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

SetTitle sets the "title" field.

func (*PostCreate) SetUpdateTime

func (_c *PostCreate) SetUpdateTime(v time.Time) *PostCreate

SetUpdateTime sets the "update_time" field.

type PostCreateBulk

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

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

func (*PostCreateBulk) Exec

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

Exec executes the query.

func (*PostCreateBulk) ExecX

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

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

func (*PostCreateBulk) Save

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

Save creates the Post entities in the database.

func (*PostCreateBulk) SaveX

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

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

type PostDelete

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

PostDelete is the builder for deleting a Post entity.

func (*PostDelete) Exec

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

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

func (*PostDelete) ExecX

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

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

func (*PostDelete) Where

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

Where appends a list predicates to the PostDelete builder.

type PostDeleteOne

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

PostDeleteOne is the builder for deleting a single Post entity.

func (*PostDeleteOne) Exec

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

Exec executes the deletion query.

func (*PostDeleteOne) ExecX

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

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

func (*PostDeleteOne) Where

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

Where appends a list predicates to the PostDelete builder.

type PostEdges

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

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

func (PostEdges) OwnerOrErr

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

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

type PostEntity

type PostEntity struct {
	ID         int           `json:"id,omitempty"`
	Title      string        `json:"title,omitempty"`
	Content    string        `json:"content,omitempty"`
	Category   post.Category `json:"category,omitempty"`
	CreateTime string        `json:"createTime,omitempty"`
	UpdateTime string        `json:"updateTime,omitempty"`
}

PostEntity -.

type PostGroupBy

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

PostGroupBy is the group-by builder for Post entities.

func (*PostGroupBy) Aggregate

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

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

func (*PostGroupBy) Bool

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

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

func (*PostGroupBy) BoolX

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

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

func (*PostGroupBy) Bools

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

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

func (*PostGroupBy) BoolsX

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

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

func (*PostGroupBy) Float64

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

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

func (*PostGroupBy) Float64X

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

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

func (*PostGroupBy) Float64s

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

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

func (*PostGroupBy) Float64sX

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

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

func (*PostGroupBy) Int

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

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

func (*PostGroupBy) IntX

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

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

func (*PostGroupBy) Ints

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

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

func (*PostGroupBy) IntsX

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

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

func (*PostGroupBy) Scan

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

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

func (*PostGroupBy) ScanX

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

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

func (*PostGroupBy) String

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

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

func (*PostGroupBy) StringX

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

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

func (*PostGroupBy) Strings

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

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

func (*PostGroupBy) StringsX

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

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

type PostMutation

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

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

func (*PostMutation) AddField

func (m *PostMutation) AddField(name string, value ent.Value) error

AddField adds the value to the field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

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

func (m *PostMutation) Category() (r post.Category, exists bool)

Category returns the value of the "category" field in the mutation.

func (*PostMutation) ClearContent

func (m *PostMutation) ClearContent()

ClearContent clears the value of the "content" field.

func (*PostMutation) ClearEdge

func (m *PostMutation) ClearEdge(name string) error

ClearEdge clears the value of the edge with the given name. It returns an error if that edge is not defined in the schema.

func (*PostMutation) ClearField

func (m *PostMutation) ClearField(name string) error

ClearField clears the value of the field with the given name. It returns an error if the field is not defined in the schema.

func (*PostMutation) ClearOwner

func (m *PostMutation) ClearOwner()

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

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

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

Content returns the value of the "content" field in the mutation.

func (*PostMutation) ContentCleared

func (m *PostMutation) ContentCleared() bool

ContentCleared returns if the "content" field was cleared in this mutation.

func (*PostMutation) CreateTime

func (m *PostMutation) CreateTime() (r time.Time, exists bool)

CreateTime returns the value of the "create_time" field in the mutation.

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

func (m *PostMutation) OldCategory(ctx context.Context) (v post.Category, err error)

OldCategory returns the old "category" field's value of the Post entity. If the Post object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*PostMutation) OldContent

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

OldContent returns the old "content" field's value of the Post entity. If the Post object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*PostMutation) OldCreateTime

func (m *PostMutation) OldCreateTime(ctx context.Context) (v time.Time, err error)

OldCreateTime returns the old "create_time" field's value of the Post entity. If the Post object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

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

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

OldTitle returns the old "title" field's value of the Post entity. If the Post object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*PostMutation) OldUpdateTime

func (m *PostMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error)

OldUpdateTime returns the old "update_time" field's value of the Post entity. If the Post object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*PostMutation) Op

func (m *PostMutation) Op() Op

Op returns the operation name.

func (*PostMutation) OwnerCleared

func (m *PostMutation) OwnerCleared() bool

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

func (*PostMutation) OwnerID

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

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

func (*PostMutation) OwnerIDs

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

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

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

func (m *PostMutation) ResetCategory()

ResetCategory resets all changes to the "category" field.

func (*PostMutation) ResetContent

func (m *PostMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*PostMutation) ResetCreateTime

func (m *PostMutation) ResetCreateTime()

ResetCreateTime resets all changes to the "create_time" field.

func (*PostMutation) ResetEdge

func (m *PostMutation) ResetEdge(name string) error

ResetEdge resets all changes to the edge with the given name in this mutation. It returns an error if the edge is not defined in the schema.

func (*PostMutation) ResetField

func (m *PostMutation) ResetField(name string) error

ResetField resets all changes in the mutation for the field with the given name. It returns an error if the field is not defined in the schema.

func (*PostMutation) ResetOwner

func (m *PostMutation) ResetOwner()

ResetOwner resets all changes to the "owner" edge.

func (*PostMutation) ResetTitle

func (m *PostMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*PostMutation) ResetUpdateTime

func (m *PostMutation) ResetUpdateTime()

ResetUpdateTime resets all changes to the "update_time" field.

func (*PostMutation) SetCategory

func (m *PostMutation) SetCategory(po post.Category)

SetCategory sets the "category" field.

func (*PostMutation) SetContent

func (m *PostMutation) SetContent(s string)

SetContent sets the "content" field.

func (*PostMutation) SetCreateTime

func (m *PostMutation) SetCreateTime(t time.Time)

SetCreateTime sets the "create_time" field.

func (*PostMutation) SetField

func (m *PostMutation) SetField(name string, value ent.Value) error

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

func (*PostMutation) SetOp

func (m *PostMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*PostMutation) SetOwnerID

func (m *PostMutation) SetOwnerID(id int)

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

func (*PostMutation) SetTitle

func (m *PostMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*PostMutation) SetUpdateTime

func (m *PostMutation) SetUpdateTime(t time.Time)

SetUpdateTime sets the "update_time" field.

func (*PostMutation) Title

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

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

func (PostMutation) Tx

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

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

func (*PostMutation) Type

func (m *PostMutation) Type() string

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

func (*PostMutation) UpdateTime

func (m *PostMutation) UpdateTime() (r time.Time, exists bool)

UpdateTime returns the value of the "update_time" field in the mutation.

func (*PostMutation) Where

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

Where appends a list predicates to the PostMutation builder.

func (*PostMutation) WhereP

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

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

type PostQuery

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

PostQuery is the builder for querying Post entities.

func (*PostQuery) Aggregate

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

Aggregate returns a PostSelect configured with the given aggregations.

func (*PostQuery) All

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

All executes the query and returns a list of Posts.

func (*PostQuery) AllX

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

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

func (*PostQuery) Clone

func (_q *PostQuery) Clone() *PostQuery

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

func (*PostQuery) Count

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

Count returns the count of the given query.

func (*PostQuery) CountX

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

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

func (*PostQuery) Exist

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

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

func (*PostQuery) ExistX

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

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

func (*PostQuery) First

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

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

func (*PostQuery) FirstID

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

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

func (*PostQuery) FirstIDX

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

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

func (*PostQuery) FirstX

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

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

func (*PostQuery) GroupBy

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

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

Example:

var v []struct {
	CreateTime time.Time `json:"create_time,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Post.Query().
	GroupBy(post.FieldCreateTime).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*PostQuery) IDs

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

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

func (*PostQuery) IDsX

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

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

func (*PostQuery) Limit

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

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

func (*PostQuery) Offset

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

Offset to start from.

func (*PostQuery) Only

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

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

func (*PostQuery) OnlyID

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

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

func (*PostQuery) OnlyIDX

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

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

func (*PostQuery) OnlyX

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

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

func (*PostQuery) Order

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

Order specifies how the records should be ordered.

func (*PostQuery) QueryOwner

func (_q *PostQuery) QueryOwner() *UserQuery

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

func (*PostQuery) Select

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

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

Example:

var v []struct {
	CreateTime time.Time `json:"create_time,omitempty"`
}

client.Post.Query().
	Select(post.FieldCreateTime).
	Scan(ctx, &v)

func (*PostQuery) Unique

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

Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.

func (*PostQuery) Where

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

Where adds a new predicate for the PostQuery builder.

func (*PostQuery) WithOwner

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

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

type PostSelect

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

PostSelect is the builder for selecting fields of Post entities.

func (*PostSelect) Aggregate

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

Aggregate adds the given aggregation functions to the selector query.

func (*PostSelect) Bool

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

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

func (*PostSelect) BoolX

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

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

func (*PostSelect) Bools

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

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

func (*PostSelect) BoolsX

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

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

func (*PostSelect) Float64

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

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

func (*PostSelect) Float64X

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

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

func (*PostSelect) Float64s

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

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

func (*PostSelect) Float64sX

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

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

func (*PostSelect) Int

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

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

func (*PostSelect) IntX

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

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

func (*PostSelect) Ints

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

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

func (*PostSelect) IntsX

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

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

func (*PostSelect) Scan

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

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

func (*PostSelect) ScanX

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

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

func (*PostSelect) String

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

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

func (*PostSelect) StringX

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

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

func (*PostSelect) Strings

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

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

func (*PostSelect) StringsX

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

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

type PostUpdate

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

PostUpdate is the builder for updating Post entities.

func (*PostUpdate) ClearContent

func (_u *PostUpdate) ClearContent() *PostUpdate

ClearContent clears the value of the "content" field.

func (*PostUpdate) ClearOwner

func (_u *PostUpdate) ClearOwner() *PostUpdate

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

func (*PostUpdate) Exec

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

Exec executes the query.

func (*PostUpdate) ExecX

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

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

func (*PostUpdate) Mutation

func (_u *PostUpdate) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostUpdate) Save

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

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

func (*PostUpdate) SaveX

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

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

func (*PostUpdate) SetCategory

func (_u *PostUpdate) SetCategory(v post.Category) *PostUpdate

SetCategory sets the "category" field.

func (*PostUpdate) SetContent

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

SetContent sets the "content" field.

func (*PostUpdate) SetNillableCategory

func (_u *PostUpdate) SetNillableCategory(v *post.Category) *PostUpdate

SetNillableCategory sets the "category" field if the given value is not nil.

func (*PostUpdate) SetNillableContent

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

SetNillableContent sets the "content" field if the given value is not nil.

func (*PostUpdate) SetNillableTitle

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

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

func (*PostUpdate) SetOwner

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

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

func (*PostUpdate) SetOwnerID

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

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

func (*PostUpdate) SetTitle

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

SetTitle sets the "title" field.

func (*PostUpdate) SetUpdateTime

func (_u *PostUpdate) SetUpdateTime(v time.Time) *PostUpdate

SetUpdateTime sets the "update_time" field.

func (*PostUpdate) Where

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

Where appends a list predicates to the PostUpdate builder.

type PostUpdateOne

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

PostUpdateOne is the builder for updating a single Post entity.

func (*PostUpdateOne) ClearContent

func (_u *PostUpdateOne) ClearContent() *PostUpdateOne

ClearContent clears the value of the "content" field.

func (*PostUpdateOne) ClearOwner

func (_u *PostUpdateOne) ClearOwner() *PostUpdateOne

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

func (*PostUpdateOne) Exec

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

Exec executes the query on the entity.

func (*PostUpdateOne) ExecX

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

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

func (*PostUpdateOne) Mutation

func (_u *PostUpdateOne) Mutation() *PostMutation

Mutation returns the PostMutation object of the builder.

func (*PostUpdateOne) Save

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

Save executes the query and returns the updated Post entity.

func (*PostUpdateOne) SaveX

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

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

func (*PostUpdateOne) Select

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

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

func (*PostUpdateOne) SetCategory

func (_u *PostUpdateOne) SetCategory(v post.Category) *PostUpdateOne

SetCategory sets the "category" field.

func (*PostUpdateOne) SetContent

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

SetContent sets the "content" field.

func (*PostUpdateOne) SetNillableCategory

func (_u *PostUpdateOne) SetNillableCategory(v *post.Category) *PostUpdateOne

SetNillableCategory sets the "category" field if the given value is not nil.

func (*PostUpdateOne) SetNillableContent

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

SetNillableContent sets the "content" field if the given value is not nil.

func (*PostUpdateOne) SetNillableTitle

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

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

func (*PostUpdateOne) SetOwner

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

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

func (*PostUpdateOne) SetOwnerID

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

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

func (*PostUpdateOne) SetTitle

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

SetTitle sets the "title" field.

func (*PostUpdateOne) SetUpdateTime

func (_u *PostUpdateOne) SetUpdateTime(v time.Time) *PostUpdateOne

SetUpdateTime sets the "update_time" field.

func (*PostUpdateOne) Where

func (_u *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 {

	// AccessToken is the client for interacting with the AccessToken builders.
	AccessToken *AccessTokenClient
	// 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"`
	// CreateTime holds the value of the "create_time" field.
	CreateTime time.Time `json:"create_time,omitempty"`
	// UpdateTime holds the value of the "update_time" field.
	UpdateTime time.Time `json:"update_time,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"`
	// Password holds the value of the "password" field.
	Password string `json:"-"`
	// 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 table stores all user information.

func (*User) ComparePassword

func (u *User) ComparePassword(password string) error

compare user password with given password

func (*User) IntoEntity

func (u *User) IntoEntity() *UserEntity

IntoEntity converts ent User to UserEntity.

func (*User) QueryPosts

func (_m *User) QueryPosts() *PostQuery

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

func (*User) String

func (_m *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (_m *User) Unwrap() *User

Unwrap unwraps the User entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.

func (*User) Update

func (_m *User) Update() *UserUpdateOne

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

func (*User) Value

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

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

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

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a builder for creating a User entity.

func (*UserClient) CreateBulk

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

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

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*UserClient) DeleteOneID

func (c *UserClient) DeleteOneID(id int) *UserDeleteOne

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

func (*UserClient) Get

func (c *UserClient) Get(ctx context.Context, id int) (*User, error)

Get returns a User entity by its id.

func (*UserClient) GetX

func (c *UserClient) GetX(ctx context.Context, id int) *User

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

func (*UserClient) Hooks

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

Hooks returns the client hooks.

func (*UserClient) Intercept

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

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

func (*UserClient) Interceptors

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

Interceptors returns the client interceptors.

func (*UserClient) MapCreateBulk

func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*UserClient) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QueryPosts

func (c *UserClient) QueryPosts(_m *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(_m *User) *UserUpdateOne

UpdateOne returns an update builder for the given entity.

func (*UserClient) UpdateOneID

func (c *UserClient) UpdateOneID(id int) *UserUpdateOne

UpdateOneID returns an update builder for the given id.

func (*UserClient) Use

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

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

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddPostIDs

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

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

func (*UserCreate) AddPosts

func (_c *UserCreate) AddPosts(v ...*Post) *UserCreate

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

func (*UserCreate) Exec

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

Exec executes the query.

func (*UserCreate) ExecX

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

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

func (*UserCreate) Mutation

func (_c *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) Save

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

Save creates the User in the database.

func (*UserCreate) SaveX

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

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetCreateTime

func (_c *UserCreate) SetCreateTime(v time.Time) *UserCreate

SetCreateTime sets the "create_time" field.

func (*UserCreate) SetEmail

func (_c *UserCreate) SetEmail(v string) *UserCreate

SetEmail sets the "email" field.

func (*UserCreate) SetName

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

SetName sets the "name" field.

func (*UserCreate) SetNillableCreateTime

func (_c *UserCreate) SetNillableCreateTime(v *time.Time) *UserCreate

SetNillableCreateTime sets the "create_time" field if the given value is not nil.

func (*UserCreate) SetNillableUpdateTime

func (_c *UserCreate) SetNillableUpdateTime(v *time.Time) *UserCreate

SetNillableUpdateTime sets the "update_time" field if the given value is not nil.

func (*UserCreate) SetPassword

func (_c *UserCreate) SetPassword(v string) *UserCreate

SetPassword sets the "password" field.

func (*UserCreate) SetUpdateTime

func (_c *UserCreate) SetUpdateTime(v time.Time) *UserCreate

SetUpdateTime sets the "update_time" field.

type UserCreateBulk

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

UserCreateBulk is the builder for creating many User entities in bulk.

func (*UserCreateBulk) Exec

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

Exec executes the query.

func (*UserCreateBulk) ExecX

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

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

func (*UserCreateBulk) Save

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

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

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

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

func (*UserDelete) ExecX

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

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

func (*UserDelete) Where

func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

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

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

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

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

func (*UserDeleteOne) Where

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

Where appends a list predicates to the UserDelete builder.

type UserEdges

type UserEdges struct {
	// Posts holds the value of the posts edge.
	Posts []*Post `json:"posts,omitempty"`
	// contains filtered or unexported fields
}

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

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 UserEntity

type UserEntity struct {
	ID         int           `json:"id,omitempty"`
	Name       string        `json:"name,omitempty"`
	Email      string        `json:"email,omitempty"`
	CreateTime string        `json:"createTime,omitempty"`
	UpdateTime string        `json:"updateTime,omitempty"`
	Posts      []*PostEntity `json:"posts"`
}

UserEntity -.

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

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

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

func (*UserGroupBy) Bool

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

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

func (*UserGroupBy) BoolX

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

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

func (*UserGroupBy) Bools

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

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

func (*UserGroupBy) BoolsX

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

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

func (*UserGroupBy) Float64

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

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

func (*UserGroupBy) Float64X

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

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

func (*UserGroupBy) Float64s

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

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

func (*UserGroupBy) Float64sX

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

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

func (*UserGroupBy) Int

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

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

func (*UserGroupBy) IntX

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

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

func (*UserGroupBy) Ints

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

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

func (*UserGroupBy) IntsX

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

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

func (*UserGroupBy) Scan

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

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

func (*UserGroupBy) ScanX

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

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

func (*UserGroupBy) String

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

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

func (*UserGroupBy) StringX

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

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

func (*UserGroupBy) Strings

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

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

func (*UserGroupBy) StringsX

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

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

type UserMutation

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

UserMutation represents an operation that mutates the User nodes in the graph.

func (*UserMutation) AddField

func (m *UserMutation) AddField(name string, value ent.Value) error

AddField adds the value to the field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

func (*UserMutation) AddPostIDs

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

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

func (*UserMutation) 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) 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) 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) CreateTime

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

CreateTime returns the value of the "create_time" 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) OldCreateTime

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

OldCreateTime returns the old "create_time" 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) OldPassword

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

OldPassword returns the old "password" 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) OldUpdateTime

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

OldUpdateTime returns the old "update_time" 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) Password

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

Password returns the value of the "password" field 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) RemovePostIDs

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

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

func (*UserMutation) RemovedEdges

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

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

func (*UserMutation) RemovedIDs

func (m *UserMutation) RemovedIDs(name string) []ent.Value

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*UserMutation) RemovedPostsIDs

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

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

func (*UserMutation) ResetCreateTime

func (m *UserMutation) ResetCreateTime()

ResetCreateTime resets all changes to the "create_time" 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) ResetPassword

func (m *UserMutation) ResetPassword()

ResetPassword resets all changes to the "password" field.

func (*UserMutation) ResetPosts

func (m *UserMutation) ResetPosts()

ResetPosts resets all changes to the "posts" edge.

func (*UserMutation) ResetUpdateTime

func (m *UserMutation) ResetUpdateTime()

ResetUpdateTime resets all changes to the "update_time" field.

func (*UserMutation) SetCreateTime

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

SetCreateTime sets the "create_time" 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) SetPassword

func (m *UserMutation) SetPassword(s string)

SetPassword sets the "password" field.

func (*UserMutation) SetUpdateTime

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

SetUpdateTime sets the "update_time" 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) UpdateTime

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

UpdateTime returns the value of the "update_time" field in the mutation.

func (*UserMutation) Where

func (m *UserMutation) Where(ps ...predicate.User)

Where appends a list predicates to the UserMutation builder.

func (*UserMutation) WhereP

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

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

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) Aggregate

func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate returns a UserSelect configured with the given aggregations.

func (*UserQuery) All

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

All executes the query and returns a list of Users.

func (*UserQuery) AllX

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

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

func (*UserQuery) Clone

func (_q *UserQuery) Clone() *UserQuery

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

func (*UserQuery) Count

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

Count returns the count of the given query.

func (*UserQuery) CountX

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

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

func (*UserQuery) Exist

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

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

func (*UserQuery) ExistX

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

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

func (*UserQuery) First

func (_q *UserQuery) First(ctx context.Context) (*User, error)

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

func (*UserQuery) FirstID

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

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

func (*UserQuery) FirstIDX

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

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

func (*UserQuery) FirstX

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

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

func (*UserQuery) GroupBy

func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy

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

Example:

var v []struct {
	CreateTime time.Time `json:"create_time,omitempty"`
	Count int `json:"count,omitempty"`
}

client.User.Query().
	GroupBy(user.FieldCreateTime).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserQuery) IDs

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

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

func (*UserQuery) IDsX

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

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

func (*UserQuery) Limit

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

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

func (*UserQuery) Offset

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

Offset to start from.

func (*UserQuery) Only

func (_q *UserQuery) Only(ctx context.Context) (*User, error)

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

func (*UserQuery) OnlyID

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

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

func (*UserQuery) OnlyIDX

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

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

func (*UserQuery) OnlyX

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

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

func (*UserQuery) Order

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

Order specifies how the records should be ordered.

func (*UserQuery) QueryPosts

func (_q *UserQuery) QueryPosts() *PostQuery

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

func (*UserQuery) Select

func (_q *UserQuery) Select(fields ...string) *UserSelect

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

Example:

var v []struct {
	CreateTime time.Time `json:"create_time,omitempty"`
}

client.User.Query().
	Select(user.FieldCreateTime).
	Scan(ctx, &v)

func (*UserQuery) Unique

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

Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.

func (*UserQuery) Where

func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithPosts

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

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

type UserSelect

type UserSelect struct {
	*UserQuery
	// contains filtered or unexported fields
}

UserSelect is the builder for selecting fields of User entities.

func (*UserSelect) Aggregate

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

Aggregate adds the given aggregation functions to the selector query.

func (*UserSelect) Bool

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

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

func (*UserSelect) BoolX

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

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

func (*UserSelect) Bools

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

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

func (*UserSelect) BoolsX

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

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

func (*UserSelect) Float64

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

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

func (*UserSelect) Float64X

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

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

func (*UserSelect) Float64s

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

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

func (*UserSelect) Float64sX

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

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

func (*UserSelect) Int

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

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

func (*UserSelect) IntX

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

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

func (*UserSelect) Ints

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

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

func (*UserSelect) IntsX

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

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

func (*UserSelect) Scan

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

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

func (*UserSelect) ScanX

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

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

func (*UserSelect) String

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

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

func (*UserSelect) StringX

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

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

func (*UserSelect) Strings

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

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

func (*UserSelect) StringsX

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

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

type UserUpdate

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

UserUpdate is the builder for updating User entities.

func (*UserUpdate) AddPostIDs

func (_u *UserUpdate) AddPostIDs(ids ...int) *UserUpdate

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

func (*UserUpdate) AddPosts

func (_u *UserUpdate) AddPosts(v ...*Post) *UserUpdate

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

func (*UserUpdate) ClearPosts

func (_u *UserUpdate) ClearPosts() *UserUpdate

ClearPosts clears all "posts" edges to the Post entity.

func (*UserUpdate) Exec

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

Exec executes the query.

func (*UserUpdate) ExecX

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

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

func (*UserUpdate) Mutation

func (_u *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemovePostIDs

func (_u *UserUpdate) RemovePostIDs(ids ...int) *UserUpdate

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

func (*UserUpdate) RemovePosts

func (_u *UserUpdate) RemovePosts(v ...*Post) *UserUpdate

RemovePosts removes "posts" edges to Post entities.

func (*UserUpdate) Save

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

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

func (*UserUpdate) SaveX

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

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

func (*UserUpdate) SetEmail

func (_u *UserUpdate) SetEmail(v string) *UserUpdate

SetEmail sets the "email" field.

func (*UserUpdate) SetName

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

SetName sets the "name" field.

func (*UserUpdate) SetNillableEmail

func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate

SetNillableEmail sets the "email" field if the given value is not nil.

func (*UserUpdate) SetNillableName

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

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

func (*UserUpdate) SetNillablePassword

func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate

SetNillablePassword sets the "password" field if the given value is not nil.

func (*UserUpdate) SetPassword

func (_u *UserUpdate) SetPassword(v string) *UserUpdate

SetPassword sets the "password" field.

func (*UserUpdate) SetUpdateTime

func (_u *UserUpdate) SetUpdateTime(v time.Time) *UserUpdate

SetUpdateTime sets the "update_time" field.

func (*UserUpdate) Where

func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOne

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

UserUpdateOne is the builder for updating a single User entity.

func (*UserUpdateOne) AddPostIDs

func (_u *UserUpdateOne) AddPostIDs(ids ...int) *UserUpdateOne

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

func (*UserUpdateOne) AddPosts

func (_u *UserUpdateOne) AddPosts(v ...*Post) *UserUpdateOne

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

func (*UserUpdateOne) ClearPosts

func (_u *UserUpdateOne) ClearPosts() *UserUpdateOne

ClearPosts clears all "posts" edges to the Post entity.

func (*UserUpdateOne) Exec

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

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

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

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

func (*UserUpdateOne) Mutation

func (_u *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemovePostIDs

func (_u *UserUpdateOne) RemovePostIDs(ids ...int) *UserUpdateOne

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

func (*UserUpdateOne) RemovePosts

func (_u *UserUpdateOne) RemovePosts(v ...*Post) *UserUpdateOne

RemovePosts removes "posts" edges to Post entities.

func (*UserUpdateOne) Save

func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (_u *UserUpdateOne) SaveX(ctx context.Context) *User

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

func (*UserUpdateOne) Select

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

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

func (*UserUpdateOne) SetEmail

func (_u *UserUpdateOne) SetEmail(v string) *UserUpdateOne

SetEmail sets the "email" field.

func (*UserUpdateOne) SetName

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

SetName sets the "name" field.

func (*UserUpdateOne) SetNillableEmail

func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne

SetNillableEmail sets the "email" field if the given value is not nil.

func (*UserUpdateOne) SetNillableName

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

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

func (*UserUpdateOne) SetNillablePassword

func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne

SetNillablePassword sets the "password" field if the given value is not nil.

func (*UserUpdateOne) SetPassword

func (_u *UserUpdateOne) SetPassword(v string) *UserUpdateOne

SetPassword sets the "password" field.

func (*UserUpdateOne) SetUpdateTime

func (_u *UserUpdateOne) SetUpdateTime(v time.Time) *UserUpdateOne

SetUpdateTime sets the "update_time" field.

func (*UserUpdateOne) Where

func (_u *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