ent

package
v0.0.0-...-ac9090e Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 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.
	TypeResources = "Resources"
	TypeTag       = "Tag"
	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
	// Resources is the client for interacting with the Resources builders.
	Resources *ResourcesClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

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

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new client configured with the given options.

func Open

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

Open opens a database/sql.DB specified by the driver name and the data source name, and returns a new client attached to it. Optional parameters can be added for configuring the client.

func (*Client) BeginTx

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

BeginTx returns a transactional client with specified options.

func (*Client) Close

func (c *Client) Close() error

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

func (*Client) Debug

func (c *Client) Debug() *Client

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

client.Debug().
	Resources.
	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 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 Resources

type Resources struct {

	// ID of the ent.
	ID string `json:"id,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"`
	// Desc holds the value of the "desc" field.
	Desc string `json:"desc,omitempty"`
	// Explain holds the value of the "explain" field.
	Explain string `json:"explain,omitempty"`
	// URL holds the value of the "url" field.
	URL string `json:"url,omitempty"`
	// IsTop holds the value of the "is_top" field.
	IsTop bool `json:"is_top,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"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the ResourcesQuery when eager-loading is set.
	Edges ResourcesEdges `json:"edges"`
	// contains filtered or unexported fields
}

Resources is the model entity for the Resources schema.

func (*Resources) QueryTag

func (r *Resources) QueryTag() *TagQuery

QueryTag queries the "tag" edge of the Resources entity.

func (*Resources) String

func (r *Resources) String() string

String implements the fmt.Stringer.

func (*Resources) Unwrap

func (r *Resources) Unwrap() *Resources

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

func (r *Resources) Update() *ResourcesUpdateOne

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

type ResourcesClient

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

ResourcesClient is a client for the Resources schema.

func NewResourcesClient

func NewResourcesClient(c config) *ResourcesClient

NewResourcesClient returns a client for the Resources from the given config.

func (*ResourcesClient) Create

func (c *ResourcesClient) Create() *ResourcesCreate

Create returns a create builder for Resources.

func (*ResourcesClient) CreateBulk

func (c *ResourcesClient) CreateBulk(builders ...*ResourcesCreate) *ResourcesCreateBulk

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

func (*ResourcesClient) Delete

func (c *ResourcesClient) Delete() *ResourcesDelete

Delete returns a delete builder for Resources.

func (*ResourcesClient) DeleteOne

func (c *ResourcesClient) DeleteOne(r *Resources) *ResourcesDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*ResourcesClient) DeleteOneID

func (c *ResourcesClient) DeleteOneID(id string) *ResourcesDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*ResourcesClient) Get

func (c *ResourcesClient) Get(ctx context.Context, id string) (*Resources, error)

Get returns a Resources entity by its id.

func (*ResourcesClient) GetX

func (c *ResourcesClient) GetX(ctx context.Context, id string) *Resources

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

func (*ResourcesClient) Hooks

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

Hooks returns the client hooks.

func (*ResourcesClient) Query

func (c *ResourcesClient) Query() *ResourcesQuery

Query returns a query builder for Resources.

func (*ResourcesClient) QueryTag

func (c *ResourcesClient) QueryTag(r *Resources) *TagQuery

QueryTag queries the tag edge of a Resources.

func (*ResourcesClient) Update

func (c *ResourcesClient) Update() *ResourcesUpdate

Update returns an update builder for Resources.

func (*ResourcesClient) UpdateOne

func (c *ResourcesClient) UpdateOne(r *Resources) *ResourcesUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ResourcesClient) UpdateOneID

func (c *ResourcesClient) UpdateOneID(id string) *ResourcesUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ResourcesClient) Use

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

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

type ResourcesCreate

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

ResourcesCreate is the builder for creating a Resources entity.

func (*ResourcesCreate) AddTag

func (rc *ResourcesCreate) AddTag(t ...*Tag) *ResourcesCreate

AddTag adds the "tag" edges to the Tag entity.

func (*ResourcesCreate) AddTagIDs

func (rc *ResourcesCreate) AddTagIDs(ids ...string) *ResourcesCreate

AddTagIDs adds the "tag" edge to the Tag entity by IDs.

func (*ResourcesCreate) Exec

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

Exec executes the query.

func (*ResourcesCreate) ExecX

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

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

func (*ResourcesCreate) Mutation

func (rc *ResourcesCreate) Mutation() *ResourcesMutation

Mutation returns the ResourcesMutation object of the builder.

func (*ResourcesCreate) Save

func (rc *ResourcesCreate) Save(ctx context.Context) (*Resources, error)

Save creates the Resources in the database.

func (*ResourcesCreate) SaveX

func (rc *ResourcesCreate) SaveX(ctx context.Context) *Resources

SaveX calls Save and panics if Save returns an error.

func (*ResourcesCreate) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*ResourcesCreate) SetDesc

func (rc *ResourcesCreate) SetDesc(s string) *ResourcesCreate

SetDesc sets the "desc" field.

func (*ResourcesCreate) SetExplain

func (rc *ResourcesCreate) SetExplain(s string) *ResourcesCreate

SetExplain sets the "explain" field.

func (*ResourcesCreate) SetID

func (rc *ResourcesCreate) SetID(s string) *ResourcesCreate

SetID sets the "id" field.

func (*ResourcesCreate) SetIcon

func (rc *ResourcesCreate) SetIcon(s string) *ResourcesCreate

SetIcon sets the "icon" field.

func (*ResourcesCreate) SetIsTop

func (rc *ResourcesCreate) SetIsTop(b bool) *ResourcesCreate

SetIsTop sets the "is_top" field.

func (*ResourcesCreate) SetName

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

SetName sets the "name" field.

func (*ResourcesCreate) SetNillableCreatedAt

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

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

func (*ResourcesCreate) SetNillableID

func (rc *ResourcesCreate) SetNillableID(s *string) *ResourcesCreate

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

func (*ResourcesCreate) SetNillableIcon

func (rc *ResourcesCreate) SetNillableIcon(s *string) *ResourcesCreate

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

func (*ResourcesCreate) SetNillableUpdatedAt

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

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

func (*ResourcesCreate) SetURL

func (rc *ResourcesCreate) SetURL(s string) *ResourcesCreate

SetURL sets the "url" field.

func (*ResourcesCreate) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

type ResourcesCreateBulk

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

ResourcesCreateBulk is the builder for creating many Resources entities in bulk.

func (*ResourcesCreateBulk) Exec

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

Exec executes the query.

func (*ResourcesCreateBulk) ExecX

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

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

func (*ResourcesCreateBulk) Save

func (rcb *ResourcesCreateBulk) Save(ctx context.Context) ([]*Resources, error)

Save creates the Resources entities in the database.

func (*ResourcesCreateBulk) SaveX

func (rcb *ResourcesCreateBulk) SaveX(ctx context.Context) []*Resources

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

type ResourcesDelete

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

ResourcesDelete is the builder for deleting a Resources entity.

func (*ResourcesDelete) Exec

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

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

func (*ResourcesDelete) ExecX

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

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

func (*ResourcesDelete) Where

Where appends a list predicates to the ResourcesDelete builder.

type ResourcesDeleteOne

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

ResourcesDeleteOne is the builder for deleting a single Resources entity.

func (*ResourcesDeleteOne) Exec

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

Exec executes the deletion query.

func (*ResourcesDeleteOne) ExecX

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

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

type ResourcesEdges

type ResourcesEdges struct {
	// Tag holds the value of the tag edge.
	Tag []*Tag `json:"tag,omitempty"`
	// contains filtered or unexported fields
}

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

func (ResourcesEdges) TagOrErr

func (e ResourcesEdges) TagOrErr() ([]*Tag, error)

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

type ResourcesGroupBy

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

ResourcesGroupBy is the group-by builder for Resources entities.

func (*ResourcesGroupBy) Aggregate

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

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

func (*ResourcesGroupBy) Bool

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) BoolX

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

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

func (*ResourcesGroupBy) Bools

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) BoolsX

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

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

func (*ResourcesGroupBy) Float64

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) Float64X

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

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

func (*ResourcesGroupBy) Float64s

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) Float64sX

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

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

func (*ResourcesGroupBy) Int

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) IntX

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

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

func (*ResourcesGroupBy) Ints

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) IntsX

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

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

func (*ResourcesGroupBy) Scan

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

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

func (*ResourcesGroupBy) ScanX

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

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

func (*ResourcesGroupBy) String

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) StringX

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

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

func (*ResourcesGroupBy) Strings

func (rgb *ResourcesGroupBy) 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 (*ResourcesGroupBy) StringsX

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

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

type ResourcesMutation

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

ResourcesMutation represents an operation that mutates the Resources nodes in the graph.

func (*ResourcesMutation) AddField

func (m *ResourcesMutation) 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 (*ResourcesMutation) AddTagIDs

func (m *ResourcesMutation) AddTagIDs(ids ...string)

AddTagIDs adds the "tag" edge to the Tag entity by ids.

func (*ResourcesMutation) AddedEdges

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

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

func (*ResourcesMutation) AddedField

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

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

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

func (*ResourcesMutation) AddedIDs

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

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

func (*ResourcesMutation) ClearEdge

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

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

func (m *ResourcesMutation) ClearIcon()

ClearIcon clears the value of the "icon" field.

func (*ResourcesMutation) ClearTag

func (m *ResourcesMutation) ClearTag()

ClearTag clears the "tag" edge to the Tag entity.

func (*ResourcesMutation) ClearedEdges

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

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

func (*ResourcesMutation) ClearedFields

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

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

func (ResourcesMutation) Client

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

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

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

func (*ResourcesMutation) Desc

func (m *ResourcesMutation) Desc() (r string, exists bool)

Desc returns the value of the "desc" field in the mutation.

func (*ResourcesMutation) EdgeCleared

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

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

func (*ResourcesMutation) Explain

func (m *ResourcesMutation) Explain() (r string, exists bool)

Explain returns the value of the "explain" field in the mutation.

func (*ResourcesMutation) Field

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

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

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

func (*ResourcesMutation) Fields

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

func (m *ResourcesMutation) ID() (id string, 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 (*ResourcesMutation) Icon

func (m *ResourcesMutation) Icon() (r string, exists bool)

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

func (*ResourcesMutation) IconCleared

func (m *ResourcesMutation) IconCleared() bool

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

func (*ResourcesMutation) IsTop

func (m *ResourcesMutation) IsTop() (r bool, exists bool)

IsTop returns the value of the "is_top" field in the mutation.

func (*ResourcesMutation) Name

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

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

func (*ResourcesMutation) OldCreatedAt

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

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

func (m *ResourcesMutation) OldDesc(ctx context.Context) (v string, err error)

OldDesc returns the old "desc" field's value of the Resources entity. If the Resources 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 (*ResourcesMutation) OldExplain

func (m *ResourcesMutation) OldExplain(ctx context.Context) (v string, err error)

OldExplain returns the old "explain" field's value of the Resources entity. If the Resources 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 (*ResourcesMutation) OldField

func (m *ResourcesMutation) 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 (*ResourcesMutation) OldIcon

func (m *ResourcesMutation) OldIcon(ctx context.Context) (v string, err error)

OldIcon returns the old "icon" field's value of the Resources entity. If the Resources 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 (*ResourcesMutation) OldIsTop

func (m *ResourcesMutation) OldIsTop(ctx context.Context) (v bool, err error)

OldIsTop returns the old "is_top" field's value of the Resources entity. If the Resources 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 (*ResourcesMutation) OldName

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

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

func (m *ResourcesMutation) OldURL(ctx context.Context) (v string, err error)

OldURL returns the old "url" field's value of the Resources entity. If the Resources 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 (*ResourcesMutation) OldUpdatedAt

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

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

func (m *ResourcesMutation) Op() Op

Op returns the operation name.

func (*ResourcesMutation) RemoveTagIDs

func (m *ResourcesMutation) RemoveTagIDs(ids ...string)

RemoveTagIDs removes the "tag" edge to the Tag entity by IDs.

func (*ResourcesMutation) RemovedEdges

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

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

func (*ResourcesMutation) RemovedIDs

func (m *ResourcesMutation) 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 (*ResourcesMutation) RemovedTagIDs

func (m *ResourcesMutation) RemovedTagIDs() (ids []string)

RemovedTag returns the removed IDs of the "tag" edge to the Tag entity.

func (*ResourcesMutation) ResetCreatedAt

func (m *ResourcesMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*ResourcesMutation) ResetDesc

func (m *ResourcesMutation) ResetDesc()

ResetDesc resets all changes to the "desc" field.

func (*ResourcesMutation) ResetEdge

func (m *ResourcesMutation) 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 (*ResourcesMutation) ResetExplain

func (m *ResourcesMutation) ResetExplain()

ResetExplain resets all changes to the "explain" field.

func (*ResourcesMutation) ResetField

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

func (m *ResourcesMutation) ResetIcon()

ResetIcon resets all changes to the "icon" field.

func (*ResourcesMutation) ResetIsTop

func (m *ResourcesMutation) ResetIsTop()

ResetIsTop resets all changes to the "is_top" field.

func (*ResourcesMutation) ResetName

func (m *ResourcesMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*ResourcesMutation) ResetTag

func (m *ResourcesMutation) ResetTag()

ResetTag resets all changes to the "tag" edge.

func (*ResourcesMutation) ResetURL

func (m *ResourcesMutation) ResetURL()

ResetURL resets all changes to the "url" field.

func (*ResourcesMutation) ResetUpdatedAt

func (m *ResourcesMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*ResourcesMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*ResourcesMutation) SetDesc

func (m *ResourcesMutation) SetDesc(s string)

SetDesc sets the "desc" field.

func (*ResourcesMutation) SetExplain

func (m *ResourcesMutation) SetExplain(s string)

SetExplain sets the "explain" field.

func (*ResourcesMutation) SetField

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

func (m *ResourcesMutation) SetID(id string)

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

func (*ResourcesMutation) SetIcon

func (m *ResourcesMutation) SetIcon(s string)

SetIcon sets the "icon" field.

func (*ResourcesMutation) SetIsTop

func (m *ResourcesMutation) SetIsTop(b bool)

SetIsTop sets the "is_top" field.

func (*ResourcesMutation) SetName

func (m *ResourcesMutation) SetName(s string)

SetName sets the "name" field.

func (*ResourcesMutation) SetURL

func (m *ResourcesMutation) SetURL(s string)

SetURL sets the "url" field.

func (*ResourcesMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*ResourcesMutation) TagCleared

func (m *ResourcesMutation) TagCleared() bool

TagCleared reports if the "tag" edge to the Tag entity was cleared.

func (*ResourcesMutation) TagIDs

func (m *ResourcesMutation) TagIDs() (ids []string)

TagIDs returns the "tag" edge IDs in the mutation.

func (ResourcesMutation) Tx

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

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

func (*ResourcesMutation) Type

func (m *ResourcesMutation) Type() string

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

func (*ResourcesMutation) URL

func (m *ResourcesMutation) URL() (r string, exists bool)

URL returns the value of the "url" field in the mutation.

func (*ResourcesMutation) UpdatedAt

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

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

func (*ResourcesMutation) Where

func (m *ResourcesMutation) Where(ps ...predicate.Resources)

Where appends a list predicates to the ResourcesMutation builder.

type ResourcesQuery

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

ResourcesQuery is the builder for querying Resources entities.

func (*ResourcesQuery) All

func (rq *ResourcesQuery) All(ctx context.Context) ([]*Resources, error)

All executes the query and returns a list of ResourcesSlice.

func (*ResourcesQuery) AllX

func (rq *ResourcesQuery) AllX(ctx context.Context) []*Resources

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

func (*ResourcesQuery) Clone

func (rq *ResourcesQuery) Clone() *ResourcesQuery

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

func (*ResourcesQuery) Count

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

Count returns the count of the given query.

func (*ResourcesQuery) CountX

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

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

func (*ResourcesQuery) Exist

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

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

func (*ResourcesQuery) ExistX

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

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

func (*ResourcesQuery) First

func (rq *ResourcesQuery) First(ctx context.Context) (*Resources, error)

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

func (*ResourcesQuery) FirstID

func (rq *ResourcesQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*ResourcesQuery) FirstIDX

func (rq *ResourcesQuery) FirstIDX(ctx context.Context) string

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

func (*ResourcesQuery) FirstX

func (rq *ResourcesQuery) FirstX(ctx context.Context) *Resources

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

func (*ResourcesQuery) GroupBy

func (rq *ResourcesQuery) GroupBy(field string, fields ...string) *ResourcesGroupBy

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

Example:

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

client.Resources.Query().
	GroupBy(resources.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ResourcesQuery) IDs

func (rq *ResourcesQuery) IDs(ctx context.Context) ([]string, error)

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

func (*ResourcesQuery) IDsX

func (rq *ResourcesQuery) IDsX(ctx context.Context) []string

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

func (*ResourcesQuery) Limit

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

Limit adds a limit step to the query.

func (*ResourcesQuery) Offset

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

Offset adds an offset step to the query.

func (*ResourcesQuery) Only

func (rq *ResourcesQuery) Only(ctx context.Context) (*Resources, error)

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

func (*ResourcesQuery) OnlyID

func (rq *ResourcesQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*ResourcesQuery) OnlyIDX

func (rq *ResourcesQuery) OnlyIDX(ctx context.Context) string

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

func (*ResourcesQuery) OnlyX

func (rq *ResourcesQuery) OnlyX(ctx context.Context) *Resources

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

func (*ResourcesQuery) Order

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

Order adds an order step to the query.

func (*ResourcesQuery) QueryTag

func (rq *ResourcesQuery) QueryTag() *TagQuery

QueryTag chains the current query on the "tag" edge.

func (*ResourcesQuery) Select

func (rq *ResourcesQuery) Select(fields ...string) *ResourcesSelect

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

Example:

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

client.Resources.Query().
	Select(resources.FieldName).
	Scan(ctx, &v)

func (*ResourcesQuery) Unique

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

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

Where adds a new predicate for the ResourcesQuery builder.

func (*ResourcesQuery) WithTag

func (rq *ResourcesQuery) WithTag(opts ...func(*TagQuery)) *ResourcesQuery

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

type ResourcesSelect

type ResourcesSelect struct {
	*ResourcesQuery
	// contains filtered or unexported fields
}

ResourcesSelect is the builder for selecting fields of Resources entities.

func (*ResourcesSelect) Bool

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

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

func (*ResourcesSelect) BoolX

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

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

func (*ResourcesSelect) Bools

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

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

func (*ResourcesSelect) BoolsX

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

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

func (*ResourcesSelect) Float64

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

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

func (*ResourcesSelect) Float64X

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

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

func (*ResourcesSelect) Float64s

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

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

func (*ResourcesSelect) Float64sX

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

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

func (*ResourcesSelect) Int

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

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

func (*ResourcesSelect) IntX

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

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

func (*ResourcesSelect) Ints

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

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

func (*ResourcesSelect) IntsX

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

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

func (*ResourcesSelect) Scan

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

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

func (*ResourcesSelect) ScanX

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

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

func (*ResourcesSelect) String

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

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

func (*ResourcesSelect) StringX

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

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

func (*ResourcesSelect) Strings

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

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

func (*ResourcesSelect) StringsX

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

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

type ResourcesSlice

type ResourcesSlice []*Resources

ResourcesSlice is a parsable slice of Resources.

type ResourcesUpdate

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

ResourcesUpdate is the builder for updating Resources entities.

func (*ResourcesUpdate) AddTag

func (ru *ResourcesUpdate) AddTag(t ...*Tag) *ResourcesUpdate

AddTag adds the "tag" edges to the Tag entity.

func (*ResourcesUpdate) AddTagIDs

func (ru *ResourcesUpdate) AddTagIDs(ids ...string) *ResourcesUpdate

AddTagIDs adds the "tag" edge to the Tag entity by IDs.

func (*ResourcesUpdate) ClearIcon

func (ru *ResourcesUpdate) ClearIcon() *ResourcesUpdate

ClearIcon clears the value of the "icon" field.

func (*ResourcesUpdate) ClearTag

func (ru *ResourcesUpdate) ClearTag() *ResourcesUpdate

ClearTag clears all "tag" edges to the Tag entity.

func (*ResourcesUpdate) Exec

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

Exec executes the query.

func (*ResourcesUpdate) ExecX

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

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

func (*ResourcesUpdate) Mutation

func (ru *ResourcesUpdate) Mutation() *ResourcesMutation

Mutation returns the ResourcesMutation object of the builder.

func (*ResourcesUpdate) RemoveTag

func (ru *ResourcesUpdate) RemoveTag(t ...*Tag) *ResourcesUpdate

RemoveTag removes "tag" edges to Tag entities.

func (*ResourcesUpdate) RemoveTagIDs

func (ru *ResourcesUpdate) RemoveTagIDs(ids ...string) *ResourcesUpdate

RemoveTagIDs removes the "tag" edge to Tag entities by IDs.

func (*ResourcesUpdate) Save

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

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

func (*ResourcesUpdate) SaveX

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

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

func (*ResourcesUpdate) SetCreatedAt

func (ru *ResourcesUpdate) SetCreatedAt(t time.Time) *ResourcesUpdate

SetCreatedAt sets the "created_at" field.

func (*ResourcesUpdate) SetDesc

func (ru *ResourcesUpdate) SetDesc(s string) *ResourcesUpdate

SetDesc sets the "desc" field.

func (*ResourcesUpdate) SetExplain

func (ru *ResourcesUpdate) SetExplain(s string) *ResourcesUpdate

SetExplain sets the "explain" field.

func (*ResourcesUpdate) SetIcon

func (ru *ResourcesUpdate) SetIcon(s string) *ResourcesUpdate

SetIcon sets the "icon" field.

func (*ResourcesUpdate) SetIsTop

func (ru *ResourcesUpdate) SetIsTop(b bool) *ResourcesUpdate

SetIsTop sets the "is_top" field.

func (*ResourcesUpdate) SetName

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

SetName sets the "name" field.

func (*ResourcesUpdate) SetNillableCreatedAt

func (ru *ResourcesUpdate) SetNillableCreatedAt(t *time.Time) *ResourcesUpdate

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

func (*ResourcesUpdate) SetNillableIcon

func (ru *ResourcesUpdate) SetNillableIcon(s *string) *ResourcesUpdate

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

func (*ResourcesUpdate) SetURL

func (ru *ResourcesUpdate) SetURL(s string) *ResourcesUpdate

SetURL sets the "url" field.

func (*ResourcesUpdate) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*ResourcesUpdate) Where

Where appends a list predicates to the ResourcesUpdate builder.

type ResourcesUpdateOne

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

ResourcesUpdateOne is the builder for updating a single Resources entity.

func (*ResourcesUpdateOne) AddTag

func (ruo *ResourcesUpdateOne) AddTag(t ...*Tag) *ResourcesUpdateOne

AddTag adds the "tag" edges to the Tag entity.

func (*ResourcesUpdateOne) AddTagIDs

func (ruo *ResourcesUpdateOne) AddTagIDs(ids ...string) *ResourcesUpdateOne

AddTagIDs adds the "tag" edge to the Tag entity by IDs.

func (*ResourcesUpdateOne) ClearIcon

func (ruo *ResourcesUpdateOne) ClearIcon() *ResourcesUpdateOne

ClearIcon clears the value of the "icon" field.

func (*ResourcesUpdateOne) ClearTag

func (ruo *ResourcesUpdateOne) ClearTag() *ResourcesUpdateOne

ClearTag clears all "tag" edges to the Tag entity.

func (*ResourcesUpdateOne) Exec

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

Exec executes the query on the entity.

func (*ResourcesUpdateOne) ExecX

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

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

func (*ResourcesUpdateOne) Mutation

func (ruo *ResourcesUpdateOne) Mutation() *ResourcesMutation

Mutation returns the ResourcesMutation object of the builder.

func (*ResourcesUpdateOne) RemoveTag

func (ruo *ResourcesUpdateOne) RemoveTag(t ...*Tag) *ResourcesUpdateOne

RemoveTag removes "tag" edges to Tag entities.

func (*ResourcesUpdateOne) RemoveTagIDs

func (ruo *ResourcesUpdateOne) RemoveTagIDs(ids ...string) *ResourcesUpdateOne

RemoveTagIDs removes the "tag" edge to Tag entities by IDs.

func (*ResourcesUpdateOne) Save

func (ruo *ResourcesUpdateOne) Save(ctx context.Context) (*Resources, error)

Save executes the query and returns the updated Resources entity.

func (*ResourcesUpdateOne) SaveX

func (ruo *ResourcesUpdateOne) SaveX(ctx context.Context) *Resources

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

func (*ResourcesUpdateOne) Select

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

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

func (*ResourcesUpdateOne) SetCreatedAt

func (ruo *ResourcesUpdateOne) SetCreatedAt(t time.Time) *ResourcesUpdateOne

SetCreatedAt sets the "created_at" field.

func (*ResourcesUpdateOne) SetDesc

func (ruo *ResourcesUpdateOne) SetDesc(s string) *ResourcesUpdateOne

SetDesc sets the "desc" field.

func (*ResourcesUpdateOne) SetExplain

func (ruo *ResourcesUpdateOne) SetExplain(s string) *ResourcesUpdateOne

SetExplain sets the "explain" field.

func (*ResourcesUpdateOne) SetIcon

func (ruo *ResourcesUpdateOne) SetIcon(s string) *ResourcesUpdateOne

SetIcon sets the "icon" field.

func (*ResourcesUpdateOne) SetIsTop

func (ruo *ResourcesUpdateOne) SetIsTop(b bool) *ResourcesUpdateOne

SetIsTop sets the "is_top" field.

func (*ResourcesUpdateOne) SetName

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

SetName sets the "name" field.

func (*ResourcesUpdateOne) SetNillableCreatedAt

func (ruo *ResourcesUpdateOne) SetNillableCreatedAt(t *time.Time) *ResourcesUpdateOne

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

func (*ResourcesUpdateOne) SetNillableIcon

func (ruo *ResourcesUpdateOne) SetNillableIcon(s *string) *ResourcesUpdateOne

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

func (*ResourcesUpdateOne) SetURL

SetURL sets the "url" field.

func (*ResourcesUpdateOne) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

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 Tag

type Tag struct {

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

Tag is the model entity for the Tag schema.

func (*Tag) QueryResources

func (t *Tag) QueryResources() *ResourcesQuery

QueryResources queries the "resources" edge of the Tag entity.

func (*Tag) String

func (t *Tag) String() string

String implements the fmt.Stringer.

func (*Tag) Unwrap

func (t *Tag) Unwrap() *Tag

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

func (*Tag) Update

func (t *Tag) Update() *TagUpdateOne

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

type TagClient

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

TagClient is a client for the Tag schema.

func NewTagClient

func NewTagClient(c config) *TagClient

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

func (*TagClient) Create

func (c *TagClient) Create() *TagCreate

Create returns a create builder for Tag.

func (*TagClient) CreateBulk

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

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

func (*TagClient) Delete

func (c *TagClient) Delete() *TagDelete

Delete returns a delete builder for Tag.

func (*TagClient) DeleteOne

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

DeleteOne returns a delete builder for the given entity.

func (*TagClient) DeleteOneID

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

DeleteOneID returns a delete builder for the given id.

func (*TagClient) Get

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

Get returns a Tag entity by its id.

func (*TagClient) GetX

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

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

func (*TagClient) Hooks

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

Hooks returns the client hooks.

func (*TagClient) Query

func (c *TagClient) Query() *TagQuery

Query returns a query builder for Tag.

func (*TagClient) QueryResources

func (c *TagClient) QueryResources(t *Tag) *ResourcesQuery

QueryResources queries the resources edge of a Tag.

func (*TagClient) Update

func (c *TagClient) Update() *TagUpdate

Update returns an update builder for Tag.

func (*TagClient) UpdateOne

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

UpdateOne returns an update builder for the given entity.

func (*TagClient) UpdateOneID

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

UpdateOneID returns an update builder for the given id.

func (*TagClient) Use

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

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

type TagCreate

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

TagCreate is the builder for creating a Tag entity.

func (*TagCreate) AddResourceIDs

func (tc *TagCreate) AddResourceIDs(ids ...string) *TagCreate

AddResourceIDs adds the "resources" edge to the Resources entity by IDs.

func (*TagCreate) AddResources

func (tc *TagCreate) AddResources(r ...*Resources) *TagCreate

AddResources adds the "resources" edges to the Resources entity.

func (*TagCreate) Exec

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

Exec executes the query.

func (*TagCreate) ExecX

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

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

func (*TagCreate) Mutation

func (tc *TagCreate) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagCreate) Save

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

Save creates the Tag in the database.

func (*TagCreate) SaveX

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

SaveX calls Save and panics if Save returns an error.

func (*TagCreate) SetID

func (tc *TagCreate) SetID(s string) *TagCreate

SetID sets the "id" field.

func (*TagCreate) SetNillableID

func (tc *TagCreate) SetNillableID(s *string) *TagCreate

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

func (*TagCreate) SetTag

func (tc *TagCreate) SetTag(s string) *TagCreate

SetTag sets the "tag" field.

type TagCreateBulk

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

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

func (*TagCreateBulk) Exec

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

Exec executes the query.

func (*TagCreateBulk) ExecX

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

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

func (*TagCreateBulk) Save

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

Save creates the Tag entities in the database.

func (*TagCreateBulk) SaveX

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

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

type TagDelete

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

TagDelete is the builder for deleting a Tag entity.

func (*TagDelete) Exec

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

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

func (*TagDelete) ExecX

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

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

func (*TagDelete) Where

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

Where appends a list predicates to the TagDelete builder.

type TagDeleteOne

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

TagDeleteOne is the builder for deleting a single Tag entity.

func (*TagDeleteOne) Exec

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

Exec executes the deletion query.

func (*TagDeleteOne) ExecX

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

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

type TagEdges

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

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

func (TagEdges) ResourcesOrErr

func (e TagEdges) ResourcesOrErr() ([]*Resources, error)

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

type TagGroupBy

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

TagGroupBy is the group-by builder for Tag entities.

func (*TagGroupBy) Aggregate

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

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

func (*TagGroupBy) Bool

func (tgb *TagGroupBy) 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 (*TagGroupBy) BoolX

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

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

func (*TagGroupBy) Bools

func (tgb *TagGroupBy) 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 (*TagGroupBy) BoolsX

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

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

func (*TagGroupBy) Float64

func (tgb *TagGroupBy) 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 (*TagGroupBy) Float64X

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

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

func (*TagGroupBy) Float64s

func (tgb *TagGroupBy) 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 (*TagGroupBy) Float64sX

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

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

func (*TagGroupBy) Int

func (tgb *TagGroupBy) 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 (*TagGroupBy) IntX

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

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

func (*TagGroupBy) Ints

func (tgb *TagGroupBy) 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 (*TagGroupBy) IntsX

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

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

func (*TagGroupBy) Scan

func (tgb *TagGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*TagGroupBy) ScanX

func (tgb *TagGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*TagGroupBy) String

func (tgb *TagGroupBy) 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 (*TagGroupBy) StringX

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

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

func (*TagGroupBy) Strings

func (tgb *TagGroupBy) 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 (*TagGroupBy) StringsX

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

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

type TagMutation

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

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

func (*TagMutation) AddField

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

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

func (*TagMutation) AddResourceIDs

func (m *TagMutation) AddResourceIDs(ids ...string)

AddResourceIDs adds the "resources" edge to the Resources entity by ids.

func (*TagMutation) AddedEdges

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

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

func (*TagMutation) AddedField

func (m *TagMutation) AddedField(name string) (ent.Value, bool)

AddedField returns the numeric value that was incremented/decremented on a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*TagMutation) AddedFields

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

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

func (*TagMutation) AddedIDs

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

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

func (*TagMutation) ClearEdge

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

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

func (*TagMutation) ClearField

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

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

func (*TagMutation) ClearResources

func (m *TagMutation) ClearResources()

ClearResources clears the "resources" edge to the Resources entity.

func (*TagMutation) ClearedEdges

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

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

func (*TagMutation) ClearedFields

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

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

func (TagMutation) Client

func (m TagMutation) Client() *Client

Client returns a new `ent.Client` from the mutation. If the mutation was executed in a transaction (ent.Tx), a transactional client is returned.

func (*TagMutation) EdgeCleared

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

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

func (*TagMutation) Field

func (m *TagMutation) Field(name string) (ent.Value, bool)

Field returns the value of a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*TagMutation) FieldCleared

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

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

func (*TagMutation) Fields

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

Fields returns all fields that were changed during this mutation. Note that in order to get all numeric fields that were incremented/decremented, call AddedFields().

func (*TagMutation) ID

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

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

func (*TagMutation) OldField

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

OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database failed.

func (*TagMutation) OldTag

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

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

func (*TagMutation) Op

func (m *TagMutation) Op() Op

Op returns the operation name.

func (*TagMutation) RemoveResourceIDs

func (m *TagMutation) RemoveResourceIDs(ids ...string)

RemoveResourceIDs removes the "resources" edge to the Resources entity by IDs.

func (*TagMutation) RemovedEdges

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

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

func (*TagMutation) RemovedIDs

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

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

func (*TagMutation) RemovedResourcesIDs

func (m *TagMutation) RemovedResourcesIDs() (ids []string)

RemovedResources returns the removed IDs of the "resources" edge to the Resources entity.

func (*TagMutation) ResetEdge

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

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

func (*TagMutation) ResetField

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

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

func (*TagMutation) ResetResources

func (m *TagMutation) ResetResources()

ResetResources resets all changes to the "resources" edge.

func (*TagMutation) ResetTag

func (m *TagMutation) ResetTag()

ResetTag resets all changes to the "tag" field.

func (*TagMutation) ResourcesCleared

func (m *TagMutation) ResourcesCleared() bool

ResourcesCleared reports if the "resources" edge to the Resources entity was cleared.

func (*TagMutation) ResourcesIDs

func (m *TagMutation) ResourcesIDs() (ids []string)

ResourcesIDs returns the "resources" edge IDs in the mutation.

func (*TagMutation) SetField

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

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

func (*TagMutation) SetID

func (m *TagMutation) SetID(id string)

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

func (*TagMutation) SetTag

func (m *TagMutation) SetTag(s string)

SetTag sets the "tag" field.

func (*TagMutation) Tag

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

Tag returns the value of the "tag" field in the mutation.

func (TagMutation) Tx

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

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

func (*TagMutation) Type

func (m *TagMutation) Type() string

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

func (*TagMutation) Where

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

Where appends a list predicates to the TagMutation builder.

type TagQuery

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

TagQuery is the builder for querying Tag entities.

func (*TagQuery) All

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

All executes the query and returns a list of Tags.

func (*TagQuery) AllX

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

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

func (*TagQuery) Clone

func (tq *TagQuery) Clone() *TagQuery

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

func (*TagQuery) Count

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

Count returns the count of the given query.

func (*TagQuery) CountX

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

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

func (*TagQuery) Exist

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

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

func (*TagQuery) ExistX

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

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

func (*TagQuery) First

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

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

func (*TagQuery) FirstID

func (tq *TagQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*TagQuery) FirstIDX

func (tq *TagQuery) FirstIDX(ctx context.Context) string

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

func (*TagQuery) FirstX

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

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

func (*TagQuery) GroupBy

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

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

Example:

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

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

func (*TagQuery) IDs

func (tq *TagQuery) IDs(ctx context.Context) ([]string, error)

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

func (*TagQuery) IDsX

func (tq *TagQuery) IDsX(ctx context.Context) []string

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

func (*TagQuery) Limit

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

Limit adds a limit step to the query.

func (*TagQuery) Offset

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

Offset adds an offset step to the query.

func (*TagQuery) Only

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

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

func (*TagQuery) OnlyID

func (tq *TagQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*TagQuery) OnlyIDX

func (tq *TagQuery) OnlyIDX(ctx context.Context) string

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

func (*TagQuery) OnlyX

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

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

func (*TagQuery) Order

func (tq *TagQuery) Order(o ...OrderFunc) *TagQuery

Order adds an order step to the query.

func (*TagQuery) QueryResources

func (tq *TagQuery) QueryResources() *ResourcesQuery

QueryResources chains the current query on the "resources" edge.

func (*TagQuery) Select

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

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

Example:

var v []struct {
	Tag string `json:"tag,omitempty"`
}

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

func (*TagQuery) Unique

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

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

func (*TagQuery) Where

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

Where adds a new predicate for the TagQuery builder.

func (*TagQuery) WithResources

func (tq *TagQuery) WithResources(opts ...func(*ResourcesQuery)) *TagQuery

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

type TagSelect

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

TagSelect is the builder for selecting fields of Tag entities.

func (*TagSelect) Bool

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

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

func (*TagSelect) BoolX

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

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

func (*TagSelect) Bools

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

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

func (*TagSelect) BoolsX

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

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

func (*TagSelect) Float64

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

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

func (*TagSelect) Float64X

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

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

func (*TagSelect) Float64s

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

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

func (*TagSelect) Float64sX

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

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

func (*TagSelect) Int

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

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

func (*TagSelect) IntX

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

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

func (*TagSelect) Ints

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

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

func (*TagSelect) IntsX

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

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

func (*TagSelect) Scan

func (ts *TagSelect) Scan(ctx context.Context, v interface{}) error

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

func (*TagSelect) ScanX

func (ts *TagSelect) ScanX(ctx context.Context, v interface{})

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

func (*TagSelect) String

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

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

func (*TagSelect) StringX

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

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

func (*TagSelect) Strings

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

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

func (*TagSelect) StringsX

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

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

type TagUpdate

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

TagUpdate is the builder for updating Tag entities.

func (*TagUpdate) AddResourceIDs

func (tu *TagUpdate) AddResourceIDs(ids ...string) *TagUpdate

AddResourceIDs adds the "resources" edge to the Resources entity by IDs.

func (*TagUpdate) AddResources

func (tu *TagUpdate) AddResources(r ...*Resources) *TagUpdate

AddResources adds the "resources" edges to the Resources entity.

func (*TagUpdate) ClearResources

func (tu *TagUpdate) ClearResources() *TagUpdate

ClearResources clears all "resources" edges to the Resources entity.

func (*TagUpdate) Exec

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

Exec executes the query.

func (*TagUpdate) ExecX

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

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

func (*TagUpdate) Mutation

func (tu *TagUpdate) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagUpdate) RemoveResourceIDs

func (tu *TagUpdate) RemoveResourceIDs(ids ...string) *TagUpdate

RemoveResourceIDs removes the "resources" edge to Resources entities by IDs.

func (*TagUpdate) RemoveResources

func (tu *TagUpdate) RemoveResources(r ...*Resources) *TagUpdate

RemoveResources removes "resources" edges to Resources entities.

func (*TagUpdate) Save

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

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

func (*TagUpdate) SaveX

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

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

func (*TagUpdate) SetTag

func (tu *TagUpdate) SetTag(s string) *TagUpdate

SetTag sets the "tag" field.

func (*TagUpdate) Where

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

Where appends a list predicates to the TagUpdate builder.

type TagUpdateOne

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

TagUpdateOne is the builder for updating a single Tag entity.

func (*TagUpdateOne) AddResourceIDs

func (tuo *TagUpdateOne) AddResourceIDs(ids ...string) *TagUpdateOne

AddResourceIDs adds the "resources" edge to the Resources entity by IDs.

func (*TagUpdateOne) AddResources

func (tuo *TagUpdateOne) AddResources(r ...*Resources) *TagUpdateOne

AddResources adds the "resources" edges to the Resources entity.

func (*TagUpdateOne) ClearResources

func (tuo *TagUpdateOne) ClearResources() *TagUpdateOne

ClearResources clears all "resources" edges to the Resources entity.

func (*TagUpdateOne) Exec

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

Exec executes the query on the entity.

func (*TagUpdateOne) ExecX

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

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

func (*TagUpdateOne) Mutation

func (tuo *TagUpdateOne) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagUpdateOne) RemoveResourceIDs

func (tuo *TagUpdateOne) RemoveResourceIDs(ids ...string) *TagUpdateOne

RemoveResourceIDs removes the "resources" edge to Resources entities by IDs.

func (*TagUpdateOne) RemoveResources

func (tuo *TagUpdateOne) RemoveResources(r ...*Resources) *TagUpdateOne

RemoveResources removes "resources" edges to Resources entities.

func (*TagUpdateOne) Save

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

Save executes the query and returns the updated Tag entity.

func (*TagUpdateOne) SaveX

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

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

func (*TagUpdateOne) Select

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

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

func (*TagUpdateOne) SetTag

func (tuo *TagUpdateOne) SetTag(s string) *TagUpdateOne

SetTag sets the "tag" field.

type Tags

type Tags []*Tag

Tags is a parsable slice of Tag.

type Tx

type Tx struct {

	// Resources is the client for interacting with the Resources builders.
	Resources *ResourcesClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// contains filtered or unexported fields
}

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

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

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

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type User

type User struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Password holds the value of the "password" field.
	Password string `json:"password,omitempty"`
	// UserType holds the value of the "user_type" field.
	UserType user.UserType `json:"user_type,omitempty"`
	// contains filtered or unexported fields
}

User is the model entity for the User schema.

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 string) *UserDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*UserClient) Get

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

Get returns a User entity by its id.

func (*UserClient) GetX

func (c *UserClient) GetX(ctx context.Context, id string) *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) 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 string) *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) 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) SetID

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

SetID sets the "id" field.

func (*UserCreate) SetName

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

SetName sets the "name" field.

func (*UserCreate) SetNillableID

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

SetNillableID sets the "id" 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) SetUserType

func (uc *UserCreate) SetUserType(ut user.UserType) *UserCreate

SetUserType sets the "user_type" 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 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) AddedEdges

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

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

func (*UserMutation) AddedField

func (m *UserMutation) AddedField(name string) (ent.Value, bool)

AddedField returns the numeric value that was incremented/decremented on a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*UserMutation) AddedFields

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

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

func (*UserMutation) AddedIDs

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

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

func (*UserMutation) ClearEdge

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

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

func (*UserMutation) ClearField

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

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

func (*UserMutation) 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) 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 string, 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) Name

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

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

func (*UserMutation) OldField

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

OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database failed.

func (*UserMutation) OldName

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

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

func (*UserMutation) OldPassword

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

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

func (*UserMutation) OldUserType

func (m *UserMutation) OldUserType(ctx context.Context) (v user.UserType, err error)

OldUserType returns the old "user_type" 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) 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) 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) ResetName

func (m *UserMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*UserMutation) ResetPassword

func (m *UserMutation) ResetPassword()

ResetPassword resets all changes to the "password" field.

func (*UserMutation) ResetUserType

func (m *UserMutation) ResetUserType()

ResetUserType resets all changes to the "user_type" 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 string)

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

func (*UserMutation) SetName

func (m *UserMutation) SetName(s string)

SetName sets the "name" field.

func (*UserMutation) SetPassword

func (m *UserMutation) SetPassword(s string)

SetPassword sets the "password" field.

func (*UserMutation) SetUserType

func (m *UserMutation) SetUserType(ut user.UserType)

SetUserType sets the "user_type" field.

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) UserType

func (m *UserMutation) UserType() (r user.UserType, exists bool)

UserType returns the value of the "user_type" 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 string, 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) string

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

func (*UserQuery) FirstX

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

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

func (*UserQuery) GroupBy

func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy

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

Example:

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

client.User.Query().
	GroupBy(user.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserQuery) IDs

func (uq *UserQuery) IDs(ctx context.Context) ([]string, error)

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

func (*UserQuery) IDsX

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

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 string, 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) string

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

func (uq *UserQuery) Select(fields ...string) *UserSelect

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

Example:

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

client.User.Query().
	Select(user.FieldName).
	Scan(ctx, &v)

func (*UserQuery) Unique

func (uq *UserQuery) Unique(unique bool) *UserQuery

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

func (*UserQuery) Where

func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

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

func (uu *UserUpdate) SetName(s string) *UserUpdate

SetName sets the "name" field.

func (*UserUpdate) SetPassword

func (uu *UserUpdate) SetPassword(s string) *UserUpdate

SetPassword sets the "password" field.

func (*UserUpdate) SetUserType

func (uu *UserUpdate) SetUserType(ut user.UserType) *UserUpdate

SetUserType sets the "user_type" 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) 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) 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) SetName

func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne

SetName sets the "name" field.

func (*UserUpdateOne) SetPassword

func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne

SetPassword sets the "password" field.

func (*UserUpdateOne) SetUserType

func (uuo *UserUpdateOne) SetUserType(ut user.UserType) *UserUpdateOne

SetUserType sets the "user_type" 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