ent

package
v0.0.0-...-1413bf2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 17 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.
	TypeTodoItem = "TodoItem"
)

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
	// TodoItem is the client for interacting with the TodoItem builders.
	TodoItem *TodoItemClient
	// 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().
	TodoItem.
	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 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 TodoItem

type TodoItem struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// UID holds the value of the "uid" field.
	UID string `json:"uid,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Completed holds the value of the "completed" field.
	Completed bool `json:"completed,omitempty"`
	// Order holds the value of the "order" field.
	Order int `json:"order,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"`
	// contains filtered or unexported fields
}

TodoItem is the model entity for the TodoItem schema.

func (*TodoItem) String

func (ti *TodoItem) String() string

String implements the fmt.Stringer.

func (*TodoItem) Unwrap

func (ti *TodoItem) Unwrap() *TodoItem

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

func (ti *TodoItem) Update() *TodoItemUpdateOne

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

type TodoItemClient

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

TodoItemClient is a client for the TodoItem schema.

func NewTodoItemClient

func NewTodoItemClient(c config) *TodoItemClient

NewTodoItemClient returns a client for the TodoItem from the given config.

func (*TodoItemClient) Create

func (c *TodoItemClient) Create() *TodoItemCreate

Create returns a create builder for TodoItem.

func (*TodoItemClient) CreateBulk

func (c *TodoItemClient) CreateBulk(builders ...*TodoItemCreate) *TodoItemCreateBulk

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

func (*TodoItemClient) Delete

func (c *TodoItemClient) Delete() *TodoItemDelete

Delete returns a delete builder for TodoItem.

func (*TodoItemClient) DeleteOne

func (c *TodoItemClient) DeleteOne(ti *TodoItem) *TodoItemDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*TodoItemClient) DeleteOneID

func (c *TodoItemClient) DeleteOneID(id int) *TodoItemDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*TodoItemClient) Get

func (c *TodoItemClient) Get(ctx context.Context, id int) (*TodoItem, error)

Get returns a TodoItem entity by its id.

func (*TodoItemClient) GetX

func (c *TodoItemClient) GetX(ctx context.Context, id int) *TodoItem

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

func (*TodoItemClient) Hooks

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

Hooks returns the client hooks.

func (*TodoItemClient) Query

func (c *TodoItemClient) Query() *TodoItemQuery

Query returns a query builder for TodoItem.

func (*TodoItemClient) Update

func (c *TodoItemClient) Update() *TodoItemUpdate

Update returns an update builder for TodoItem.

func (*TodoItemClient) UpdateOne

func (c *TodoItemClient) UpdateOne(ti *TodoItem) *TodoItemUpdateOne

UpdateOne returns an update builder for the given entity.

func (*TodoItemClient) UpdateOneID

func (c *TodoItemClient) UpdateOneID(id int) *TodoItemUpdateOne

UpdateOneID returns an update builder for the given id.

func (*TodoItemClient) Use

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

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

type TodoItemCreate

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

TodoItemCreate is the builder for creating a TodoItem entity.

func (*TodoItemCreate) Exec

func (tic *TodoItemCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*TodoItemCreate) ExecX

func (tic *TodoItemCreate) ExecX(ctx context.Context)

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

func (*TodoItemCreate) Mutation

func (tic *TodoItemCreate) Mutation() *TodoItemMutation

Mutation returns the TodoItemMutation object of the builder.

func (*TodoItemCreate) Save

func (tic *TodoItemCreate) Save(ctx context.Context) (*TodoItem, error)

Save creates the TodoItem in the database.

func (*TodoItemCreate) SaveX

func (tic *TodoItemCreate) SaveX(ctx context.Context) *TodoItem

SaveX calls Save and panics if Save returns an error.

func (*TodoItemCreate) SetCompleted

func (tic *TodoItemCreate) SetCompleted(b bool) *TodoItemCreate

SetCompleted sets the "completed" field.

func (*TodoItemCreate) SetCreatedAt

func (tic *TodoItemCreate) SetCreatedAt(t time.Time) *TodoItemCreate

SetCreatedAt sets the "created_at" field.

func (*TodoItemCreate) SetNillableCreatedAt

func (tic *TodoItemCreate) SetNillableCreatedAt(t *time.Time) *TodoItemCreate

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

func (*TodoItemCreate) SetNillableUpdatedAt

func (tic *TodoItemCreate) SetNillableUpdatedAt(t *time.Time) *TodoItemCreate

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

func (*TodoItemCreate) SetOrder

func (tic *TodoItemCreate) SetOrder(i int) *TodoItemCreate

SetOrder sets the "order" field.

func (*TodoItemCreate) SetTitle

func (tic *TodoItemCreate) SetTitle(s string) *TodoItemCreate

SetTitle sets the "title" field.

func (*TodoItemCreate) SetUID

func (tic *TodoItemCreate) SetUID(s string) *TodoItemCreate

SetUID sets the "uid" field.

func (*TodoItemCreate) SetUpdatedAt

func (tic *TodoItemCreate) SetUpdatedAt(t time.Time) *TodoItemCreate

SetUpdatedAt sets the "updated_at" field.

type TodoItemCreateBulk

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

TodoItemCreateBulk is the builder for creating many TodoItem entities in bulk.

func (*TodoItemCreateBulk) Exec

func (ticb *TodoItemCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*TodoItemCreateBulk) ExecX

func (ticb *TodoItemCreateBulk) ExecX(ctx context.Context)

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

func (*TodoItemCreateBulk) Save

func (ticb *TodoItemCreateBulk) Save(ctx context.Context) ([]*TodoItem, error)

Save creates the TodoItem entities in the database.

func (*TodoItemCreateBulk) SaveX

func (ticb *TodoItemCreateBulk) SaveX(ctx context.Context) []*TodoItem

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

type TodoItemDelete

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

TodoItemDelete is the builder for deleting a TodoItem entity.

func (*TodoItemDelete) Exec

func (tid *TodoItemDelete) Exec(ctx context.Context) (int, error)

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

func (*TodoItemDelete) ExecX

func (tid *TodoItemDelete) ExecX(ctx context.Context) int

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

func (*TodoItemDelete) Where

func (tid *TodoItemDelete) Where(ps ...predicate.TodoItem) *TodoItemDelete

Where appends a list predicates to the TodoItemDelete builder.

type TodoItemDeleteOne

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

TodoItemDeleteOne is the builder for deleting a single TodoItem entity.

func (*TodoItemDeleteOne) Exec

func (tido *TodoItemDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*TodoItemDeleteOne) ExecX

func (tido *TodoItemDeleteOne) ExecX(ctx context.Context)

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

type TodoItemGroupBy

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

TodoItemGroupBy is the group-by builder for TodoItem entities.

func (*TodoItemGroupBy) Aggregate

func (tigb *TodoItemGroupBy) Aggregate(fns ...AggregateFunc) *TodoItemGroupBy

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

func (*TodoItemGroupBy) Bool

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) BoolX

func (tigb *TodoItemGroupBy) BoolX(ctx context.Context) bool

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

func (*TodoItemGroupBy) Bools

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) BoolsX

func (tigb *TodoItemGroupBy) BoolsX(ctx context.Context) []bool

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

func (*TodoItemGroupBy) Float64

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) Float64X

func (tigb *TodoItemGroupBy) Float64X(ctx context.Context) float64

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

func (*TodoItemGroupBy) Float64s

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) Float64sX

func (tigb *TodoItemGroupBy) Float64sX(ctx context.Context) []float64

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

func (*TodoItemGroupBy) Int

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) IntX

func (tigb *TodoItemGroupBy) IntX(ctx context.Context) int

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

func (*TodoItemGroupBy) Ints

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) IntsX

func (tigb *TodoItemGroupBy) IntsX(ctx context.Context) []int

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

func (*TodoItemGroupBy) Scan

func (tigb *TodoItemGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*TodoItemGroupBy) ScanX

func (tigb *TodoItemGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*TodoItemGroupBy) String

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) StringX

func (tigb *TodoItemGroupBy) StringX(ctx context.Context) string

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

func (*TodoItemGroupBy) Strings

func (tigb *TodoItemGroupBy) 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 (*TodoItemGroupBy) StringsX

func (tigb *TodoItemGroupBy) StringsX(ctx context.Context) []string

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

type TodoItemMutation

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

TodoItemMutation represents an operation that mutates the TodoItem nodes in the graph.

func (*TodoItemMutation) AddField

func (m *TodoItemMutation) 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 (*TodoItemMutation) AddOrder

func (m *TodoItemMutation) AddOrder(i int)

AddOrder adds i to the "order" field.

func (*TodoItemMutation) AddedEdges

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

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

func (*TodoItemMutation) AddedField

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

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

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

func (*TodoItemMutation) AddedIDs

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

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

func (*TodoItemMutation) AddedOrder

func (m *TodoItemMutation) AddedOrder() (r int, exists bool)

AddedOrder returns the value that was added to the "order" field in this mutation.

func (*TodoItemMutation) ClearEdge

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

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

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

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

func (*TodoItemMutation) ClearedFields

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

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

func (TodoItemMutation) Client

func (m TodoItemMutation) 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 (*TodoItemMutation) Completed

func (m *TodoItemMutation) Completed() (r bool, exists bool)

Completed returns the value of the "completed" field in the mutation.

func (*TodoItemMutation) CreatedAt

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

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

func (*TodoItemMutation) EdgeCleared

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

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

func (*TodoItemMutation) Field

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

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

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

func (*TodoItemMutation) Fields

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

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

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

func (*TodoItemMutation) OldCompleted

func (m *TodoItemMutation) OldCompleted(ctx context.Context) (v bool, err error)

OldCompleted returns the old "completed" field's value of the TodoItem entity. If the TodoItem 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 (*TodoItemMutation) OldCreatedAt

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

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

func (m *TodoItemMutation) 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 (*TodoItemMutation) OldOrder

func (m *TodoItemMutation) OldOrder(ctx context.Context) (v int, err error)

OldOrder returns the old "order" field's value of the TodoItem entity. If the TodoItem 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 (*TodoItemMutation) OldTitle

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

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

func (m *TodoItemMutation) OldUID(ctx context.Context) (v string, err error)

OldUID returns the old "uid" field's value of the TodoItem entity. If the TodoItem 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 (*TodoItemMutation) OldUpdatedAt

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

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

func (m *TodoItemMutation) Op() Op

Op returns the operation name.

func (*TodoItemMutation) Order

func (m *TodoItemMutation) Order() (r int, exists bool)

Order returns the value of the "order" field in the mutation.

func (*TodoItemMutation) RemovedEdges

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

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

func (*TodoItemMutation) RemovedIDs

func (m *TodoItemMutation) 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 (*TodoItemMutation) ResetCompleted

func (m *TodoItemMutation) ResetCompleted()

ResetCompleted resets all changes to the "completed" field.

func (*TodoItemMutation) ResetCreatedAt

func (m *TodoItemMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*TodoItemMutation) ResetEdge

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

func (m *TodoItemMutation) 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 (*TodoItemMutation) ResetOrder

func (m *TodoItemMutation) ResetOrder()

ResetOrder resets all changes to the "order" field.

func (*TodoItemMutation) ResetTitle

func (m *TodoItemMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*TodoItemMutation) ResetUID

func (m *TodoItemMutation) ResetUID()

ResetUID resets all changes to the "uid" field.

func (*TodoItemMutation) ResetUpdatedAt

func (m *TodoItemMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*TodoItemMutation) SetCompleted

func (m *TodoItemMutation) SetCompleted(b bool)

SetCompleted sets the "completed" field.

func (*TodoItemMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*TodoItemMutation) SetField

func (m *TodoItemMutation) 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 (*TodoItemMutation) SetOrder

func (m *TodoItemMutation) SetOrder(i int)

SetOrder sets the "order" field.

func (*TodoItemMutation) SetTitle

func (m *TodoItemMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*TodoItemMutation) SetUID

func (m *TodoItemMutation) SetUID(s string)

SetUID sets the "uid" field.

func (*TodoItemMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*TodoItemMutation) Title

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

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

func (TodoItemMutation) Tx

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

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

func (*TodoItemMutation) Type

func (m *TodoItemMutation) Type() string

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

func (*TodoItemMutation) UID

func (m *TodoItemMutation) UID() (r string, exists bool)

UID returns the value of the "uid" field in the mutation.

func (*TodoItemMutation) UpdatedAt

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

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

func (*TodoItemMutation) Where

func (m *TodoItemMutation) Where(ps ...predicate.TodoItem)

Where appends a list predicates to the TodoItemMutation builder.

type TodoItemQuery

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

TodoItemQuery is the builder for querying TodoItem entities.

func (*TodoItemQuery) All

func (tiq *TodoItemQuery) All(ctx context.Context) ([]*TodoItem, error)

All executes the query and returns a list of TodoItems.

func (*TodoItemQuery) AllX

func (tiq *TodoItemQuery) AllX(ctx context.Context) []*TodoItem

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

func (*TodoItemQuery) Clone

func (tiq *TodoItemQuery) Clone() *TodoItemQuery

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

func (*TodoItemQuery) Count

func (tiq *TodoItemQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*TodoItemQuery) CountX

func (tiq *TodoItemQuery) CountX(ctx context.Context) int

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

func (*TodoItemQuery) Exist

func (tiq *TodoItemQuery) Exist(ctx context.Context) (bool, error)

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

func (*TodoItemQuery) ExistX

func (tiq *TodoItemQuery) ExistX(ctx context.Context) bool

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

func (*TodoItemQuery) First

func (tiq *TodoItemQuery) First(ctx context.Context) (*TodoItem, error)

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

func (*TodoItemQuery) FirstID

func (tiq *TodoItemQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*TodoItemQuery) FirstIDX

func (tiq *TodoItemQuery) FirstIDX(ctx context.Context) int

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

func (*TodoItemQuery) FirstX

func (tiq *TodoItemQuery) FirstX(ctx context.Context) *TodoItem

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

func (*TodoItemQuery) GroupBy

func (tiq *TodoItemQuery) GroupBy(field string, fields ...string) *TodoItemGroupBy

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

client.TodoItem.Query().
	GroupBy(todoitem.FieldUID).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*TodoItemQuery) IDs

func (tiq *TodoItemQuery) IDs(ctx context.Context) ([]int, error)

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

func (*TodoItemQuery) IDsX

func (tiq *TodoItemQuery) IDsX(ctx context.Context) []int

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

func (*TodoItemQuery) Limit

func (tiq *TodoItemQuery) Limit(limit int) *TodoItemQuery

Limit adds a limit step to the query.

func (*TodoItemQuery) Offset

func (tiq *TodoItemQuery) Offset(offset int) *TodoItemQuery

Offset adds an offset step to the query.

func (*TodoItemQuery) Only

func (tiq *TodoItemQuery) Only(ctx context.Context) (*TodoItem, error)

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

func (*TodoItemQuery) OnlyID

func (tiq *TodoItemQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*TodoItemQuery) OnlyIDX

func (tiq *TodoItemQuery) OnlyIDX(ctx context.Context) int

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

func (*TodoItemQuery) OnlyX

func (tiq *TodoItemQuery) OnlyX(ctx context.Context) *TodoItem

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

func (*TodoItemQuery) Order

func (tiq *TodoItemQuery) Order(o ...OrderFunc) *TodoItemQuery

Order adds an order step to the query.

func (*TodoItemQuery) Select

func (tiq *TodoItemQuery) Select(fields ...string) *TodoItemSelect

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

client.TodoItem.Query().
	Select(todoitem.FieldUID).
	Scan(ctx, &v)

func (*TodoItemQuery) Unique

func (tiq *TodoItemQuery) Unique(unique bool) *TodoItemQuery

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

func (tiq *TodoItemQuery) Where(ps ...predicate.TodoItem) *TodoItemQuery

Where adds a new predicate for the TodoItemQuery builder.

type TodoItemSelect

type TodoItemSelect struct {
	*TodoItemQuery
	// contains filtered or unexported fields
}

TodoItemSelect is the builder for selecting fields of TodoItem entities.

func (*TodoItemSelect) Bool

func (tis *TodoItemSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*TodoItemSelect) BoolX

func (tis *TodoItemSelect) BoolX(ctx context.Context) bool

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

func (*TodoItemSelect) Bools

func (tis *TodoItemSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*TodoItemSelect) BoolsX

func (tis *TodoItemSelect) BoolsX(ctx context.Context) []bool

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

func (*TodoItemSelect) Float64

func (tis *TodoItemSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*TodoItemSelect) Float64X

func (tis *TodoItemSelect) Float64X(ctx context.Context) float64

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

func (*TodoItemSelect) Float64s

func (tis *TodoItemSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*TodoItemSelect) Float64sX

func (tis *TodoItemSelect) Float64sX(ctx context.Context) []float64

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

func (*TodoItemSelect) Int

func (tis *TodoItemSelect) Int(ctx context.Context) (_ int, err error)

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

func (*TodoItemSelect) IntX

func (tis *TodoItemSelect) IntX(ctx context.Context) int

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

func (*TodoItemSelect) Ints

func (tis *TodoItemSelect) Ints(ctx context.Context) ([]int, error)

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

func (*TodoItemSelect) IntsX

func (tis *TodoItemSelect) IntsX(ctx context.Context) []int

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

func (*TodoItemSelect) Scan

func (tis *TodoItemSelect) Scan(ctx context.Context, v interface{}) error

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

func (*TodoItemSelect) ScanX

func (tis *TodoItemSelect) ScanX(ctx context.Context, v interface{})

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

func (*TodoItemSelect) String

func (tis *TodoItemSelect) String(ctx context.Context) (_ string, err error)

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

func (*TodoItemSelect) StringX

func (tis *TodoItemSelect) StringX(ctx context.Context) string

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

func (*TodoItemSelect) Strings

func (tis *TodoItemSelect) Strings(ctx context.Context) ([]string, error)

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

func (*TodoItemSelect) StringsX

func (tis *TodoItemSelect) StringsX(ctx context.Context) []string

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

type TodoItemUpdate

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

TodoItemUpdate is the builder for updating TodoItem entities.

func (*TodoItemUpdate) AddOrder

func (tiu *TodoItemUpdate) AddOrder(i int) *TodoItemUpdate

AddOrder adds i to the "order" field.

func (*TodoItemUpdate) Exec

func (tiu *TodoItemUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*TodoItemUpdate) ExecX

func (tiu *TodoItemUpdate) ExecX(ctx context.Context)

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

func (*TodoItemUpdate) Mutation

func (tiu *TodoItemUpdate) Mutation() *TodoItemMutation

Mutation returns the TodoItemMutation object of the builder.

func (*TodoItemUpdate) Save

func (tiu *TodoItemUpdate) Save(ctx context.Context) (int, error)

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

func (*TodoItemUpdate) SaveX

func (tiu *TodoItemUpdate) SaveX(ctx context.Context) int

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

func (*TodoItemUpdate) SetCompleted

func (tiu *TodoItemUpdate) SetCompleted(b bool) *TodoItemUpdate

SetCompleted sets the "completed" field.

func (*TodoItemUpdate) SetCreatedAt

func (tiu *TodoItemUpdate) SetCreatedAt(t time.Time) *TodoItemUpdate

SetCreatedAt sets the "created_at" field.

func (*TodoItemUpdate) SetNillableCreatedAt

func (tiu *TodoItemUpdate) SetNillableCreatedAt(t *time.Time) *TodoItemUpdate

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

func (*TodoItemUpdate) SetOrder

func (tiu *TodoItemUpdate) SetOrder(i int) *TodoItemUpdate

SetOrder sets the "order" field.

func (*TodoItemUpdate) SetTitle

func (tiu *TodoItemUpdate) SetTitle(s string) *TodoItemUpdate

SetTitle sets the "title" field.

func (*TodoItemUpdate) SetUpdatedAt

func (tiu *TodoItemUpdate) SetUpdatedAt(t time.Time) *TodoItemUpdate

SetUpdatedAt sets the "updated_at" field.

func (*TodoItemUpdate) Where

func (tiu *TodoItemUpdate) Where(ps ...predicate.TodoItem) *TodoItemUpdate

Where appends a list predicates to the TodoItemUpdate builder.

type TodoItemUpdateOne

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

TodoItemUpdateOne is the builder for updating a single TodoItem entity.

func (*TodoItemUpdateOne) AddOrder

func (tiuo *TodoItemUpdateOne) AddOrder(i int) *TodoItemUpdateOne

AddOrder adds i to the "order" field.

func (*TodoItemUpdateOne) Exec

func (tiuo *TodoItemUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*TodoItemUpdateOne) ExecX

func (tiuo *TodoItemUpdateOne) ExecX(ctx context.Context)

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

func (*TodoItemUpdateOne) Mutation

func (tiuo *TodoItemUpdateOne) Mutation() *TodoItemMutation

Mutation returns the TodoItemMutation object of the builder.

func (*TodoItemUpdateOne) Save

func (tiuo *TodoItemUpdateOne) Save(ctx context.Context) (*TodoItem, error)

Save executes the query and returns the updated TodoItem entity.

func (*TodoItemUpdateOne) SaveX

func (tiuo *TodoItemUpdateOne) SaveX(ctx context.Context) *TodoItem

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

func (*TodoItemUpdateOne) Select

func (tiuo *TodoItemUpdateOne) Select(field string, fields ...string) *TodoItemUpdateOne

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

func (*TodoItemUpdateOne) SetCompleted

func (tiuo *TodoItemUpdateOne) SetCompleted(b bool) *TodoItemUpdateOne

SetCompleted sets the "completed" field.

func (*TodoItemUpdateOne) SetCreatedAt

func (tiuo *TodoItemUpdateOne) SetCreatedAt(t time.Time) *TodoItemUpdateOne

SetCreatedAt sets the "created_at" field.

func (*TodoItemUpdateOne) SetNillableCreatedAt

func (tiuo *TodoItemUpdateOne) SetNillableCreatedAt(t *time.Time) *TodoItemUpdateOne

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

func (*TodoItemUpdateOne) SetOrder

func (tiuo *TodoItemUpdateOne) SetOrder(i int) *TodoItemUpdateOne

SetOrder sets the "order" field.

func (*TodoItemUpdateOne) SetTitle

func (tiuo *TodoItemUpdateOne) SetTitle(s string) *TodoItemUpdateOne

SetTitle sets the "title" field.

func (*TodoItemUpdateOne) SetUpdatedAt

func (tiuo *TodoItemUpdateOne) SetUpdatedAt(t time.Time) *TodoItemUpdateOne

SetUpdatedAt sets the "updated_at" field.

type TodoItems

type TodoItems []*TodoItem

TodoItems is a parsable slice of TodoItem.

type Tx

type Tx struct {

	// TodoItem is the client for interacting with the TodoItem builders.
	TodoItem *TodoItemClient
	// 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 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