ent

package
v0.0.0-...-c6aefec Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: MIT Imports: 20 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.
	TypeMenu = "Menu"
	TypeRole = "Role"
	TypeUser = "User"
)

Variables

This section is empty.

Functions

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Client

type Client struct {

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

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(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 Committer 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 Menu struct {

	// ID of the ent.
	// 菜单id
	ID int64 `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	// 创建时间
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	// 更新时间
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// DeletedAt holds the value of the "deleted_at" field.
	// 删除时间
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
	// Permission holds the value of the "permission" field.
	// 菜单权限标识
	Permission string `json:"permission,omitempty"`
	// Path holds the value of the "path" field.
	// 前端url
	Path *string `json:"path,omitempty"`
	// Name holds the value of the "name" field.
	// 菜单名称
	Name string `json:"name,omitempty"`
	// Icon holds the value of the "icon" field.
	// 图标
	Icon *string `json:"icon,omitempty"`
	// Sort holds the value of the "sort" field.
	// 排序值
	Sort int `json:"sort,omitempty"`
	// Enable holds the value of the "enable" field.
	// 0-开启,1-关闭
	Enable string `json:"enable,omitempty"`
	// Type holds the value of the "type" field.
	// 菜单类型 0-菜单 1-按钮
	Type *string `json:"type,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the MenuQuery when eager-loading is set.
	Edges MenuEdges `json:"edges"`
	// contains filtered or unexported fields
}

Menu is the model entity for the Menu schema.

func (m *Menu) QueryChildren() *MenuQuery

QueryChildren queries the "children" edge of the Menu entity.

func (m *Menu) QueryOwner() *RoleQuery

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

func (m *Menu) QueryParent() *MenuQuery

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

func (m *Menu) String() string

String implements the fmt.Stringer.

func (m *Menu) Unwrap() *Menu

Unwrap unwraps the Menu 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 (m *Menu) Update() *MenuUpdateOne

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

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

MenuClient is a client for the Menu schema.

func NewMenuClient

func NewMenuClient(c config) *MenuClient

NewMenuClient returns a client for the Menu from the given config.

func (c *MenuClient) Create() *MenuCreate

Create returns a create builder for Menu.

func (c *MenuClient) CreateBulk(builders ...*MenuCreate) *MenuCreateBulk

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

func (c *MenuClient) Delete() *MenuDelete

Delete returns a delete builder for Menu.

func (c *MenuClient) DeleteOne(m *Menu) *MenuDeleteOne

DeleteOne returns a delete builder for the given entity.

func (c *MenuClient) DeleteOneID(id int64) *MenuDeleteOne

DeleteOneID returns a delete builder for the given id.

func (c *MenuClient) Get(ctx context.Context, id int64) (*Menu, error)

Get returns a Menu entity by its id.

func (c *MenuClient) GetX(ctx context.Context, id int64) *Menu

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

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

Hooks returns the client hooks.

func (c *MenuClient) Query() *MenuQuery

Query returns a query builder for Menu.

func (c *MenuClient) QueryChildren(m *Menu) *MenuQuery

QueryChildren queries the children edge of a Menu.

func (c *MenuClient) QueryOwner(m *Menu) *RoleQuery

QueryOwner queries the owner edge of a Menu.

func (c *MenuClient) QueryParent(m *Menu) *MenuQuery

QueryParent queries the parent edge of a Menu.

func (c *MenuClient) Update() *MenuUpdate

Update returns an update builder for Menu.

func (c *MenuClient) UpdateOne(m *Menu) *MenuUpdateOne

UpdateOne returns an update builder for the given entity.

func (c *MenuClient) UpdateOneID(id int64) *MenuUpdateOne

UpdateOneID returns an update builder for the given id.

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

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

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

MenuCreate is the builder for creating a Menu entity.

func (mc *MenuCreate) AddChildIDs(ids ...int64) *MenuCreate

AddChildIDs adds the "children" edge to the Menu entity by IDs.

func (mc *MenuCreate) AddChildren(m ...*Menu) *MenuCreate

AddChildren adds the "children" edges to the Menu entity.

func (mc *MenuCreate) Exec(ctx context.Context) error

Exec executes the query.

func (mc *MenuCreate) ExecX(ctx context.Context)

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

func (mc *MenuCreate) Mutation() *MenuMutation

Mutation returns the MenuMutation object of the builder.

func (mc *MenuCreate) Save(ctx context.Context) (*Menu, error)

Save creates the Menu in the database.

func (mc *MenuCreate) SaveX(ctx context.Context) *Menu

SaveX calls Save and panics if Save returns an error.

func (mc *MenuCreate) SetCreatedAt(t time.Time) *MenuCreate

SetCreatedAt sets the "created_at" field.

func (mc *MenuCreate) SetDeletedAt(t time.Time) *MenuCreate

SetDeletedAt sets the "deleted_at" field.

func (mc *MenuCreate) SetEnable(s string) *MenuCreate

SetEnable sets the "enable" field.

func (mc *MenuCreate) SetID(i int64) *MenuCreate

SetID sets the "id" field.

func (mc *MenuCreate) SetIcon(s string) *MenuCreate

SetIcon sets the "icon" field.

func (mc *MenuCreate) SetName(s string) *MenuCreate

SetName sets the "name" field.

func (mc *MenuCreate) SetNillableCreatedAt(t *time.Time) *MenuCreate

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

func (mc *MenuCreate) SetNillableDeletedAt(t *time.Time) *MenuCreate

SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.

func (mc *MenuCreate) SetNillableEnable(s *string) *MenuCreate

SetNillableEnable sets the "enable" field if the given value is not nil.

func (mc *MenuCreate) SetNillableIcon(s *string) *MenuCreate

SetNillableIcon sets the "icon" field if the given value is not nil.

func (mc *MenuCreate) SetNillableOwnerID(id *int64) *MenuCreate

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

func (mc *MenuCreate) SetNillableParentID(id *int64) *MenuCreate

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

func (mc *MenuCreate) SetNillablePath(s *string) *MenuCreate

SetNillablePath sets the "path" field if the given value is not nil.

func (mc *MenuCreate) SetNillableSort(i *int) *MenuCreate

SetNillableSort sets the "sort" field if the given value is not nil.

func (mc *MenuCreate) SetNillableType(s *string) *MenuCreate

SetNillableType sets the "type" field if the given value is not nil.

func (mc *MenuCreate) SetNillableUpdatedAt(t *time.Time) *MenuCreate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (mc *MenuCreate) SetOwner(r *Role) *MenuCreate

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

func (mc *MenuCreate) SetOwnerID(id int64) *MenuCreate

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

func (mc *MenuCreate) SetParent(m *Menu) *MenuCreate

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

func (mc *MenuCreate) SetParentID(id int64) *MenuCreate

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

func (mc *MenuCreate) SetPath(s string) *MenuCreate

SetPath sets the "path" field.

func (mc *MenuCreate) SetPermission(s string) *MenuCreate

SetPermission sets the "permission" field.

func (mc *MenuCreate) SetSort(i int) *MenuCreate

SetSort sets the "sort" field.

func (mc *MenuCreate) SetType(s string) *MenuCreate

SetType sets the "type" field.

func (mc *MenuCreate) SetUpdatedAt(t time.Time) *MenuCreate

SetUpdatedAt sets the "updated_at" field.

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

MenuCreateBulk is the builder for creating many Menu entities in bulk.

func (mcb *MenuCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (mcb *MenuCreateBulk) ExecX(ctx context.Context)

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

func (mcb *MenuCreateBulk) Save(ctx context.Context) ([]*Menu, error)

Save creates the Menu entities in the database.

func (mcb *MenuCreateBulk) SaveX(ctx context.Context) []*Menu

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

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

MenuDelete is the builder for deleting a Menu entity.

func (md *MenuDelete) Exec(ctx context.Context) (int, error)

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

func (md *MenuDelete) ExecX(ctx context.Context) int

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

func (md *MenuDelete) Where(ps ...predicate.Menu) *MenuDelete

Where appends a list predicates to the MenuDelete builder.

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

MenuDeleteOne is the builder for deleting a single Menu entity.

func (mdo *MenuDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (mdo *MenuDeleteOne) ExecX(ctx context.Context)

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

type MenuEdges struct {
	// Parent holds the value of the parent edge.
	Parent *Menu `json:"parent,omitempty"`
	// Children holds the value of the children edge.
	Children []*Menu `json:"children,omitempty"`
	// Owner holds the value of the owner edge.
	Owner *Role `json:"owner,omitempty"`
	// contains filtered or unexported fields
}

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

func (e MenuEdges) ChildrenOrErr() ([]*Menu, error)

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

func (e MenuEdges) OwnerOrErr() (*Role, error)

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

func (e MenuEdges) ParentOrErr() (*Menu, error)

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

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

MenuGroupBy is the group-by builder for Menu entities.

func (mgb *MenuGroupBy) Aggregate(fns ...AggregateFunc) *MenuGroupBy

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

func (mgb *MenuGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) BoolX(ctx context.Context) bool

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

func (mgb *MenuGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) BoolsX(ctx context.Context) []bool

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

func (mgb *MenuGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) Float64X(ctx context.Context) float64

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

func (mgb *MenuGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) Float64sX(ctx context.Context) []float64

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

func (mgb *MenuGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) IntX(ctx context.Context) int

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

func (mgb *MenuGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) IntsX(ctx context.Context) []int

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

func (mgb *MenuGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (mgb *MenuGroupBy) ScanX(ctx context.Context, v interface{})

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

func (mgb *MenuGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) StringX(ctx context.Context) string

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

func (mgb *MenuGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (mgb *MenuGroupBy) StringsX(ctx context.Context) []string

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

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

MenuMutation represents an operation that mutates the Menu nodes in the graph.

func (m *MenuMutation) AddChildIDs(ids ...int64)

AddChildIDs adds the "children" edge to the Menu entity by ids.

func (m *MenuMutation) 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 (m *MenuMutation) AddSort(i int)

AddSort adds i to the "sort" field.

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

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

func (m *MenuMutation) 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 (m *MenuMutation) AddedFields() []string

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

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

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

func (m *MenuMutation) AddedSort() (r int, exists bool)

AddedSort returns the value that was added to the "sort" field in this mutation.

func (m *MenuMutation) ChildrenCleared() bool

ChildrenCleared reports if the "children" edge to the Menu entity was cleared.

func (m *MenuMutation) ChildrenIDs() (ids []int64)

ChildrenIDs returns the "children" edge IDs in the mutation.

func (m *MenuMutation) ClearChildren()

ClearChildren clears the "children" edge to the Menu entity.

func (m *MenuMutation) ClearDeletedAt()

ClearDeletedAt clears the value of the "deleted_at" field.

func (m *MenuMutation) 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 (m *MenuMutation) 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 (m *MenuMutation) ClearIcon()

ClearIcon clears the value of the "icon" field.

func (m *MenuMutation) ClearOwner()

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

func (m *MenuMutation) ClearParent()

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

func (m *MenuMutation) ClearPath()

ClearPath clears the value of the "path" field.

func (m *MenuMutation) ClearType()

ClearType clears the value of the "type" field.

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

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

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

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

func (m MenuMutation) 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 (m *MenuMutation) CreatedAt() (r time.Time, exists bool)

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

func (m *MenuMutation) DeletedAt() (r time.Time, exists bool)

DeletedAt returns the value of the "deleted_at" field in the mutation.

func (m *MenuMutation) DeletedAtCleared() bool

DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.

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

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

func (m *MenuMutation) Enable() (r string, exists bool)

Enable returns the value of the "enable" field in the mutation.

func (m *MenuMutation) 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 (m *MenuMutation) FieldCleared(name string) bool

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

func (m *MenuMutation) 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 (m *MenuMutation) GetType() (r string, exists bool)

GetType returns the value of the "type" field in the mutation.

func (m *MenuMutation) ID() (id int64, 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 (m *MenuMutation) Icon() (r string, exists bool)

Icon returns the value of the "icon" field in the mutation.

func (m *MenuMutation) IconCleared() bool

IconCleared returns if the "icon" field was cleared in this mutation.

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

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

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

OldCreatedAt returns the old "created_at" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error)

OldDeletedAt returns the old "deleted_at" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldEnable(ctx context.Context) (v string, err error)

OldEnable returns the old "enable" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) 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 (m *MenuMutation) OldIcon(ctx context.Context) (v *string, err error)

OldIcon returns the old "icon" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldPath(ctx context.Context) (v *string, err error)

OldPath returns the old "path" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldPermission(ctx context.Context) (v string, err error)

OldPermission returns the old "permission" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldSort(ctx context.Context) (v int, err error)

OldSort returns the old "sort" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldType(ctx context.Context) (v *string, err error)

OldType returns the old "type" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)

OldUpdatedAt returns the old "updated_at" field's value of the Menu entity. If the Menu 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 (m *MenuMutation) Op() Op

Op returns the operation name.

func (m *MenuMutation) OwnerCleared() bool

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

func (m *MenuMutation) OwnerID() (id int64, exists bool)

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

func (m *MenuMutation) OwnerIDs() (ids []int64)

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 (m *MenuMutation) ParentCleared() bool

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

func (m *MenuMutation) ParentID() (id int64, exists bool)

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

func (m *MenuMutation) ParentIDs() (ids []int64)

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

func (m *MenuMutation) Path() (r string, exists bool)

Path returns the value of the "path" field in the mutation.

func (m *MenuMutation) PathCleared() bool

PathCleared returns if the "path" field was cleared in this mutation.

func (m *MenuMutation) Permission() (r string, exists bool)

Permission returns the value of the "permission" field in the mutation.

func (m *MenuMutation) RemoveChildIDs(ids ...int64)

RemoveChildIDs removes the "children" edge to the Menu entity by IDs.

func (m *MenuMutation) RemovedChildrenIDs() (ids []int64)

RemovedChildren returns the removed IDs of the "children" edge to the Menu entity.

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

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

func (m *MenuMutation) 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 (m *MenuMutation) ResetChildren()

ResetChildren resets all changes to the "children" edge.

func (m *MenuMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (m *MenuMutation) ResetDeletedAt()

ResetDeletedAt resets all changes to the "deleted_at" field.

func (m *MenuMutation) 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 (m *MenuMutation) ResetEnable()

ResetEnable resets all changes to the "enable" field.

func (m *MenuMutation) 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 (m *MenuMutation) ResetIcon()

ResetIcon resets all changes to the "icon" field.

func (m *MenuMutation) ResetName()

ResetName resets all changes to the "name" field.

func (m *MenuMutation) ResetOwner()

ResetOwner resets all changes to the "owner" edge.

func (m *MenuMutation) ResetParent()

ResetParent resets all changes to the "parent" edge.

func (m *MenuMutation) ResetPath()

ResetPath resets all changes to the "path" field.

func (m *MenuMutation) ResetPermission()

ResetPermission resets all changes to the "permission" field.

func (m *MenuMutation) ResetSort()

ResetSort resets all changes to the "sort" field.

func (m *MenuMutation) ResetType()

ResetType resets all changes to the "type" field.

func (m *MenuMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

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

SetCreatedAt sets the "created_at" field.

func (m *MenuMutation) SetDeletedAt(t time.Time)

SetDeletedAt sets the "deleted_at" field.

func (m *MenuMutation) SetEnable(s string)

SetEnable sets the "enable" field.

func (m *MenuMutation) 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 (m *MenuMutation) SetID(id int64)

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

func (m *MenuMutation) SetIcon(s string)

SetIcon sets the "icon" field.

func (m *MenuMutation) SetName(s string)

SetName sets the "name" field.

func (m *MenuMutation) SetOwnerID(id int64)

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

func (m *MenuMutation) SetParentID(id int64)

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

func (m *MenuMutation) SetPath(s string)

SetPath sets the "path" field.

func (m *MenuMutation) SetPermission(s string)

SetPermission sets the "permission" field.

func (m *MenuMutation) SetSort(i int)

SetSort sets the "sort" field.

func (m *MenuMutation) SetType(s string)

SetType sets the "type" field.

func (m *MenuMutation) SetUpdatedAt(t time.Time)

SetUpdatedAt sets the "updated_at" field.

func (m *MenuMutation) Sort() (r int, exists bool)

Sort returns the value of the "sort" field in the mutation.

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

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

func (m *MenuMutation) Type() string

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

func (m *MenuMutation) TypeCleared() bool

TypeCleared returns if the "type" field was cleared in this mutation.

func (m *MenuMutation) UpdatedAt() (r time.Time, exists bool)

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (m *MenuMutation) Where(ps ...predicate.Menu)

Where appends a list predicates to the MenuMutation builder.

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

MenuQuery is the builder for querying Menu entities.

func (mq *MenuQuery) All(ctx context.Context) ([]*Menu, error)

All executes the query and returns a list of Menus.

func (mq *MenuQuery) AllX(ctx context.Context) []*Menu

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

func (mq *MenuQuery) Clone() *MenuQuery

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

func (mq *MenuQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (mq *MenuQuery) CountX(ctx context.Context) int

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

func (mq *MenuQuery) Exist(ctx context.Context) (bool, error)

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

func (mq *MenuQuery) ExistX(ctx context.Context) bool

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

func (mq *MenuQuery) First(ctx context.Context) (*Menu, error)

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

func (mq *MenuQuery) FirstID(ctx context.Context) (id int64, err error)

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

func (mq *MenuQuery) FirstIDX(ctx context.Context) int64

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

func (mq *MenuQuery) FirstX(ctx context.Context) *Menu

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

func (mq *MenuQuery) GroupBy(field string, fields ...string) *MenuGroupBy

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

client.Menu.Query().
	GroupBy(menu.FieldCreatedAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)
func (mq *MenuQuery) IDs(ctx context.Context) ([]int64, error)

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

func (mq *MenuQuery) IDsX(ctx context.Context) []int64

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

func (mq *MenuQuery) Limit(limit int) *MenuQuery

Limit adds a limit step to the query.

func (mq *MenuQuery) Offset(offset int) *MenuQuery

Offset adds an offset step to the query.

func (mq *MenuQuery) Only(ctx context.Context) (*Menu, error)

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

func (mq *MenuQuery) OnlyID(ctx context.Context) (id int64, err error)

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

func (mq *MenuQuery) OnlyIDX(ctx context.Context) int64

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

func (mq *MenuQuery) OnlyX(ctx context.Context) *Menu

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

func (mq *MenuQuery) Order(o ...OrderFunc) *MenuQuery

Order adds an order step to the query.

func (mq *MenuQuery) QueryChildren() *MenuQuery

QueryChildren chains the current query on the "children" edge.

func (mq *MenuQuery) QueryOwner() *RoleQuery

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

func (mq *MenuQuery) QueryParent() *MenuQuery

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

func (mq *MenuQuery) Select(fields ...string) *MenuSelect

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

client.Menu.Query().
	Select(menu.FieldCreatedAt).
	Scan(ctx, &v)
func (mq *MenuQuery) Unique(unique bool) *MenuQuery

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 (mq *MenuQuery) Where(ps ...predicate.Menu) *MenuQuery

Where adds a new predicate for the MenuQuery builder.

func (mq *MenuQuery) WithChildren(opts ...func(*MenuQuery)) *MenuQuery

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

func (mq *MenuQuery) WithOwner(opts ...func(*RoleQuery)) *MenuQuery

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

func (mq *MenuQuery) WithParent(opts ...func(*MenuQuery)) *MenuQuery

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

type MenuSelect struct {
	*MenuQuery
	// contains filtered or unexported fields
}

MenuSelect is the builder for selecting fields of Menu entities.

func (ms *MenuSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (ms *MenuSelect) BoolX(ctx context.Context) bool

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

func (ms *MenuSelect) Bools(ctx context.Context) ([]bool, error)

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

func (ms *MenuSelect) BoolsX(ctx context.Context) []bool

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

func (ms *MenuSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (ms *MenuSelect) Float64X(ctx context.Context) float64

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

func (ms *MenuSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (ms *MenuSelect) Float64sX(ctx context.Context) []float64

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

func (ms *MenuSelect) Int(ctx context.Context) (_ int, err error)

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

func (ms *MenuSelect) IntX(ctx context.Context) int

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

func (ms *MenuSelect) Ints(ctx context.Context) ([]int, error)

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

func (ms *MenuSelect) IntsX(ctx context.Context) []int

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

func (ms *MenuSelect) Scan(ctx context.Context, v interface{}) error

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

func (ms *MenuSelect) ScanX(ctx context.Context, v interface{})

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

func (ms *MenuSelect) String(ctx context.Context) (_ string, err error)

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

func (ms *MenuSelect) StringX(ctx context.Context) string

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

func (ms *MenuSelect) Strings(ctx context.Context) ([]string, error)

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

func (ms *MenuSelect) StringsX(ctx context.Context) []string

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

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

MenuUpdate is the builder for updating Menu entities.

func (mu *MenuUpdate) AddChildIDs(ids ...int64) *MenuUpdate

AddChildIDs adds the "children" edge to the Menu entity by IDs.

func (mu *MenuUpdate) AddChildren(m ...*Menu) *MenuUpdate

AddChildren adds the "children" edges to the Menu entity.

func (mu *MenuUpdate) AddSort(i int) *MenuUpdate

AddSort adds i to the "sort" field.

func (mu *MenuUpdate) ClearChildren() *MenuUpdate

ClearChildren clears all "children" edges to the Menu entity.

func (mu *MenuUpdate) ClearDeletedAt() *MenuUpdate

ClearDeletedAt clears the value of the "deleted_at" field.

func (mu *MenuUpdate) ClearIcon() *MenuUpdate

ClearIcon clears the value of the "icon" field.

func (mu *MenuUpdate) ClearOwner() *MenuUpdate

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

func (mu *MenuUpdate) ClearParent() *MenuUpdate

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

func (mu *MenuUpdate) ClearPath() *MenuUpdate

ClearPath clears the value of the "path" field.

func (mu *MenuUpdate) ClearType() *MenuUpdate

ClearType clears the value of the "type" field.

func (mu *MenuUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (mu *MenuUpdate) ExecX(ctx context.Context)

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

func (mu *MenuUpdate) Mutation() *MenuMutation

Mutation returns the MenuMutation object of the builder.

func (mu *MenuUpdate) RemoveChildIDs(ids ...int64) *MenuUpdate

RemoveChildIDs removes the "children" edge to Menu entities by IDs.

func (mu *MenuUpdate) RemoveChildren(m ...*Menu) *MenuUpdate

RemoveChildren removes "children" edges to Menu entities.

func (mu *MenuUpdate) Save(ctx context.Context) (int, error)

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

func (mu *MenuUpdate) SaveX(ctx context.Context) int

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

func (mu *MenuUpdate) SetDeletedAt(t time.Time) *MenuUpdate

SetDeletedAt sets the "deleted_at" field.

func (mu *MenuUpdate) SetEnable(s string) *MenuUpdate

SetEnable sets the "enable" field.

func (mu *MenuUpdate) SetIcon(s string) *MenuUpdate

SetIcon sets the "icon" field.

func (mu *MenuUpdate) SetName(s string) *MenuUpdate

SetName sets the "name" field.

func (mu *MenuUpdate) SetNillableEnable(s *string) *MenuUpdate

SetNillableEnable sets the "enable" field if the given value is not nil.

func (mu *MenuUpdate) SetNillableIcon(s *string) *MenuUpdate

SetNillableIcon sets the "icon" field if the given value is not nil.

func (mu *MenuUpdate) SetNillableOwnerID(id *int64) *MenuUpdate

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

func (mu *MenuUpdate) SetNillableParentID(id *int64) *MenuUpdate

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

func (mu *MenuUpdate) SetNillablePath(s *string) *MenuUpdate

SetNillablePath sets the "path" field if the given value is not nil.

func (mu *MenuUpdate) SetNillableSort(i *int) *MenuUpdate

SetNillableSort sets the "sort" field if the given value is not nil.

func (mu *MenuUpdate) SetNillableType(s *string) *MenuUpdate

SetNillableType sets the "type" field if the given value is not nil.

func (mu *MenuUpdate) SetOwner(r *Role) *MenuUpdate

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

func (mu *MenuUpdate) SetOwnerID(id int64) *MenuUpdate

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

func (mu *MenuUpdate) SetParent(m *Menu) *MenuUpdate

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

func (mu *MenuUpdate) SetParentID(id int64) *MenuUpdate

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

func (mu *MenuUpdate) SetPath(s string) *MenuUpdate

SetPath sets the "path" field.

func (mu *MenuUpdate) SetPermission(s string) *MenuUpdate

SetPermission sets the "permission" field.

func (mu *MenuUpdate) SetSort(i int) *MenuUpdate

SetSort sets the "sort" field.

func (mu *MenuUpdate) SetType(s string) *MenuUpdate

SetType sets the "type" field.

func (mu *MenuUpdate) SetUpdatedAt(t time.Time) *MenuUpdate

SetUpdatedAt sets the "updated_at" field.

func (mu *MenuUpdate) Where(ps ...predicate.Menu) *MenuUpdate

Where appends a list predicates to the MenuUpdate builder.

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

MenuUpdateOne is the builder for updating a single Menu entity.

func (muo *MenuUpdateOne) AddChildIDs(ids ...int64) *MenuUpdateOne

AddChildIDs adds the "children" edge to the Menu entity by IDs.

func (muo *MenuUpdateOne) AddChildren(m ...*Menu) *MenuUpdateOne

AddChildren adds the "children" edges to the Menu entity.

func (muo *MenuUpdateOne) AddSort(i int) *MenuUpdateOne

AddSort adds i to the "sort" field.

func (muo *MenuUpdateOne) ClearChildren() *MenuUpdateOne

ClearChildren clears all "children" edges to the Menu entity.

func (muo *MenuUpdateOne) ClearDeletedAt() *MenuUpdateOne

ClearDeletedAt clears the value of the "deleted_at" field.

func (muo *MenuUpdateOne) ClearIcon() *MenuUpdateOne

ClearIcon clears the value of the "icon" field.

func (muo *MenuUpdateOne) ClearOwner() *MenuUpdateOne

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

func (muo *MenuUpdateOne) ClearParent() *MenuUpdateOne

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

func (muo *MenuUpdateOne) ClearPath() *MenuUpdateOne

ClearPath clears the value of the "path" field.

func (muo *MenuUpdateOne) ClearType() *MenuUpdateOne

ClearType clears the value of the "type" field.

func (muo *MenuUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (muo *MenuUpdateOne) ExecX(ctx context.Context)

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

func (muo *MenuUpdateOne) Mutation() *MenuMutation

Mutation returns the MenuMutation object of the builder.

func (muo *MenuUpdateOne) RemoveChildIDs(ids ...int64) *MenuUpdateOne

RemoveChildIDs removes the "children" edge to Menu entities by IDs.

func (muo *MenuUpdateOne) RemoveChildren(m ...*Menu) *MenuUpdateOne

RemoveChildren removes "children" edges to Menu entities.

func (muo *MenuUpdateOne) Save(ctx context.Context) (*Menu, error)

Save executes the query and returns the updated Menu entity.

func (muo *MenuUpdateOne) SaveX(ctx context.Context) *Menu

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

func (muo *MenuUpdateOne) Select(field string, fields ...string) *MenuUpdateOne

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

func (muo *MenuUpdateOne) SetDeletedAt(t time.Time) *MenuUpdateOne

SetDeletedAt sets the "deleted_at" field.

func (muo *MenuUpdateOne) SetEnable(s string) *MenuUpdateOne

SetEnable sets the "enable" field.

func (muo *MenuUpdateOne) SetIcon(s string) *MenuUpdateOne

SetIcon sets the "icon" field.

func (muo *MenuUpdateOne) SetName(s string) *MenuUpdateOne

SetName sets the "name" field.

func (muo *MenuUpdateOne) SetNillableEnable(s *string) *MenuUpdateOne

SetNillableEnable sets the "enable" field if the given value is not nil.

func (muo *MenuUpdateOne) SetNillableIcon(s *string) *MenuUpdateOne

SetNillableIcon sets the "icon" field if the given value is not nil.

func (muo *MenuUpdateOne) SetNillableOwnerID(id *int64) *MenuUpdateOne

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

func (muo *MenuUpdateOne) SetNillableParentID(id *int64) *MenuUpdateOne

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

func (muo *MenuUpdateOne) SetNillablePath(s *string) *MenuUpdateOne

SetNillablePath sets the "path" field if the given value is not nil.

func (muo *MenuUpdateOne) SetNillableSort(i *int) *MenuUpdateOne

SetNillableSort sets the "sort" field if the given value is not nil.

func (muo *MenuUpdateOne) SetNillableType(s *string) *MenuUpdateOne

SetNillableType sets the "type" field if the given value is not nil.

func (muo *MenuUpdateOne) SetOwner(r *Role) *MenuUpdateOne

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

func (muo *MenuUpdateOne) SetOwnerID(id int64) *MenuUpdateOne

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

func (muo *MenuUpdateOne) SetParent(m *Menu) *MenuUpdateOne

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

func (muo *MenuUpdateOne) SetParentID(id int64) *MenuUpdateOne

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

func (muo *MenuUpdateOne) SetPath(s string) *MenuUpdateOne

SetPath sets the "path" field.

func (muo *MenuUpdateOne) SetPermission(s string) *MenuUpdateOne

SetPermission sets the "permission" field.

func (muo *MenuUpdateOne) SetSort(i int) *MenuUpdateOne

SetSort sets the "sort" field.

func (muo *MenuUpdateOne) SetType(s string) *MenuUpdateOne

SetType sets the "type" field.

func (muo *MenuUpdateOne) SetUpdatedAt(t time.Time) *MenuUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Menus []*Menu

Menus is a parsable slice of Menu.

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(...interface{})) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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 Role

type Role struct {

	// ID of the ent.
	// 角色id
	ID int64 `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	// 创建时间
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	// 更新时间
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// DeletedAt holds the value of the "deleted_at" field.
	// 删除时间
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
	// Key holds the value of the "key" field.
	// 角色关键字
	Key string `json:"key,omitempty"`
	// Name holds the value of the "name" field.
	// 角色名称
	Name string `json:"name,omitempty"`
	// Comment holds the value of the "comment" field.
	// 备注
	Comment *string `json:"comment,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the RoleQuery when eager-loading is set.
	Edges RoleEdges `json:"edges"`
	// contains filtered or unexported fields
}

Role is the model entity for the Role schema.

func (*Role) QueryMenu

func (r *Role) QueryMenu() *MenuQuery

QueryMenu queries the "menu" edge of the Role entity.

func (*Role) QueryUser

func (r *Role) QueryUser() *UserQuery

QueryUser queries the "user" edge of the Role entity.

func (*Role) String

func (r *Role) String() string

String implements the fmt.Stringer.

func (*Role) Unwrap

func (r *Role) Unwrap() *Role

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

func (r *Role) Update() *RoleUpdateOne

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

type RoleClient

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

RoleClient is a client for the Role schema.

func NewRoleClient

func NewRoleClient(c config) *RoleClient

NewRoleClient returns a client for the Role from the given config.

func (*RoleClient) Create

func (c *RoleClient) Create() *RoleCreate

Create returns a create builder for Role.

func (*RoleClient) CreateBulk

func (c *RoleClient) CreateBulk(builders ...*RoleCreate) *RoleCreateBulk

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

func (*RoleClient) Delete

func (c *RoleClient) Delete() *RoleDelete

Delete returns a delete builder for Role.

func (*RoleClient) DeleteOne

func (c *RoleClient) DeleteOne(r *Role) *RoleDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*RoleClient) DeleteOneID

func (c *RoleClient) DeleteOneID(id int64) *RoleDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*RoleClient) Get

func (c *RoleClient) Get(ctx context.Context, id int64) (*Role, error)

Get returns a Role entity by its id.

func (*RoleClient) GetX

func (c *RoleClient) GetX(ctx context.Context, id int64) *Role

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

func (*RoleClient) Hooks

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

Hooks returns the client hooks.

func (*RoleClient) Query

func (c *RoleClient) Query() *RoleQuery

Query returns a query builder for Role.

func (*RoleClient) QueryMenu

func (c *RoleClient) QueryMenu(r *Role) *MenuQuery

QueryMenu queries the menu edge of a Role.

func (*RoleClient) QueryUser

func (c *RoleClient) QueryUser(r *Role) *UserQuery

QueryUser queries the user edge of a Role.

func (*RoleClient) Update

func (c *RoleClient) Update() *RoleUpdate

Update returns an update builder for Role.

func (*RoleClient) UpdateOne

func (c *RoleClient) UpdateOne(r *Role) *RoleUpdateOne

UpdateOne returns an update builder for the given entity.

func (*RoleClient) UpdateOneID

func (c *RoleClient) UpdateOneID(id int64) *RoleUpdateOne

UpdateOneID returns an update builder for the given id.

func (*RoleClient) Use

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

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

type RoleCreate

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

RoleCreate is the builder for creating a Role entity.

func (*RoleCreate) AddMenu

func (rc *RoleCreate) AddMenu(m ...*Menu) *RoleCreate

AddMenu adds the "menu" edges to the Menu entity.

func (*RoleCreate) AddMenuIDs

func (rc *RoleCreate) AddMenuIDs(ids ...int64) *RoleCreate

AddMenuIDs adds the "menu" edge to the Menu entity by IDs.

func (*RoleCreate) AddUser

func (rc *RoleCreate) AddUser(u ...*User) *RoleCreate

AddUser adds the "user" edges to the User entity.

func (*RoleCreate) AddUserIDs

func (rc *RoleCreate) AddUserIDs(ids ...int) *RoleCreate

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

func (*RoleCreate) Exec

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

Exec executes the query.

func (*RoleCreate) ExecX

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

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

func (*RoleCreate) Mutation

func (rc *RoleCreate) Mutation() *RoleMutation

Mutation returns the RoleMutation object of the builder.

func (*RoleCreate) Save

func (rc *RoleCreate) Save(ctx context.Context) (*Role, error)

Save creates the Role in the database.

func (*RoleCreate) SaveX

func (rc *RoleCreate) SaveX(ctx context.Context) *Role

SaveX calls Save and panics if Save returns an error.

func (*RoleCreate) SetComment

func (rc *RoleCreate) SetComment(s string) *RoleCreate

SetComment sets the "comment" field.

func (*RoleCreate) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*RoleCreate) SetDeletedAt

func (rc *RoleCreate) SetDeletedAt(t time.Time) *RoleCreate

SetDeletedAt sets the "deleted_at" field.

func (*RoleCreate) SetID

func (rc *RoleCreate) SetID(i int64) *RoleCreate

SetID sets the "id" field.

func (*RoleCreate) SetKey

func (rc *RoleCreate) SetKey(s string) *RoleCreate

SetKey sets the "key" field.

func (*RoleCreate) SetName

func (rc *RoleCreate) SetName(s string) *RoleCreate

SetName sets the "name" field.

func (*RoleCreate) SetNillableComment

func (rc *RoleCreate) SetNillableComment(s *string) *RoleCreate

SetNillableComment sets the "comment" field if the given value is not nil.

func (*RoleCreate) SetNillableCreatedAt

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

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

func (*RoleCreate) SetNillableDeletedAt

func (rc *RoleCreate) SetNillableDeletedAt(t *time.Time) *RoleCreate

SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.

func (*RoleCreate) SetNillableUpdatedAt

func (rc *RoleCreate) SetNillableUpdatedAt(t *time.Time) *RoleCreate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*RoleCreate) SetUpdatedAt

func (rc *RoleCreate) SetUpdatedAt(t time.Time) *RoleCreate

SetUpdatedAt sets the "updated_at" field.

type RoleCreateBulk

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

RoleCreateBulk is the builder for creating many Role entities in bulk.

func (*RoleCreateBulk) Exec

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

Exec executes the query.

func (*RoleCreateBulk) ExecX

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

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

func (*RoleCreateBulk) Save

func (rcb *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error)

Save creates the Role entities in the database.

func (*RoleCreateBulk) SaveX

func (rcb *RoleCreateBulk) SaveX(ctx context.Context) []*Role

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

type RoleDelete

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

RoleDelete is the builder for deleting a Role entity.

func (*RoleDelete) Exec

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

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

func (*RoleDelete) ExecX

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

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

func (*RoleDelete) Where

func (rd *RoleDelete) Where(ps ...predicate.Role) *RoleDelete

Where appends a list predicates to the RoleDelete builder.

type RoleDeleteOne

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

RoleDeleteOne is the builder for deleting a single Role entity.

func (*RoleDeleteOne) Exec

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

Exec executes the deletion query.

func (*RoleDeleteOne) ExecX

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

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

type RoleEdges

type RoleEdges struct {
	// User holds the value of the user edge.
	User []*User `json:"user,omitempty"`
	// Menu holds the value of the menu edge.
	Menu []*Menu `json:"menu,omitempty"`
	// contains filtered or unexported fields
}

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

func (RoleEdges) MenuOrErr

func (e RoleEdges) MenuOrErr() ([]*Menu, error)

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

func (RoleEdges) UserOrErr

func (e RoleEdges) UserOrErr() ([]*User, error)

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

type RoleGroupBy

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

RoleGroupBy is the group-by builder for Role entities.

func (*RoleGroupBy) Aggregate

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

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

func (*RoleGroupBy) Bool

func (rgb *RoleGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) BoolX

func (rgb *RoleGroupBy) BoolX(ctx context.Context) bool

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

func (*RoleGroupBy) Bools

func (rgb *RoleGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) BoolsX

func (rgb *RoleGroupBy) BoolsX(ctx context.Context) []bool

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

func (*RoleGroupBy) Float64

func (rgb *RoleGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) Float64X

func (rgb *RoleGroupBy) Float64X(ctx context.Context) float64

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

func (*RoleGroupBy) Float64s

func (rgb *RoleGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) Float64sX

func (rgb *RoleGroupBy) Float64sX(ctx context.Context) []float64

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

func (*RoleGroupBy) Int

func (rgb *RoleGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) IntX

func (rgb *RoleGroupBy) IntX(ctx context.Context) int

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

func (*RoleGroupBy) Ints

func (rgb *RoleGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) IntsX

func (rgb *RoleGroupBy) IntsX(ctx context.Context) []int

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

func (*RoleGroupBy) Scan

func (rgb *RoleGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (*RoleGroupBy) ScanX

func (rgb *RoleGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*RoleGroupBy) String

func (rgb *RoleGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) StringX

func (rgb *RoleGroupBy) StringX(ctx context.Context) string

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

func (*RoleGroupBy) Strings

func (rgb *RoleGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (*RoleGroupBy) StringsX

func (rgb *RoleGroupBy) StringsX(ctx context.Context) []string

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

type RoleMutation

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

RoleMutation represents an operation that mutates the Role nodes in the graph.

func (*RoleMutation) AddField

func (m *RoleMutation) 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 (*RoleMutation) AddMenuIDs

func (m *RoleMutation) AddMenuIDs(ids ...int64)

AddMenuIDs adds the "menu" edge to the Menu entity by ids.

func (*RoleMutation) AddUserIDs

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

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

func (*RoleMutation) AddedEdges

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

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

func (*RoleMutation) AddedField

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

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

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

func (*RoleMutation) AddedIDs

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

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

func (*RoleMutation) ClearComment

func (m *RoleMutation) ClearComment()

ClearComment clears the value of the "comment" field.

func (*RoleMutation) ClearDeletedAt

func (m *RoleMutation) ClearDeletedAt()

ClearDeletedAt clears the value of the "deleted_at" field.

func (*RoleMutation) ClearEdge

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

func (m *RoleMutation) 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 (*RoleMutation) ClearMenu

func (m *RoleMutation) ClearMenu()

ClearMenu clears the "menu" edge to the Menu entity.

func (*RoleMutation) ClearUser

func (m *RoleMutation) ClearUser()

ClearUser clears the "user" edge to the User entity.

func (*RoleMutation) ClearedEdges

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

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

func (*RoleMutation) ClearedFields

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

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

func (RoleMutation) Client

func (m RoleMutation) 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 (*RoleMutation) Comment

func (m *RoleMutation) Comment() (r string, exists bool)

Comment returns the value of the "comment" field in the mutation.

func (*RoleMutation) CommentCleared

func (m *RoleMutation) CommentCleared() bool

CommentCleared returns if the "comment" field was cleared in this mutation.

func (*RoleMutation) CreatedAt

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

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

func (*RoleMutation) DeletedAt

func (m *RoleMutation) DeletedAt() (r time.Time, exists bool)

DeletedAt returns the value of the "deleted_at" field in the mutation.

func (*RoleMutation) DeletedAtCleared

func (m *RoleMutation) DeletedAtCleared() bool

DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.

func (*RoleMutation) EdgeCleared

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

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

func (*RoleMutation) Field

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

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

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

func (*RoleMutation) Fields

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

func (m *RoleMutation) ID() (id int64, 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 (*RoleMutation) Key

func (m *RoleMutation) Key() (r string, exists bool)

Key returns the value of the "key" field in the mutation.

func (*RoleMutation) MenuCleared

func (m *RoleMutation) MenuCleared() bool

MenuCleared reports if the "menu" edge to the Menu entity was cleared.

func (*RoleMutation) MenuIDs

func (m *RoleMutation) MenuIDs() (ids []int64)

MenuIDs returns the "menu" edge IDs in the mutation.

func (*RoleMutation) Name

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

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

func (*RoleMutation) OldComment

func (m *RoleMutation) OldComment(ctx context.Context) (v *string, err error)

OldComment returns the old "comment" field's value of the Role entity. If the Role 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 (*RoleMutation) OldCreatedAt

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

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

func (m *RoleMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error)

OldDeletedAt returns the old "deleted_at" field's value of the Role entity. If the Role 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 (*RoleMutation) OldField

func (m *RoleMutation) 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 (*RoleMutation) OldKey

func (m *RoleMutation) OldKey(ctx context.Context) (v string, err error)

OldKey returns the old "key" field's value of the Role entity. If the Role 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 (*RoleMutation) OldName

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

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

func (m *RoleMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)

OldUpdatedAt returns the old "updated_at" field's value of the Role entity. If the Role 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 (*RoleMutation) Op

func (m *RoleMutation) Op() Op

Op returns the operation name.

func (*RoleMutation) RemoveMenuIDs

func (m *RoleMutation) RemoveMenuIDs(ids ...int64)

RemoveMenuIDs removes the "menu" edge to the Menu entity by IDs.

func (*RoleMutation) RemoveUserIDs

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

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

func (*RoleMutation) RemovedEdges

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

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

func (*RoleMutation) RemovedIDs

func (m *RoleMutation) 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 (*RoleMutation) RemovedMenuIDs

func (m *RoleMutation) RemovedMenuIDs() (ids []int64)

RemovedMenu returns the removed IDs of the "menu" edge to the Menu entity.

func (*RoleMutation) RemovedUserIDs

func (m *RoleMutation) RemovedUserIDs() (ids []int)

RemovedUser returns the removed IDs of the "user" edge to the User entity.

func (*RoleMutation) ResetComment

func (m *RoleMutation) ResetComment()

ResetComment resets all changes to the "comment" field.

func (*RoleMutation) ResetCreatedAt

func (m *RoleMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*RoleMutation) ResetDeletedAt

func (m *RoleMutation) ResetDeletedAt()

ResetDeletedAt resets all changes to the "deleted_at" field.

func (*RoleMutation) ResetEdge

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

func (m *RoleMutation) 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 (*RoleMutation) ResetKey

func (m *RoleMutation) ResetKey()

ResetKey resets all changes to the "key" field.

func (*RoleMutation) ResetMenu

func (m *RoleMutation) ResetMenu()

ResetMenu resets all changes to the "menu" edge.

func (*RoleMutation) ResetName

func (m *RoleMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*RoleMutation) ResetUpdatedAt

func (m *RoleMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*RoleMutation) ResetUser

func (m *RoleMutation) ResetUser()

ResetUser resets all changes to the "user" edge.

func (*RoleMutation) SetComment

func (m *RoleMutation) SetComment(s string)

SetComment sets the "comment" field.

func (*RoleMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*RoleMutation) SetDeletedAt

func (m *RoleMutation) SetDeletedAt(t time.Time)

SetDeletedAt sets the "deleted_at" field.

func (*RoleMutation) SetField

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

func (m *RoleMutation) SetID(id int64)

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

func (*RoleMutation) SetKey

func (m *RoleMutation) SetKey(s string)

SetKey sets the "key" field.

func (*RoleMutation) SetName

func (m *RoleMutation) SetName(s string)

SetName sets the "name" field.

func (*RoleMutation) SetUpdatedAt

func (m *RoleMutation) SetUpdatedAt(t time.Time)

SetUpdatedAt sets the "updated_at" field.

func (RoleMutation) Tx

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

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

func (*RoleMutation) Type

func (m *RoleMutation) Type() string

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

func (*RoleMutation) UpdatedAt

func (m *RoleMutation) UpdatedAt() (r time.Time, exists bool)

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (*RoleMutation) UserCleared

func (m *RoleMutation) UserCleared() bool

UserCleared reports if the "user" edge to the User entity was cleared.

func (*RoleMutation) UserIDs

func (m *RoleMutation) UserIDs() (ids []int)

UserIDs returns the "user" edge IDs in the mutation.

func (*RoleMutation) Where

func (m *RoleMutation) Where(ps ...predicate.Role)

Where appends a list predicates to the RoleMutation builder.

type RoleQuery

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

RoleQuery is the builder for querying Role entities.

func (*RoleQuery) All

func (rq *RoleQuery) All(ctx context.Context) ([]*Role, error)

All executes the query and returns a list of Roles.

func (*RoleQuery) AllX

func (rq *RoleQuery) AllX(ctx context.Context) []*Role

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

func (*RoleQuery) Clone

func (rq *RoleQuery) Clone() *RoleQuery

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

func (*RoleQuery) Count

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

Count returns the count of the given query.

func (*RoleQuery) CountX

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

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

func (*RoleQuery) Exist

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

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

func (*RoleQuery) ExistX

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

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

func (*RoleQuery) First

func (rq *RoleQuery) First(ctx context.Context) (*Role, error)

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

func (*RoleQuery) FirstID

func (rq *RoleQuery) FirstID(ctx context.Context) (id int64, err error)

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

func (*RoleQuery) FirstIDX

func (rq *RoleQuery) FirstIDX(ctx context.Context) int64

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

func (*RoleQuery) FirstX

func (rq *RoleQuery) FirstX(ctx context.Context) *Role

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

func (*RoleQuery) GroupBy

func (rq *RoleQuery) GroupBy(field string, fields ...string) *RoleGroupBy

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

client.Role.Query().
	GroupBy(role.FieldCreatedAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*RoleQuery) IDs

func (rq *RoleQuery) IDs(ctx context.Context) ([]int64, error)

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

func (*RoleQuery) IDsX

func (rq *RoleQuery) IDsX(ctx context.Context) []int64

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

func (*RoleQuery) Limit

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

Limit adds a limit step to the query.

func (*RoleQuery) Offset

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

Offset adds an offset step to the query.

func (*RoleQuery) Only

func (rq *RoleQuery) Only(ctx context.Context) (*Role, error)

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

func (*RoleQuery) OnlyID

func (rq *RoleQuery) OnlyID(ctx context.Context) (id int64, err error)

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

func (*RoleQuery) OnlyIDX

func (rq *RoleQuery) OnlyIDX(ctx context.Context) int64

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

func (*RoleQuery) OnlyX

func (rq *RoleQuery) OnlyX(ctx context.Context) *Role

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

func (*RoleQuery) Order

func (rq *RoleQuery) Order(o ...OrderFunc) *RoleQuery

Order adds an order step to the query.

func (*RoleQuery) QueryMenu

func (rq *RoleQuery) QueryMenu() *MenuQuery

QueryMenu chains the current query on the "menu" edge.

func (*RoleQuery) QueryUser

func (rq *RoleQuery) QueryUser() *UserQuery

QueryUser chains the current query on the "user" edge.

func (*RoleQuery) Select

func (rq *RoleQuery) Select(fields ...string) *RoleSelect

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

client.Role.Query().
	Select(role.FieldCreatedAt).
	Scan(ctx, &v)

func (*RoleQuery) Unique

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

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

func (rq *RoleQuery) Where(ps ...predicate.Role) *RoleQuery

Where adds a new predicate for the RoleQuery builder.

func (*RoleQuery) WithMenu

func (rq *RoleQuery) WithMenu(opts ...func(*MenuQuery)) *RoleQuery

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

func (*RoleQuery) WithUser

func (rq *RoleQuery) WithUser(opts ...func(*UserQuery)) *RoleQuery

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

type RoleSelect

type RoleSelect struct {
	*RoleQuery
	// contains filtered or unexported fields
}

RoleSelect is the builder for selecting fields of Role entities.

func (*RoleSelect) Bool

func (rs *RoleSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*RoleSelect) BoolX

func (rs *RoleSelect) BoolX(ctx context.Context) bool

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

func (*RoleSelect) Bools

func (rs *RoleSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*RoleSelect) BoolsX

func (rs *RoleSelect) BoolsX(ctx context.Context) []bool

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

func (*RoleSelect) Float64

func (rs *RoleSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*RoleSelect) Float64X

func (rs *RoleSelect) Float64X(ctx context.Context) float64

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

func (*RoleSelect) Float64s

func (rs *RoleSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*RoleSelect) Float64sX

func (rs *RoleSelect) Float64sX(ctx context.Context) []float64

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

func (*RoleSelect) Int

func (rs *RoleSelect) Int(ctx context.Context) (_ int, err error)

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

func (*RoleSelect) IntX

func (rs *RoleSelect) IntX(ctx context.Context) int

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

func (*RoleSelect) Ints

func (rs *RoleSelect) Ints(ctx context.Context) ([]int, error)

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

func (*RoleSelect) IntsX

func (rs *RoleSelect) IntsX(ctx context.Context) []int

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

func (*RoleSelect) Scan

func (rs *RoleSelect) Scan(ctx context.Context, v interface{}) error

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

func (*RoleSelect) ScanX

func (rs *RoleSelect) ScanX(ctx context.Context, v interface{})

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

func (*RoleSelect) String

func (rs *RoleSelect) String(ctx context.Context) (_ string, err error)

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

func (*RoleSelect) StringX

func (rs *RoleSelect) StringX(ctx context.Context) string

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

func (*RoleSelect) Strings

func (rs *RoleSelect) Strings(ctx context.Context) ([]string, error)

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

func (*RoleSelect) StringsX

func (rs *RoleSelect) StringsX(ctx context.Context) []string

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

type RoleUpdate

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

RoleUpdate is the builder for updating Role entities.

func (*RoleUpdate) AddMenu

func (ru *RoleUpdate) AddMenu(m ...*Menu) *RoleUpdate

AddMenu adds the "menu" edges to the Menu entity.

func (*RoleUpdate) AddMenuIDs

func (ru *RoleUpdate) AddMenuIDs(ids ...int64) *RoleUpdate

AddMenuIDs adds the "menu" edge to the Menu entity by IDs.

func (*RoleUpdate) AddUser

func (ru *RoleUpdate) AddUser(u ...*User) *RoleUpdate

AddUser adds the "user" edges to the User entity.

func (*RoleUpdate) AddUserIDs

func (ru *RoleUpdate) AddUserIDs(ids ...int) *RoleUpdate

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

func (*RoleUpdate) ClearComment

func (ru *RoleUpdate) ClearComment() *RoleUpdate

ClearComment clears the value of the "comment" field.

func (*RoleUpdate) ClearDeletedAt

func (ru *RoleUpdate) ClearDeletedAt() *RoleUpdate

ClearDeletedAt clears the value of the "deleted_at" field.

func (*RoleUpdate) ClearMenu

func (ru *RoleUpdate) ClearMenu() *RoleUpdate

ClearMenu clears all "menu" edges to the Menu entity.

func (*RoleUpdate) ClearUser

func (ru *RoleUpdate) ClearUser() *RoleUpdate

ClearUser clears all "user" edges to the User entity.

func (*RoleUpdate) Exec

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

Exec executes the query.

func (*RoleUpdate) ExecX

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

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

func (*RoleUpdate) Mutation

func (ru *RoleUpdate) Mutation() *RoleMutation

Mutation returns the RoleMutation object of the builder.

func (*RoleUpdate) RemoveMenu

func (ru *RoleUpdate) RemoveMenu(m ...*Menu) *RoleUpdate

RemoveMenu removes "menu" edges to Menu entities.

func (*RoleUpdate) RemoveMenuIDs

func (ru *RoleUpdate) RemoveMenuIDs(ids ...int64) *RoleUpdate

RemoveMenuIDs removes the "menu" edge to Menu entities by IDs.

func (*RoleUpdate) RemoveUser

func (ru *RoleUpdate) RemoveUser(u ...*User) *RoleUpdate

RemoveUser removes "user" edges to User entities.

func (*RoleUpdate) RemoveUserIDs

func (ru *RoleUpdate) RemoveUserIDs(ids ...int) *RoleUpdate

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

func (*RoleUpdate) Save

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

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

func (*RoleUpdate) SaveX

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

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

func (*RoleUpdate) SetComment

func (ru *RoleUpdate) SetComment(s string) *RoleUpdate

SetComment sets the "comment" field.

func (*RoleUpdate) SetDeletedAt

func (ru *RoleUpdate) SetDeletedAt(t time.Time) *RoleUpdate

SetDeletedAt sets the "deleted_at" field.

func (*RoleUpdate) SetKey

func (ru *RoleUpdate) SetKey(s string) *RoleUpdate

SetKey sets the "key" field.

func (*RoleUpdate) SetName

func (ru *RoleUpdate) SetName(s string) *RoleUpdate

SetName sets the "name" field.

func (*RoleUpdate) SetNillableComment

func (ru *RoleUpdate) SetNillableComment(s *string) *RoleUpdate

SetNillableComment sets the "comment" field if the given value is not nil.

func (*RoleUpdate) SetUpdatedAt

func (ru *RoleUpdate) SetUpdatedAt(t time.Time) *RoleUpdate

SetUpdatedAt sets the "updated_at" field.

func (*RoleUpdate) Where

func (ru *RoleUpdate) Where(ps ...predicate.Role) *RoleUpdate

Where appends a list predicates to the RoleUpdate builder.

type RoleUpdateOne

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

RoleUpdateOne is the builder for updating a single Role entity.

func (*RoleUpdateOne) AddMenu

func (ruo *RoleUpdateOne) AddMenu(m ...*Menu) *RoleUpdateOne

AddMenu adds the "menu" edges to the Menu entity.

func (*RoleUpdateOne) AddMenuIDs

func (ruo *RoleUpdateOne) AddMenuIDs(ids ...int64) *RoleUpdateOne

AddMenuIDs adds the "menu" edge to the Menu entity by IDs.

func (*RoleUpdateOne) AddUser

func (ruo *RoleUpdateOne) AddUser(u ...*User) *RoleUpdateOne

AddUser adds the "user" edges to the User entity.

func (*RoleUpdateOne) AddUserIDs

func (ruo *RoleUpdateOne) AddUserIDs(ids ...int) *RoleUpdateOne

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

func (*RoleUpdateOne) ClearComment

func (ruo *RoleUpdateOne) ClearComment() *RoleUpdateOne

ClearComment clears the value of the "comment" field.

func (*RoleUpdateOne) ClearDeletedAt

func (ruo *RoleUpdateOne) ClearDeletedAt() *RoleUpdateOne

ClearDeletedAt clears the value of the "deleted_at" field.

func (*RoleUpdateOne) ClearMenu

func (ruo *RoleUpdateOne) ClearMenu() *RoleUpdateOne

ClearMenu clears all "menu" edges to the Menu entity.

func (*RoleUpdateOne) ClearUser

func (ruo *RoleUpdateOne) ClearUser() *RoleUpdateOne

ClearUser clears all "user" edges to the User entity.

func (*RoleUpdateOne) Exec

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

Exec executes the query on the entity.

func (*RoleUpdateOne) ExecX

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

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

func (*RoleUpdateOne) Mutation

func (ruo *RoleUpdateOne) Mutation() *RoleMutation

Mutation returns the RoleMutation object of the builder.

func (*RoleUpdateOne) RemoveMenu

func (ruo *RoleUpdateOne) RemoveMenu(m ...*Menu) *RoleUpdateOne

RemoveMenu removes "menu" edges to Menu entities.

func (*RoleUpdateOne) RemoveMenuIDs

func (ruo *RoleUpdateOne) RemoveMenuIDs(ids ...int64) *RoleUpdateOne

RemoveMenuIDs removes the "menu" edge to Menu entities by IDs.

func (*RoleUpdateOne) RemoveUser

func (ruo *RoleUpdateOne) RemoveUser(u ...*User) *RoleUpdateOne

RemoveUser removes "user" edges to User entities.

func (*RoleUpdateOne) RemoveUserIDs

func (ruo *RoleUpdateOne) RemoveUserIDs(ids ...int) *RoleUpdateOne

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

func (*RoleUpdateOne) Save

func (ruo *RoleUpdateOne) Save(ctx context.Context) (*Role, error)

Save executes the query and returns the updated Role entity.

func (*RoleUpdateOne) SaveX

func (ruo *RoleUpdateOne) SaveX(ctx context.Context) *Role

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

func (*RoleUpdateOne) Select

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

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

func (*RoleUpdateOne) SetComment

func (ruo *RoleUpdateOne) SetComment(s string) *RoleUpdateOne

SetComment sets the "comment" field.

func (*RoleUpdateOne) SetDeletedAt

func (ruo *RoleUpdateOne) SetDeletedAt(t time.Time) *RoleUpdateOne

SetDeletedAt sets the "deleted_at" field.

func (*RoleUpdateOne) SetKey

func (ruo *RoleUpdateOne) SetKey(s string) *RoleUpdateOne

SetKey sets the "key" field.

func (*RoleUpdateOne) SetName

func (ruo *RoleUpdateOne) SetName(s string) *RoleUpdateOne

SetName sets the "name" field.

func (*RoleUpdateOne) SetNillableComment

func (ruo *RoleUpdateOne) SetNillableComment(s *string) *RoleUpdateOne

SetNillableComment sets the "comment" field if the given value is not nil.

func (*RoleUpdateOne) SetUpdatedAt

func (ruo *RoleUpdateOne) SetUpdatedAt(t time.Time) *RoleUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Roles

type Roles []*Role

Roles is a parsable slice of Role.

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(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 Rollbacker method.

type Tx

type Tx struct {

	// Menu is the client for interacting with the Menu builders.
	Menu *MenuClient
	// Role is the client for interacting with the Role builders.
	Role *RoleClient
	// 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"`
	// CreatedAt holds the value of the "created_at" field.
	// 创建时间
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	// 更新时间
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// DeletedAt holds the value of the "deleted_at" field.
	// 删除时间
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
	// Username holds the value of the "username" field.
	// 用户名
	Username string `json:"username,omitempty"`
	// Password holds the value of the "password" field.
	// 密码
	Password *string `json:"-"`
	// NickName holds the value of the "nick_name" field.
	// 昵称
	NickName *string `json:"nick_name,omitempty"`
	// Phone holds the value of the "phone" field.
	// 手机号
	Phone *string `json:"phone,omitempty"`
	// Status holds the value of the "status" field.
	// 用户状态
	Status string `json:"status,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the UserQuery when eager-loading is set.
	Edges UserEdges `json:"edges"`
	// contains filtered or unexported fields
}

User is the model entity for the User schema.

func (*User) QueryRole

func (u *User) QueryRole() *RoleQuery

QueryRole queries the "role" edge of the User entity.

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (u *User) Unwrap() *User

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

func (*User) Update

func (u *User) Update() *UserUpdateOne

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

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 create builder for User.

func (*UserClient) CreateBulk

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

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

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

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

DeleteOne returns a delete builder for the given entity.

func (*UserClient) DeleteOneID

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

DeleteOneID returns a delete builder for the given 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) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QueryRole

func (c *UserClient) QueryRole(u *User) *RoleQuery

QueryRole queries the role edge of a User.

func (*UserClient) Update

func (c *UserClient) Update() *UserUpdate

Update returns an update builder for User.

func (*UserClient) UpdateOne

func (c *UserClient) UpdateOne(u *User) *UserUpdateOne

UpdateOne returns an update builder for the given entity.

func (*UserClient) UpdateOneID

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

UpdateOneID returns an update builder for the given id.

func (*UserClient) Use

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

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

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddRole

func (uc *UserCreate) AddRole(r ...*Role) *UserCreate

AddRole adds the "role" edges to the Role entity.

func (*UserCreate) AddRoleIDs

func (uc *UserCreate) AddRoleIDs(ids ...int64) *UserCreate

AddRoleIDs adds the "role" edge to the Role entity by IDs.

func (*UserCreate) Exec

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

Exec executes the query.

func (*UserCreate) ExecX

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

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

func (*UserCreate) Mutation

func (uc *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) Save

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

Save creates the User in the database.

func (*UserCreate) SaveX

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

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*UserCreate) SetDeletedAt

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

SetDeletedAt sets the "deleted_at" field.

func (*UserCreate) SetID

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

SetID sets the "id" field.

func (*UserCreate) SetNickName

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

SetNickName sets the "nick_name" field.

func (*UserCreate) SetNillableCreatedAt

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

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

func (*UserCreate) SetNillableDeletedAt

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

SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.

func (*UserCreate) SetNillableNickName

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

SetNillableNickName sets the "nick_name" field if the given value is not nil.

func (*UserCreate) SetNillablePassword

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

SetNillablePassword sets the "password" field if the given value is not nil.

func (*UserCreate) SetNillablePhone

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

SetNillablePhone sets the "phone" field if the given value is not nil.

func (*UserCreate) SetNillableStatus

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

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

func (*UserCreate) SetNillableUpdatedAt

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

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*UserCreate) SetPassword

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

SetPassword sets the "password" field.

func (*UserCreate) SetPhone

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

SetPhone sets the "phone" field.

func (*UserCreate) SetStatus

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

SetStatus sets the "status" field.

func (*UserCreate) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*UserCreate) SetUsername

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

SetUsername sets the "username" field.

type UserCreateBulk

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

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

func (*UserCreateBulk) Exec

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

Exec executes the query.

func (*UserCreateBulk) ExecX

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

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

func (*UserCreateBulk) Save

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

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

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

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

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

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

func (*UserDelete) ExecX

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

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

func (*UserDelete) Where

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

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

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

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

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

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

type UserEdges

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

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

func (UserEdges) RoleOrErr

func (e UserEdges) RoleOrErr() ([]*Role, error)

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

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

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

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

func (*UserGroupBy) Bool

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

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) BoolX

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

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

func (*UserGroupBy) Bools

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

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) BoolsX

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

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

func (*UserGroupBy) Float64

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

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) Float64X

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

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

func (*UserGroupBy) Float64s

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

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) Float64sX

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

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

func (*UserGroupBy) Int

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

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) IntX

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

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

func (*UserGroupBy) Ints

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

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) IntsX

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

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

func (*UserGroupBy) Scan

func (ugb *UserGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (*UserGroupBy) ScanX

func (ugb *UserGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*UserGroupBy) String

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

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) StringX

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

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

func (*UserGroupBy) Strings

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

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) StringsX

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

func (m *UserMutation) AddRoleIDs(ids ...int64)

AddRoleIDs adds the "role" edge to the Role 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) ClearDeletedAt

func (m *UserMutation) ClearDeletedAt()

ClearDeletedAt clears the value of the "deleted_at" field.

func (*UserMutation) ClearEdge

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

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

func (*UserMutation) ClearField

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

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

func (*UserMutation) ClearNickName

func (m *UserMutation) ClearNickName()

ClearNickName clears the value of the "nick_name" field.

func (*UserMutation) ClearPassword

func (m *UserMutation) ClearPassword()

ClearPassword clears the value of the "password" field.

func (*UserMutation) ClearPhone

func (m *UserMutation) ClearPhone()

ClearPhone clears the value of the "phone" field.

func (*UserMutation) ClearRole

func (m *UserMutation) ClearRole()

ClearRole clears the "role" edge to the Role 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) CreatedAt

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

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

func (*UserMutation) DeletedAt

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

DeletedAt returns the value of the "deleted_at" field in the mutation.

func (*UserMutation) DeletedAtCleared

func (m *UserMutation) DeletedAtCleared() bool

DeletedAtCleared returns if the "deleted_at" field was cleared in this 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) 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) NickName

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

NickName returns the value of the "nick_name" field in the mutation.

func (*UserMutation) NickNameCleared

func (m *UserMutation) NickNameCleared() bool

NickNameCleared returns if the "nick_name" field was cleared in this mutation.

func (*UserMutation) OldCreatedAt

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

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

func (*UserMutation) OldDeletedAt

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

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

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

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

OldNickName returns the old "nick_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) OldPhone

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

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

func (*UserMutation) OldStatus

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

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

func (*UserMutation) OldUpdatedAt

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

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

func (*UserMutation) OldUsername

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

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

func (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) Password

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

Password returns the value of the "password" field in the mutation.

func (*UserMutation) PasswordCleared

func (m *UserMutation) PasswordCleared() bool

PasswordCleared returns if the "password" field was cleared in this mutation.

func (*UserMutation) Phone

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

Phone returns the value of the "phone" field in the mutation.

func (*UserMutation) PhoneCleared

func (m *UserMutation) PhoneCleared() bool

PhoneCleared returns if the "phone" field was cleared in this mutation.

func (*UserMutation) RemoveRoleIDs

func (m *UserMutation) RemoveRoleIDs(ids ...int64)

RemoveRoleIDs removes the "role" edge to the Role 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) RemovedRoleIDs

func (m *UserMutation) RemovedRoleIDs() (ids []int64)

RemovedRole returns the removed IDs of the "role" edge to the Role entity.

func (*UserMutation) ResetCreatedAt

func (m *UserMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*UserMutation) ResetDeletedAt

func (m *UserMutation) ResetDeletedAt()

ResetDeletedAt resets all changes to the "deleted_at" field.

func (*UserMutation) ResetEdge

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

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

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

func (m *UserMutation) ResetNickName()

ResetNickName resets all changes to the "nick_name" field.

func (*UserMutation) ResetPassword

func (m *UserMutation) ResetPassword()

ResetPassword resets all changes to the "password" field.

func (*UserMutation) ResetPhone

func (m *UserMutation) ResetPhone()

ResetPhone resets all changes to the "phone" field.

func (*UserMutation) ResetRole

func (m *UserMutation) ResetRole()

ResetRole resets all changes to the "role" edge.

func (*UserMutation) ResetStatus

func (m *UserMutation) ResetStatus()

ResetStatus resets all changes to the "status" field.

func (*UserMutation) ResetUpdatedAt

func (m *UserMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*UserMutation) ResetUsername

func (m *UserMutation) ResetUsername()

ResetUsername resets all changes to the "username" field.

func (*UserMutation) RoleCleared

func (m *UserMutation) RoleCleared() bool

RoleCleared reports if the "role" edge to the Role entity was cleared.

func (*UserMutation) RoleIDs

func (m *UserMutation) RoleIDs() (ids []int64)

RoleIDs returns the "role" edge IDs in the mutation.

func (*UserMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*UserMutation) SetDeletedAt

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

SetDeletedAt sets the "deleted_at" 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) SetID

func (m *UserMutation) SetID(id int)

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

func (*UserMutation) SetNickName

func (m *UserMutation) SetNickName(s string)

SetNickName sets the "nick_name" field.

func (*UserMutation) SetPassword

func (m *UserMutation) SetPassword(s string)

SetPassword sets the "password" field.

func (*UserMutation) SetPhone

func (m *UserMutation) SetPhone(s string)

SetPhone sets the "phone" field.

func (*UserMutation) SetStatus

func (m *UserMutation) SetStatus(s string)

SetStatus sets the "status" field.

func (*UserMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*UserMutation) SetUsername

func (m *UserMutation) SetUsername(s string)

SetUsername sets the "username" field.

func (*UserMutation) Status

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

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

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) UpdatedAt

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

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (*UserMutation) Username

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

Username returns the value of the "username" field in the mutation.

func (*UserMutation) Where

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

Where appends a list predicates to the UserMutation builder.

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) All

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

All executes the query and returns a list of Users.

func (*UserQuery) AllX

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

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

func (*UserQuery) Clone

func (uq *UserQuery) Clone() *UserQuery

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

func (*UserQuery) Count

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

Count returns the count of the given query.

func (*UserQuery) CountX

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

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

func (*UserQuery) Exist

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

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

func (*UserQuery) ExistX

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

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

func (*UserQuery) First

func (uq *UserQuery) First(ctx context.Context) (*User, error)

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

func (*UserQuery) FirstID

func (uq *UserQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*UserQuery) FirstIDX

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

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

func (*UserQuery) FirstX

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

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

func (*UserQuery) GroupBy

func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy

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

Example:

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

client.User.Query().
	GroupBy(user.FieldCreatedAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserQuery) IDs

func (uq *UserQuery) IDs(ctx context.Context) ([]int, error)

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

func (*UserQuery) IDsX

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

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

func (*UserQuery) Limit

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

Limit adds a limit step to the query.

func (*UserQuery) Offset

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

Offset adds an offset step to the query.

func (*UserQuery) Only

func (uq *UserQuery) Only(ctx context.Context) (*User, error)

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

func (*UserQuery) OnlyID

func (uq *UserQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*UserQuery) OnlyIDX

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

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

func (*UserQuery) OnlyX

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

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

func (*UserQuery) Order

func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery

Order adds an order step to the query.

func (*UserQuery) QueryRole

func (uq *UserQuery) QueryRole() *RoleQuery

QueryRole chains the current query on the "role" edge.

func (*UserQuery) Select

func (uq *UserQuery) Select(fields ...string) *UserSelect

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

Example:

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

client.User.Query().
	Select(user.FieldCreatedAt).
	Scan(ctx, &v)

func (*UserQuery) Unique

func (uq *UserQuery) Unique(unique bool) *UserQuery

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

func (*UserQuery) Where

func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithRole

func (uq *UserQuery) WithRole(opts ...func(*RoleQuery)) *UserQuery

WithRole tells the query-builder to eager-load the nodes that are connected to the "role" 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) Bool

func (us *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 (us *UserSelect) BoolX(ctx context.Context) bool

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

func (*UserSelect) Bools

func (us *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 (us *UserSelect) BoolsX(ctx context.Context) []bool

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

func (*UserSelect) Float64

func (us *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 (us *UserSelect) Float64X(ctx context.Context) float64

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

func (*UserSelect) Float64s

func (us *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 (us *UserSelect) Float64sX(ctx context.Context) []float64

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

func (*UserSelect) Int

func (us *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 (us *UserSelect) IntX(ctx context.Context) int

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

func (*UserSelect) Ints

func (us *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 (us *UserSelect) IntsX(ctx context.Context) []int

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

func (*UserSelect) Scan

func (us *UserSelect) Scan(ctx context.Context, v interface{}) error

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

func (*UserSelect) ScanX

func (us *UserSelect) ScanX(ctx context.Context, v interface{})

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

func (*UserSelect) String

func (us *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 (us *UserSelect) StringX(ctx context.Context) string

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

func (*UserSelect) Strings

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

func (uu *UserUpdate) AddRole(r ...*Role) *UserUpdate

AddRole adds the "role" edges to the Role entity.

func (*UserUpdate) AddRoleIDs

func (uu *UserUpdate) AddRoleIDs(ids ...int64) *UserUpdate

AddRoleIDs adds the "role" edge to the Role entity by IDs.

func (*UserUpdate) ClearDeletedAt

func (uu *UserUpdate) ClearDeletedAt() *UserUpdate

ClearDeletedAt clears the value of the "deleted_at" field.

func (*UserUpdate) ClearNickName

func (uu *UserUpdate) ClearNickName() *UserUpdate

ClearNickName clears the value of the "nick_name" field.

func (*UserUpdate) ClearPassword

func (uu *UserUpdate) ClearPassword() *UserUpdate

ClearPassword clears the value of the "password" field.

func (*UserUpdate) ClearPhone

func (uu *UserUpdate) ClearPhone() *UserUpdate

ClearPhone clears the value of the "phone" field.

func (*UserUpdate) ClearRole

func (uu *UserUpdate) ClearRole() *UserUpdate

ClearRole clears all "role" edges to the Role entity.

func (*UserUpdate) Exec

func (uu *UserUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpdate) ExecX

func (uu *UserUpdate) ExecX(ctx context.Context)

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

func (*UserUpdate) Mutation

func (uu *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemoveRole

func (uu *UserUpdate) RemoveRole(r ...*Role) *UserUpdate

RemoveRole removes "role" edges to Role entities.

func (*UserUpdate) RemoveRoleIDs

func (uu *UserUpdate) RemoveRoleIDs(ids ...int64) *UserUpdate

RemoveRoleIDs removes the "role" edge to Role entities by IDs.

func (*UserUpdate) Save

func (uu *UserUpdate) Save(ctx context.Context) (int, error)

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

func (*UserUpdate) SaveX

func (uu *UserUpdate) SaveX(ctx context.Context) int

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

func (*UserUpdate) SetDeletedAt

func (uu *UserUpdate) SetDeletedAt(t time.Time) *UserUpdate

SetDeletedAt sets the "deleted_at" field.

func (*UserUpdate) SetNickName

func (uu *UserUpdate) SetNickName(s string) *UserUpdate

SetNickName sets the "nick_name" field.

func (*UserUpdate) SetNillableNickName

func (uu *UserUpdate) SetNillableNickName(s *string) *UserUpdate

SetNillableNickName sets the "nick_name" field if the given value is not nil.

func (*UserUpdate) SetNillablePassword

func (uu *UserUpdate) SetNillablePassword(s *string) *UserUpdate

SetNillablePassword sets the "password" field if the given value is not nil.

func (*UserUpdate) SetNillablePhone

func (uu *UserUpdate) SetNillablePhone(s *string) *UserUpdate

SetNillablePhone sets the "phone" field if the given value is not nil.

func (*UserUpdate) SetNillableStatus

func (uu *UserUpdate) SetNillableStatus(s *string) *UserUpdate

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

func (*UserUpdate) SetPassword

func (uu *UserUpdate) SetPassword(s string) *UserUpdate

SetPassword sets the "password" field.

func (*UserUpdate) SetPhone

func (uu *UserUpdate) SetPhone(s string) *UserUpdate

SetPhone sets the "phone" field.

func (*UserUpdate) SetStatus

func (uu *UserUpdate) SetStatus(s string) *UserUpdate

SetStatus sets the "status" field.

func (*UserUpdate) SetUpdatedAt

func (uu *UserUpdate) SetUpdatedAt(t time.Time) *UserUpdate

SetUpdatedAt sets the "updated_at" field.

func (*UserUpdate) SetUsername

func (uu *UserUpdate) SetUsername(s string) *UserUpdate

SetUsername sets the "username" field.

func (*UserUpdate) Where

func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOne

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

UserUpdateOne is the builder for updating a single User entity.

func (*UserUpdateOne) AddRole

func (uuo *UserUpdateOne) AddRole(r ...*Role) *UserUpdateOne

AddRole adds the "role" edges to the Role entity.

func (*UserUpdateOne) AddRoleIDs

func (uuo *UserUpdateOne) AddRoleIDs(ids ...int64) *UserUpdateOne

AddRoleIDs adds the "role" edge to the Role entity by IDs.

func (*UserUpdateOne) ClearDeletedAt

func (uuo *UserUpdateOne) ClearDeletedAt() *UserUpdateOne

ClearDeletedAt clears the value of the "deleted_at" field.

func (*UserUpdateOne) ClearNickName

func (uuo *UserUpdateOne) ClearNickName() *UserUpdateOne

ClearNickName clears the value of the "nick_name" field.

func (*UserUpdateOne) ClearPassword

func (uuo *UserUpdateOne) ClearPassword() *UserUpdateOne

ClearPassword clears the value of the "password" field.

func (*UserUpdateOne) ClearPhone

func (uuo *UserUpdateOne) ClearPhone() *UserUpdateOne

ClearPhone clears the value of the "phone" field.

func (*UserUpdateOne) ClearRole

func (uuo *UserUpdateOne) ClearRole() *UserUpdateOne

ClearRole clears all "role" edges to the Role entity.

func (*UserUpdateOne) Exec

func (uuo *UserUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

func (uuo *UserUpdateOne) ExecX(ctx context.Context)

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

func (*UserUpdateOne) Mutation

func (uuo *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemoveRole

func (uuo *UserUpdateOne) RemoveRole(r ...*Role) *UserUpdateOne

RemoveRole removes "role" edges to Role entities.

func (*UserUpdateOne) RemoveRoleIDs

func (uuo *UserUpdateOne) RemoveRoleIDs(ids ...int64) *UserUpdateOne

RemoveRoleIDs removes the "role" edge to Role entities by IDs.

func (*UserUpdateOne) Save

func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User

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

func (*UserUpdateOne) Select

func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne

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

func (*UserUpdateOne) SetDeletedAt

func (uuo *UserUpdateOne) SetDeletedAt(t time.Time) *UserUpdateOne

SetDeletedAt sets the "deleted_at" field.

func (*UserUpdateOne) SetNickName

func (uuo *UserUpdateOne) SetNickName(s string) *UserUpdateOne

SetNickName sets the "nick_name" field.

func (*UserUpdateOne) SetNillableNickName

func (uuo *UserUpdateOne) SetNillableNickName(s *string) *UserUpdateOne

SetNillableNickName sets the "nick_name" field if the given value is not nil.

func (*UserUpdateOne) SetNillablePassword

func (uuo *UserUpdateOne) SetNillablePassword(s *string) *UserUpdateOne

SetNillablePassword sets the "password" field if the given value is not nil.

func (*UserUpdateOne) SetNillablePhone

func (uuo *UserUpdateOne) SetNillablePhone(s *string) *UserUpdateOne

SetNillablePhone sets the "phone" field if the given value is not nil.

func (*UserUpdateOne) SetNillableStatus

func (uuo *UserUpdateOne) SetNillableStatus(s *string) *UserUpdateOne

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

func (*UserUpdateOne) SetPassword

func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne

SetPassword sets the "password" field.

func (*UserUpdateOne) SetPhone

func (uuo *UserUpdateOne) SetPhone(s string) *UserUpdateOne

SetPhone sets the "phone" field.

func (*UserUpdateOne) SetStatus

func (uuo *UserUpdateOne) SetStatus(s string) *UserUpdateOne

SetStatus sets the "status" field.

func (*UserUpdateOne) SetUpdatedAt

func (uuo *UserUpdateOne) SetUpdatedAt(t time.Time) *UserUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*UserUpdateOne) SetUsername

func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne

SetUsername sets the "username" field.

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