ent

package
v0.0.0-...-02a5af8 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 19 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.
	TypeItem  = "Item"
	TypeOrder = "Order"
)

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 validaton 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, func(string) bool) 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
	// Item is the client for interacting with the Item builders.
	Item *ItemClient
	// Order is the client for interacting with the Order builders.
	Order *OrderClient
	// 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().
	Item.
	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 Item

type Item struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// ProductID holds the value of the "product_id" field.
	ProductID int `json:"product_id,omitempty"`
	// Qty holds the value of the "qty" field.
	Qty int `json:"qty,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 ItemQuery when eager-loading is set.
	Edges ItemEdges `json:"edges"`
	// contains filtered or unexported fields
}

Item is the model entity for the Item schema.

func (*Item) QueryOrderID

func (i *Item) QueryOrderID() *OrderQuery

QueryOrderID queries the "order_id" edge of the Item entity.

func (*Item) String

func (i *Item) String() string

String implements the fmt.Stringer.

func (*Item) Unwrap

func (i *Item) Unwrap() *Item

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

func (i *Item) Update() *ItemUpdateOne

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

type ItemClient

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

ItemClient is a client for the Item schema.

func NewItemClient

func NewItemClient(c config) *ItemClient

NewItemClient returns a client for the Item from the given config.

func (*ItemClient) Create

func (c *ItemClient) Create() *ItemCreate

Create returns a create builder for Item.

func (*ItemClient) CreateBulk

func (c *ItemClient) CreateBulk(builders ...*ItemCreate) *ItemCreateBulk

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

func (*ItemClient) Delete

func (c *ItemClient) Delete() *ItemDelete

Delete returns a delete builder for Item.

func (*ItemClient) DeleteOne

func (c *ItemClient) DeleteOne(i *Item) *ItemDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*ItemClient) DeleteOneID

func (c *ItemClient) DeleteOneID(id int) *ItemDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*ItemClient) Get

func (c *ItemClient) Get(ctx context.Context, id int) (*Item, error)

Get returns a Item entity by its id.

func (*ItemClient) GetX

func (c *ItemClient) GetX(ctx context.Context, id int) *Item

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

func (*ItemClient) Hooks

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

Hooks returns the client hooks.

func (*ItemClient) Query

func (c *ItemClient) Query() *ItemQuery

Query returns a query builder for Item.

func (*ItemClient) QueryOrderID

func (c *ItemClient) QueryOrderID(i *Item) *OrderQuery

QueryOrderID queries the order_id edge of a Item.

func (*ItemClient) Update

func (c *ItemClient) Update() *ItemUpdate

Update returns an update builder for Item.

func (*ItemClient) UpdateOne

func (c *ItemClient) UpdateOne(i *Item) *ItemUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ItemClient) UpdateOneID

func (c *ItemClient) UpdateOneID(id int) *ItemUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ItemClient) Use

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

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

type ItemCreate

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

ItemCreate is the builder for creating a Item entity.

func (*ItemCreate) AddOrderID

func (ic *ItemCreate) AddOrderID(o ...*Order) *ItemCreate

AddOrderID adds the "order_id" edges to the Order entity.

func (*ItemCreate) AddOrderIDIDs

func (ic *ItemCreate) AddOrderIDIDs(ids ...string) *ItemCreate

AddOrderIDIDs adds the "order_id" edge to the Order entity by IDs.

func (*ItemCreate) Mutation

func (ic *ItemCreate) Mutation() *ItemMutation

Mutation returns the ItemMutation object of the builder.

func (*ItemCreate) Save

func (ic *ItemCreate) Save(ctx context.Context) (*Item, error)

Save creates the Item in the database.

func (*ItemCreate) SaveX

func (ic *ItemCreate) SaveX(ctx context.Context) *Item

SaveX calls Save and panics if Save returns an error.

func (*ItemCreate) SetCreatedAt

func (ic *ItemCreate) SetCreatedAt(t time.Time) *ItemCreate

SetCreatedAt sets the "created_at" field.

func (*ItemCreate) SetNillableCreatedAt

func (ic *ItemCreate) SetNillableCreatedAt(t *time.Time) *ItemCreate

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

func (*ItemCreate) SetNillableQty

func (ic *ItemCreate) SetNillableQty(i *int) *ItemCreate

SetNillableQty sets the "qty" field if the given value is not nil.

func (*ItemCreate) SetNillableUpdatedAt

func (ic *ItemCreate) SetNillableUpdatedAt(t *time.Time) *ItemCreate

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

func (*ItemCreate) SetProductID

func (ic *ItemCreate) SetProductID(i int) *ItemCreate

SetProductID sets the "product_id" field.

func (*ItemCreate) SetQty

func (ic *ItemCreate) SetQty(i int) *ItemCreate

SetQty sets the "qty" field.

func (*ItemCreate) SetUpdatedAt

func (ic *ItemCreate) SetUpdatedAt(t time.Time) *ItemCreate

SetUpdatedAt sets the "updated_at" field.

type ItemCreateBulk

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

ItemCreateBulk is the builder for creating many Item entities in bulk.

func (*ItemCreateBulk) Save

func (icb *ItemCreateBulk) Save(ctx context.Context) ([]*Item, error)

Save creates the Item entities in the database.

func (*ItemCreateBulk) SaveX

func (icb *ItemCreateBulk) SaveX(ctx context.Context) []*Item

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

type ItemDelete

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

ItemDelete is the builder for deleting a Item entity.

func (*ItemDelete) Exec

func (id *ItemDelete) Exec(ctx context.Context) (int, error)

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

func (*ItemDelete) ExecX

func (id *ItemDelete) ExecX(ctx context.Context) int

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

func (*ItemDelete) Where

func (id *ItemDelete) Where(ps ...predicate.Item) *ItemDelete

Where adds a new predicate to the ItemDelete builder.

type ItemDeleteOne

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

ItemDeleteOne is the builder for deleting a single Item entity.

func (*ItemDeleteOne) Exec

func (ido *ItemDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*ItemDeleteOne) ExecX

func (ido *ItemDeleteOne) ExecX(ctx context.Context)

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

type ItemEdges

type ItemEdges struct {
	// OrderID holds the value of the order_id edge.
	OrderID []*Order `json:"order_id,omitempty"`
	// contains filtered or unexported fields
}

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

func (ItemEdges) OrderIDOrErr

func (e ItemEdges) OrderIDOrErr() ([]*Order, error)

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

type ItemGroupBy

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

ItemGroupBy is the group-by builder for Item entities.

func (*ItemGroupBy) Aggregate

func (igb *ItemGroupBy) Aggregate(fns ...AggregateFunc) *ItemGroupBy

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

func (*ItemGroupBy) Bool

func (igb *ItemGroupBy) 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 (*ItemGroupBy) BoolX

func (igb *ItemGroupBy) BoolX(ctx context.Context) bool

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

func (*ItemGroupBy) Bools

func (igb *ItemGroupBy) 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 (*ItemGroupBy) BoolsX

func (igb *ItemGroupBy) BoolsX(ctx context.Context) []bool

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

func (*ItemGroupBy) Float64

func (igb *ItemGroupBy) 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 (*ItemGroupBy) Float64X

func (igb *ItemGroupBy) Float64X(ctx context.Context) float64

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

func (*ItemGroupBy) Float64s

func (igb *ItemGroupBy) 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 (*ItemGroupBy) Float64sX

func (igb *ItemGroupBy) Float64sX(ctx context.Context) []float64

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

func (*ItemGroupBy) Int

func (igb *ItemGroupBy) 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 (*ItemGroupBy) IntX

func (igb *ItemGroupBy) IntX(ctx context.Context) int

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

func (*ItemGroupBy) Ints

func (igb *ItemGroupBy) 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 (*ItemGroupBy) IntsX

func (igb *ItemGroupBy) IntsX(ctx context.Context) []int

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

func (*ItemGroupBy) Scan

func (igb *ItemGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*ItemGroupBy) ScanX

func (igb *ItemGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*ItemGroupBy) String

func (igb *ItemGroupBy) 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 (*ItemGroupBy) StringX

func (igb *ItemGroupBy) StringX(ctx context.Context) string

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

func (*ItemGroupBy) Strings

func (igb *ItemGroupBy) 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 (*ItemGroupBy) StringsX

func (igb *ItemGroupBy) StringsX(ctx context.Context) []string

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

type ItemMutation

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

ItemMutation represents an operation that mutates the Item nodes in the graph.

func (*ItemMutation) AddField

func (m *ItemMutation) 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 (*ItemMutation) AddOrderIDIDs

func (m *ItemMutation) AddOrderIDIDs(ids ...string)

AddOrderIDIDs adds the "order_id" edge to the Order entity by ids.

func (*ItemMutation) AddProductID

func (m *ItemMutation) AddProductID(i int)

AddProductID adds i to the "product_id" field.

func (*ItemMutation) AddQty

func (m *ItemMutation) AddQty(i int)

AddQty adds i to the "qty" field.

func (*ItemMutation) AddedEdges

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

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

func (*ItemMutation) AddedField

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

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

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

func (*ItemMutation) AddedIDs

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

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

func (*ItemMutation) AddedProductID

func (m *ItemMutation) AddedProductID() (r int, exists bool)

AddedProductID returns the value that was added to the "product_id" field in this mutation.

func (*ItemMutation) AddedQty

func (m *ItemMutation) AddedQty() (r int, exists bool)

AddedQty returns the value that was added to the "qty" field in this mutation.

func (*ItemMutation) ClearEdge

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

func (m *ItemMutation) 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 (*ItemMutation) ClearOrderID

func (m *ItemMutation) ClearOrderID()

ClearOrderID clears the "order_id" edge to the Order entity.

func (*ItemMutation) ClearedEdges

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

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

func (*ItemMutation) ClearedFields

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

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

func (ItemMutation) Client

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

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

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

func (*ItemMutation) EdgeCleared

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

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

func (*ItemMutation) Field

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

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

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

func (*ItemMutation) Fields

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

func (m *ItemMutation) 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.

func (*ItemMutation) OldCreatedAt

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

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

func (m *ItemMutation) 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 (*ItemMutation) OldProductID

func (m *ItemMutation) OldProductID(ctx context.Context) (v int, err error)

OldProductID returns the old "product_id" field's value of the Item entity. If the Item 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 (*ItemMutation) OldQty

func (m *ItemMutation) OldQty(ctx context.Context) (v int, err error)

OldQty returns the old "qty" field's value of the Item entity. If the Item 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 (*ItemMutation) OldUpdatedAt

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

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

func (m *ItemMutation) Op() Op

Op returns the operation name.

func (*ItemMutation) OrderIDCleared

func (m *ItemMutation) OrderIDCleared() bool

OrderIDCleared returns if the "order_id" edge to the Order entity was cleared.

func (*ItemMutation) OrderIDIDs

func (m *ItemMutation) OrderIDIDs() (ids []string)

OrderIDIDs returns the "order_id" edge IDs in the mutation.

func (*ItemMutation) ProductID

func (m *ItemMutation) ProductID() (r int, exists bool)

ProductID returns the value of the "product_id" field in the mutation.

func (*ItemMutation) Qty

func (m *ItemMutation) Qty() (r int, exists bool)

Qty returns the value of the "qty" field in the mutation.

func (*ItemMutation) RemoveOrderIDIDs

func (m *ItemMutation) RemoveOrderIDIDs(ids ...string)

RemoveOrderIDIDs removes the "order_id" edge to the Order entity by IDs.

func (*ItemMutation) RemovedEdges

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

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

func (*ItemMutation) RemovedIDs

func (m *ItemMutation) 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 (*ItemMutation) RemovedOrderIDIDs

func (m *ItemMutation) RemovedOrderIDIDs() (ids []string)

RemovedOrderID returns the removed IDs of the "order_id" edge to the Order entity.

func (*ItemMutation) ResetCreatedAt

func (m *ItemMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*ItemMutation) ResetEdge

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

func (m *ItemMutation) 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 (*ItemMutation) ResetOrderID

func (m *ItemMutation) ResetOrderID()

ResetOrderID resets all changes to the "order_id" edge.

func (*ItemMutation) ResetProductID

func (m *ItemMutation) ResetProductID()

ResetProductID resets all changes to the "product_id" field.

func (*ItemMutation) ResetQty

func (m *ItemMutation) ResetQty()

ResetQty resets all changes to the "qty" field.

func (*ItemMutation) ResetUpdatedAt

func (m *ItemMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*ItemMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*ItemMutation) SetField

func (m *ItemMutation) 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 (*ItemMutation) SetProductID

func (m *ItemMutation) SetProductID(i int)

SetProductID sets the "product_id" field.

func (*ItemMutation) SetQty

func (m *ItemMutation) SetQty(i int)

SetQty sets the "qty" field.

func (*ItemMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (ItemMutation) Tx

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

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

func (*ItemMutation) Type

func (m *ItemMutation) Type() string

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

func (*ItemMutation) UpdatedAt

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

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

type ItemQuery

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

ItemQuery is the builder for querying Item entities.

func (*ItemQuery) All

func (iq *ItemQuery) All(ctx context.Context) ([]*Item, error)

All executes the query and returns a list of Items.

func (*ItemQuery) AllX

func (iq *ItemQuery) AllX(ctx context.Context) []*Item

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

func (*ItemQuery) Clone

func (iq *ItemQuery) Clone() *ItemQuery

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

func (*ItemQuery) Count

func (iq *ItemQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*ItemQuery) CountX

func (iq *ItemQuery) CountX(ctx context.Context) int

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

func (*ItemQuery) Exist

func (iq *ItemQuery) Exist(ctx context.Context) (bool, error)

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

func (*ItemQuery) ExistX

func (iq *ItemQuery) ExistX(ctx context.Context) bool

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

func (*ItemQuery) First

func (iq *ItemQuery) First(ctx context.Context) (*Item, error)

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

func (*ItemQuery) FirstID

func (iq *ItemQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*ItemQuery) FirstIDX

func (iq *ItemQuery) FirstIDX(ctx context.Context) int

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

func (*ItemQuery) FirstX

func (iq *ItemQuery) FirstX(ctx context.Context) *Item

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

func (*ItemQuery) GroupBy

func (iq *ItemQuery) GroupBy(field string, fields ...string) *ItemGroupBy

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 {
	ProductID int `json:"product_id,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Item.Query().
	GroupBy(item.FieldProductID).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ItemQuery) IDs

func (iq *ItemQuery) IDs(ctx context.Context) ([]int, error)

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

func (*ItemQuery) IDsX

func (iq *ItemQuery) IDsX(ctx context.Context) []int

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

func (*ItemQuery) Limit

func (iq *ItemQuery) Limit(limit int) *ItemQuery

Limit adds a limit step to the query.

func (*ItemQuery) Offset

func (iq *ItemQuery) Offset(offset int) *ItemQuery

Offset adds an offset step to the query.

func (*ItemQuery) Only

func (iq *ItemQuery) Only(ctx context.Context) (*Item, error)

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

func (*ItemQuery) OnlyID

func (iq *ItemQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*ItemQuery) OnlyIDX

func (iq *ItemQuery) OnlyIDX(ctx context.Context) int

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

func (*ItemQuery) OnlyX

func (iq *ItemQuery) OnlyX(ctx context.Context) *Item

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

func (*ItemQuery) Order

func (iq *ItemQuery) Order(o ...OrderFunc) *ItemQuery

Order adds an order step to the query.

func (*ItemQuery) QueryOrderID

func (iq *ItemQuery) QueryOrderID() *OrderQuery

QueryOrderID chains the current query on the "order_id" edge.

func (*ItemQuery) Select

func (iq *ItemQuery) Select(field string, fields ...string) *ItemSelect

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 {
	ProductID int `json:"product_id,omitempty"`
}

client.Item.Query().
	Select(item.FieldProductID).
	Scan(ctx, &v)

func (*ItemQuery) Where

func (iq *ItemQuery) Where(ps ...predicate.Item) *ItemQuery

Where adds a new predicate for the ItemQuery builder.

func (*ItemQuery) WithOrderID

func (iq *ItemQuery) WithOrderID(opts ...func(*OrderQuery)) *ItemQuery

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

type ItemSelect

type ItemSelect struct {
	*ItemQuery
	// contains filtered or unexported fields
}

ItemSelect is the builder for selecting fields of Item entities.

func (*ItemSelect) Bool

func (is *ItemSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*ItemSelect) BoolX

func (is *ItemSelect) BoolX(ctx context.Context) bool

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

func (*ItemSelect) Bools

func (is *ItemSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*ItemSelect) BoolsX

func (is *ItemSelect) BoolsX(ctx context.Context) []bool

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

func (*ItemSelect) Float64

func (is *ItemSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*ItemSelect) Float64X

func (is *ItemSelect) Float64X(ctx context.Context) float64

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

func (*ItemSelect) Float64s

func (is *ItemSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*ItemSelect) Float64sX

func (is *ItemSelect) Float64sX(ctx context.Context) []float64

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

func (*ItemSelect) Int

func (is *ItemSelect) Int(ctx context.Context) (_ int, err error)

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

func (*ItemSelect) IntX

func (is *ItemSelect) IntX(ctx context.Context) int

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

func (*ItemSelect) Ints

func (is *ItemSelect) Ints(ctx context.Context) ([]int, error)

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

func (*ItemSelect) IntsX

func (is *ItemSelect) IntsX(ctx context.Context) []int

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

func (*ItemSelect) Scan

func (is *ItemSelect) Scan(ctx context.Context, v interface{}) error

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

func (*ItemSelect) ScanX

func (is *ItemSelect) ScanX(ctx context.Context, v interface{})

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

func (*ItemSelect) String

func (is *ItemSelect) String(ctx context.Context) (_ string, err error)

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

func (*ItemSelect) StringX

func (is *ItemSelect) StringX(ctx context.Context) string

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

func (*ItemSelect) Strings

func (is *ItemSelect) Strings(ctx context.Context) ([]string, error)

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

func (*ItemSelect) StringsX

func (is *ItemSelect) StringsX(ctx context.Context) []string

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

type ItemUpdate

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

ItemUpdate is the builder for updating Item entities.

func (*ItemUpdate) AddOrderID

func (iu *ItemUpdate) AddOrderID(o ...*Order) *ItemUpdate

AddOrderID adds the "order_id" edges to the Order entity.

func (*ItemUpdate) AddOrderIDIDs

func (iu *ItemUpdate) AddOrderIDIDs(ids ...string) *ItemUpdate

AddOrderIDIDs adds the "order_id" edge to the Order entity by IDs.

func (*ItemUpdate) AddProductID

func (iu *ItemUpdate) AddProductID(i int) *ItemUpdate

AddProductID adds i to the "product_id" field.

func (*ItemUpdate) AddQty

func (iu *ItemUpdate) AddQty(i int) *ItemUpdate

AddQty adds i to the "qty" field.

func (*ItemUpdate) ClearOrderID

func (iu *ItemUpdate) ClearOrderID() *ItemUpdate

ClearOrderID clears all "order_id" edges to the Order entity.

func (*ItemUpdate) Exec

func (iu *ItemUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*ItemUpdate) ExecX

func (iu *ItemUpdate) ExecX(ctx context.Context)

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

func (*ItemUpdate) Mutation

func (iu *ItemUpdate) Mutation() *ItemMutation

Mutation returns the ItemMutation object of the builder.

func (*ItemUpdate) RemoveOrderID

func (iu *ItemUpdate) RemoveOrderID(o ...*Order) *ItemUpdate

RemoveOrderID removes "order_id" edges to Order entities.

func (*ItemUpdate) RemoveOrderIDIDs

func (iu *ItemUpdate) RemoveOrderIDIDs(ids ...string) *ItemUpdate

RemoveOrderIDIDs removes the "order_id" edge to Order entities by IDs.

func (*ItemUpdate) Save

func (iu *ItemUpdate) Save(ctx context.Context) (int, error)

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

func (*ItemUpdate) SaveX

func (iu *ItemUpdate) SaveX(ctx context.Context) int

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

func (*ItemUpdate) SetCreatedAt

func (iu *ItemUpdate) SetCreatedAt(t time.Time) *ItemUpdate

SetCreatedAt sets the "created_at" field.

func (*ItemUpdate) SetNillableCreatedAt

func (iu *ItemUpdate) SetNillableCreatedAt(t *time.Time) *ItemUpdate

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

func (*ItemUpdate) SetNillableQty

func (iu *ItemUpdate) SetNillableQty(i *int) *ItemUpdate

SetNillableQty sets the "qty" field if the given value is not nil.

func (*ItemUpdate) SetProductID

func (iu *ItemUpdate) SetProductID(i int) *ItemUpdate

SetProductID sets the "product_id" field.

func (*ItemUpdate) SetQty

func (iu *ItemUpdate) SetQty(i int) *ItemUpdate

SetQty sets the "qty" field.

func (*ItemUpdate) SetUpdatedAt

func (iu *ItemUpdate) SetUpdatedAt(t time.Time) *ItemUpdate

SetUpdatedAt sets the "updated_at" field.

func (*ItemUpdate) Where

func (iu *ItemUpdate) Where(ps ...predicate.Item) *ItemUpdate

Where adds a new predicate for the ItemUpdate builder.

type ItemUpdateOne

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

ItemUpdateOne is the builder for updating a single Item entity.

func (*ItemUpdateOne) AddOrderID

func (iuo *ItemUpdateOne) AddOrderID(o ...*Order) *ItemUpdateOne

AddOrderID adds the "order_id" edges to the Order entity.

func (*ItemUpdateOne) AddOrderIDIDs

func (iuo *ItemUpdateOne) AddOrderIDIDs(ids ...string) *ItemUpdateOne

AddOrderIDIDs adds the "order_id" edge to the Order entity by IDs.

func (*ItemUpdateOne) AddProductID

func (iuo *ItemUpdateOne) AddProductID(i int) *ItemUpdateOne

AddProductID adds i to the "product_id" field.

func (*ItemUpdateOne) AddQty

func (iuo *ItemUpdateOne) AddQty(i int) *ItemUpdateOne

AddQty adds i to the "qty" field.

func (*ItemUpdateOne) ClearOrderID

func (iuo *ItemUpdateOne) ClearOrderID() *ItemUpdateOne

ClearOrderID clears all "order_id" edges to the Order entity.

func (*ItemUpdateOne) Exec

func (iuo *ItemUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*ItemUpdateOne) ExecX

func (iuo *ItemUpdateOne) ExecX(ctx context.Context)

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

func (*ItemUpdateOne) Mutation

func (iuo *ItemUpdateOne) Mutation() *ItemMutation

Mutation returns the ItemMutation object of the builder.

func (*ItemUpdateOne) RemoveOrderID

func (iuo *ItemUpdateOne) RemoveOrderID(o ...*Order) *ItemUpdateOne

RemoveOrderID removes "order_id" edges to Order entities.

func (*ItemUpdateOne) RemoveOrderIDIDs

func (iuo *ItemUpdateOne) RemoveOrderIDIDs(ids ...string) *ItemUpdateOne

RemoveOrderIDIDs removes the "order_id" edge to Order entities by IDs.

func (*ItemUpdateOne) Save

func (iuo *ItemUpdateOne) Save(ctx context.Context) (*Item, error)

Save executes the query and returns the updated Item entity.

func (*ItemUpdateOne) SaveX

func (iuo *ItemUpdateOne) SaveX(ctx context.Context) *Item

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

func (*ItemUpdateOne) SetCreatedAt

func (iuo *ItemUpdateOne) SetCreatedAt(t time.Time) *ItemUpdateOne

SetCreatedAt sets the "created_at" field.

func (*ItemUpdateOne) SetNillableCreatedAt

func (iuo *ItemUpdateOne) SetNillableCreatedAt(t *time.Time) *ItemUpdateOne

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

func (*ItemUpdateOne) SetNillableQty

func (iuo *ItemUpdateOne) SetNillableQty(i *int) *ItemUpdateOne

SetNillableQty sets the "qty" field if the given value is not nil.

func (*ItemUpdateOne) SetProductID

func (iuo *ItemUpdateOne) SetProductID(i int) *ItemUpdateOne

SetProductID sets the "product_id" field.

func (*ItemUpdateOne) SetQty

func (iuo *ItemUpdateOne) SetQty(i int) *ItemUpdateOne

SetQty sets the "qty" field.

func (*ItemUpdateOne) SetUpdatedAt

func (iuo *ItemUpdateOne) SetUpdatedAt(t time.Time) *ItemUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Items

type Items []*Item

Items is a parsable slice of Item.

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 Order

type Order struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// UserID holds the value of the "user_id" field.
	UserID string `json:"user_id,omitempty"`
	// Status holds the value of the "status" field.
	Status string `json:"status,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 OrderQuery when eager-loading is set.
	Edges OrderEdges `json:"edges"`
	// contains filtered or unexported fields
}

Order is the model entity for the Order schema.

func (*Order) QueryItems

func (o *Order) QueryItems() *ItemQuery

QueryItems queries the "items" edge of the Order entity.

func (*Order) String

func (o *Order) String() string

String implements the fmt.Stringer.

func (*Order) Unwrap

func (o *Order) Unwrap() *Order

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

func (o *Order) Update() *OrderUpdateOne

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

type OrderClient

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

OrderClient is a client for the Order schema.

func NewOrderClient

func NewOrderClient(c config) *OrderClient

NewOrderClient returns a client for the Order from the given config.

func (*OrderClient) Create

func (c *OrderClient) Create() *OrderCreate

Create returns a create builder for Order.

func (*OrderClient) CreateBulk

func (c *OrderClient) CreateBulk(builders ...*OrderCreate) *OrderCreateBulk

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

func (*OrderClient) Delete

func (c *OrderClient) Delete() *OrderDelete

Delete returns a delete builder for Order.

func (*OrderClient) DeleteOne

func (c *OrderClient) DeleteOne(o *Order) *OrderDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*OrderClient) DeleteOneID

func (c *OrderClient) DeleteOneID(id string) *OrderDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*OrderClient) Get

func (c *OrderClient) Get(ctx context.Context, id string) (*Order, error)

Get returns a Order entity by its id.

func (*OrderClient) GetX

func (c *OrderClient) GetX(ctx context.Context, id string) *Order

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

func (*OrderClient) Hooks

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

Hooks returns the client hooks.

func (*OrderClient) Query

func (c *OrderClient) Query() *OrderQuery

Query returns a query builder for Order.

func (*OrderClient) QueryItems

func (c *OrderClient) QueryItems(o *Order) *ItemQuery

QueryItems queries the items edge of a Order.

func (*OrderClient) Update

func (c *OrderClient) Update() *OrderUpdate

Update returns an update builder for Order.

func (*OrderClient) UpdateOne

func (c *OrderClient) UpdateOne(o *Order) *OrderUpdateOne

UpdateOne returns an update builder for the given entity.

func (*OrderClient) UpdateOneID

func (c *OrderClient) UpdateOneID(id string) *OrderUpdateOne

UpdateOneID returns an update builder for the given id.

func (*OrderClient) Use

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

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

type OrderCreate

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

OrderCreate is the builder for creating a Order entity.

func (*OrderCreate) AddItemIDs

func (oc *OrderCreate) AddItemIDs(ids ...int) *OrderCreate

AddItemIDs adds the "items" edge to the Item entity by IDs.

func (*OrderCreate) AddItems

func (oc *OrderCreate) AddItems(i ...*Item) *OrderCreate

AddItems adds the "items" edges to the Item entity.

func (*OrderCreate) Mutation

func (oc *OrderCreate) Mutation() *OrderMutation

Mutation returns the OrderMutation object of the builder.

func (*OrderCreate) Save

func (oc *OrderCreate) Save(ctx context.Context) (*Order, error)

Save creates the Order in the database.

func (*OrderCreate) SaveX

func (oc *OrderCreate) SaveX(ctx context.Context) *Order

SaveX calls Save and panics if Save returns an error.

func (*OrderCreate) SetCreatedAt

func (oc *OrderCreate) SetCreatedAt(t time.Time) *OrderCreate

SetCreatedAt sets the "created_at" field.

func (*OrderCreate) SetID

func (oc *OrderCreate) SetID(s string) *OrderCreate

SetID sets the "id" field.

func (*OrderCreate) SetNillableCreatedAt

func (oc *OrderCreate) SetNillableCreatedAt(t *time.Time) *OrderCreate

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

func (*OrderCreate) SetNillableStatus

func (oc *OrderCreate) SetNillableStatus(s *string) *OrderCreate

SetNillableStatus sets the "status" field if the given value is not nil.

func (*OrderCreate) SetNillableUpdatedAt

func (oc *OrderCreate) SetNillableUpdatedAt(t *time.Time) *OrderCreate

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

func (*OrderCreate) SetStatus

func (oc *OrderCreate) SetStatus(s string) *OrderCreate

SetStatus sets the "status" field.

func (*OrderCreate) SetUpdatedAt

func (oc *OrderCreate) SetUpdatedAt(t time.Time) *OrderCreate

SetUpdatedAt sets the "updated_at" field.

func (*OrderCreate) SetUserID

func (oc *OrderCreate) SetUserID(s string) *OrderCreate

SetUserID sets the "user_id" field.

type OrderCreateBulk

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

OrderCreateBulk is the builder for creating many Order entities in bulk.

func (*OrderCreateBulk) Save

func (ocb *OrderCreateBulk) Save(ctx context.Context) ([]*Order, error)

Save creates the Order entities in the database.

func (*OrderCreateBulk) SaveX

func (ocb *OrderCreateBulk) SaveX(ctx context.Context) []*Order

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

type OrderDelete

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

OrderDelete is the builder for deleting a Order entity.

func (*OrderDelete) Exec

func (od *OrderDelete) Exec(ctx context.Context) (int, error)

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

func (*OrderDelete) ExecX

func (od *OrderDelete) ExecX(ctx context.Context) int

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

func (*OrderDelete) Where

func (od *OrderDelete) Where(ps ...predicate.Order) *OrderDelete

Where adds a new predicate to the OrderDelete builder.

type OrderDeleteOne

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

OrderDeleteOne is the builder for deleting a single Order entity.

func (*OrderDeleteOne) Exec

func (odo *OrderDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*OrderDeleteOne) ExecX

func (odo *OrderDeleteOne) ExecX(ctx context.Context)

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

type OrderEdges

type OrderEdges struct {
	// Items holds the value of the items edge.
	Items []*Item `json:"items,omitempty"`
	// contains filtered or unexported fields
}

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

func (OrderEdges) ItemsOrErr

func (e OrderEdges) ItemsOrErr() ([]*Item, error)

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

type OrderFunc

type OrderFunc func(*sql.Selector, func(string) bool)

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 OrderGroupBy

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

OrderGroupBy is the group-by builder for Order entities.

func (*OrderGroupBy) Aggregate

func (ogb *OrderGroupBy) Aggregate(fns ...AggregateFunc) *OrderGroupBy

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

func (*OrderGroupBy) Bool

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) BoolX

func (ogb *OrderGroupBy) BoolX(ctx context.Context) bool

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

func (*OrderGroupBy) Bools

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) BoolsX

func (ogb *OrderGroupBy) BoolsX(ctx context.Context) []bool

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

func (*OrderGroupBy) Float64

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) Float64X

func (ogb *OrderGroupBy) Float64X(ctx context.Context) float64

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

func (*OrderGroupBy) Float64s

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) Float64sX

func (ogb *OrderGroupBy) Float64sX(ctx context.Context) []float64

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

func (*OrderGroupBy) Int

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) IntX

func (ogb *OrderGroupBy) IntX(ctx context.Context) int

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

func (*OrderGroupBy) Ints

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) IntsX

func (ogb *OrderGroupBy) IntsX(ctx context.Context) []int

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

func (*OrderGroupBy) Scan

func (ogb *OrderGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*OrderGroupBy) ScanX

func (ogb *OrderGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*OrderGroupBy) String

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) StringX

func (ogb *OrderGroupBy) StringX(ctx context.Context) string

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

func (*OrderGroupBy) Strings

func (ogb *OrderGroupBy) 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 (*OrderGroupBy) StringsX

func (ogb *OrderGroupBy) StringsX(ctx context.Context) []string

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

type OrderMutation

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

OrderMutation represents an operation that mutates the Order nodes in the graph.

func (*OrderMutation) AddField

func (m *OrderMutation) 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 (*OrderMutation) AddItemIDs

func (m *OrderMutation) AddItemIDs(ids ...int)

AddItemIDs adds the "items" edge to the Item entity by ids.

func (*OrderMutation) AddedEdges

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

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

func (*OrderMutation) AddedField

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

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

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

func (*OrderMutation) AddedIDs

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

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

func (*OrderMutation) ClearEdge

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

func (m *OrderMutation) 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 (*OrderMutation) ClearItems

func (m *OrderMutation) ClearItems()

ClearItems clears the "items" edge to the Item entity.

func (*OrderMutation) ClearedEdges

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

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

func (*OrderMutation) ClearedFields

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

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

func (OrderMutation) Client

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

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

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

func (*OrderMutation) EdgeCleared

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

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

func (*OrderMutation) Field

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

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

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

func (*OrderMutation) Fields

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

func (m *OrderMutation) 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.

func (*OrderMutation) ItemsCleared

func (m *OrderMutation) ItemsCleared() bool

ItemsCleared returns if the "items" edge to the Item entity was cleared.

func (*OrderMutation) ItemsIDs

func (m *OrderMutation) ItemsIDs() (ids []int)

ItemsIDs returns the "items" edge IDs in the mutation.

func (*OrderMutation) OldCreatedAt

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

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

func (m *OrderMutation) 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 (*OrderMutation) OldStatus

func (m *OrderMutation) OldStatus(ctx context.Context) (v string, err error)

OldStatus returns the old "status" field's value of the Order entity. If the Order 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 (*OrderMutation) OldUpdatedAt

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

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

func (m *OrderMutation) OldUserID(ctx context.Context) (v string, err error)

OldUserID returns the old "user_id" field's value of the Order entity. If the Order 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 (*OrderMutation) Op

func (m *OrderMutation) Op() Op

Op returns the operation name.

func (*OrderMutation) RemoveItemIDs

func (m *OrderMutation) RemoveItemIDs(ids ...int)

RemoveItemIDs removes the "items" edge to the Item entity by IDs.

func (*OrderMutation) RemovedEdges

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

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

func (*OrderMutation) RemovedIDs

func (m *OrderMutation) 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 (*OrderMutation) RemovedItemsIDs

func (m *OrderMutation) RemovedItemsIDs() (ids []int)

RemovedItems returns the removed IDs of the "items" edge to the Item entity.

func (*OrderMutation) ResetCreatedAt

func (m *OrderMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*OrderMutation) ResetEdge

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

func (m *OrderMutation) 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 (*OrderMutation) ResetItems

func (m *OrderMutation) ResetItems()

ResetItems resets all changes to the "items" edge.

func (*OrderMutation) ResetStatus

func (m *OrderMutation) ResetStatus()

ResetStatus resets all changes to the "status" field.

func (*OrderMutation) ResetUpdatedAt

func (m *OrderMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*OrderMutation) ResetUserID

func (m *OrderMutation) ResetUserID()

ResetUserID resets all changes to the "user_id" field.

func (*OrderMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*OrderMutation) SetField

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

func (m *OrderMutation) SetID(id string)

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

func (*OrderMutation) SetStatus

func (m *OrderMutation) SetStatus(s string)

SetStatus sets the "status" field.

func (*OrderMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*OrderMutation) SetUserID

func (m *OrderMutation) SetUserID(s string)

SetUserID sets the "user_id" field.

func (*OrderMutation) Status

func (m *OrderMutation) Status() (r string, exists bool)

Status returns the value of the "status" field in the mutation.

func (OrderMutation) Tx

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

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

func (*OrderMutation) Type

func (m *OrderMutation) Type() string

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

func (*OrderMutation) UpdatedAt

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

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

func (*OrderMutation) UserID

func (m *OrderMutation) UserID() (r string, exists bool)

UserID returns the value of the "user_id" field in the mutation.

type OrderQuery

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

OrderQuery is the builder for querying Order entities.

func (*OrderQuery) All

func (oq *OrderQuery) All(ctx context.Context) ([]*Order, error)

All executes the query and returns a list of Orders.

func (*OrderQuery) AllX

func (oq *OrderQuery) AllX(ctx context.Context) []*Order

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

func (*OrderQuery) Clone

func (oq *OrderQuery) Clone() *OrderQuery

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

func (*OrderQuery) Count

func (oq *OrderQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*OrderQuery) CountX

func (oq *OrderQuery) CountX(ctx context.Context) int

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

func (*OrderQuery) Exist

func (oq *OrderQuery) Exist(ctx context.Context) (bool, error)

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

func (*OrderQuery) ExistX

func (oq *OrderQuery) ExistX(ctx context.Context) bool

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

func (*OrderQuery) First

func (oq *OrderQuery) First(ctx context.Context) (*Order, error)

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

func (*OrderQuery) FirstID

func (oq *OrderQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*OrderQuery) FirstIDX

func (oq *OrderQuery) FirstIDX(ctx context.Context) string

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

func (*OrderQuery) FirstX

func (oq *OrderQuery) FirstX(ctx context.Context) *Order

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

func (*OrderQuery) GroupBy

func (oq *OrderQuery) GroupBy(field string, fields ...string) *OrderGroupBy

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

client.Order.Query().
	GroupBy(order.FieldUserID).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*OrderQuery) IDs

func (oq *OrderQuery) IDs(ctx context.Context) ([]string, error)

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

func (*OrderQuery) IDsX

func (oq *OrderQuery) IDsX(ctx context.Context) []string

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

func (*OrderQuery) Limit

func (oq *OrderQuery) Limit(limit int) *OrderQuery

Limit adds a limit step to the query.

func (*OrderQuery) Offset

func (oq *OrderQuery) Offset(offset int) *OrderQuery

Offset adds an offset step to the query.

func (*OrderQuery) Only

func (oq *OrderQuery) Only(ctx context.Context) (*Order, error)

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

func (*OrderQuery) OnlyID

func (oq *OrderQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*OrderQuery) OnlyIDX

func (oq *OrderQuery) OnlyIDX(ctx context.Context) string

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

func (*OrderQuery) OnlyX

func (oq *OrderQuery) OnlyX(ctx context.Context) *Order

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

func (*OrderQuery) Order

func (oq *OrderQuery) Order(o ...OrderFunc) *OrderQuery

Order adds an order step to the query.

func (*OrderQuery) QueryItems

func (oq *OrderQuery) QueryItems() *ItemQuery

QueryItems chains the current query on the "items" edge.

func (*OrderQuery) Select

func (oq *OrderQuery) Select(field string, fields ...string) *OrderSelect

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

client.Order.Query().
	Select(order.FieldUserID).
	Scan(ctx, &v)

func (*OrderQuery) Where

func (oq *OrderQuery) Where(ps ...predicate.Order) *OrderQuery

Where adds a new predicate for the OrderQuery builder.

func (*OrderQuery) WithItems

func (oq *OrderQuery) WithItems(opts ...func(*ItemQuery)) *OrderQuery

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

type OrderSelect

type OrderSelect struct {
	*OrderQuery
	// contains filtered or unexported fields
}

OrderSelect is the builder for selecting fields of Order entities.

func (*OrderSelect) Bool

func (os *OrderSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*OrderSelect) BoolX

func (os *OrderSelect) BoolX(ctx context.Context) bool

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

func (*OrderSelect) Bools

func (os *OrderSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*OrderSelect) BoolsX

func (os *OrderSelect) BoolsX(ctx context.Context) []bool

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

func (*OrderSelect) Float64

func (os *OrderSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*OrderSelect) Float64X

func (os *OrderSelect) Float64X(ctx context.Context) float64

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

func (*OrderSelect) Float64s

func (os *OrderSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*OrderSelect) Float64sX

func (os *OrderSelect) Float64sX(ctx context.Context) []float64

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

func (*OrderSelect) Int

func (os *OrderSelect) Int(ctx context.Context) (_ int, err error)

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

func (*OrderSelect) IntX

func (os *OrderSelect) IntX(ctx context.Context) int

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

func (*OrderSelect) Ints

func (os *OrderSelect) Ints(ctx context.Context) ([]int, error)

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

func (*OrderSelect) IntsX

func (os *OrderSelect) IntsX(ctx context.Context) []int

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

func (*OrderSelect) Scan

func (os *OrderSelect) Scan(ctx context.Context, v interface{}) error

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

func (*OrderSelect) ScanX

func (os *OrderSelect) ScanX(ctx context.Context, v interface{})

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

func (*OrderSelect) String

func (os *OrderSelect) String(ctx context.Context) (_ string, err error)

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

func (*OrderSelect) StringX

func (os *OrderSelect) StringX(ctx context.Context) string

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

func (*OrderSelect) Strings

func (os *OrderSelect) Strings(ctx context.Context) ([]string, error)

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

func (*OrderSelect) StringsX

func (os *OrderSelect) StringsX(ctx context.Context) []string

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

type OrderUpdate

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

OrderUpdate is the builder for updating Order entities.

func (*OrderUpdate) AddItemIDs

func (ou *OrderUpdate) AddItemIDs(ids ...int) *OrderUpdate

AddItemIDs adds the "items" edge to the Item entity by IDs.

func (*OrderUpdate) AddItems

func (ou *OrderUpdate) AddItems(i ...*Item) *OrderUpdate

AddItems adds the "items" edges to the Item entity.

func (*OrderUpdate) ClearItems

func (ou *OrderUpdate) ClearItems() *OrderUpdate

ClearItems clears all "items" edges to the Item entity.

func (*OrderUpdate) Exec

func (ou *OrderUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*OrderUpdate) ExecX

func (ou *OrderUpdate) ExecX(ctx context.Context)

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

func (*OrderUpdate) Mutation

func (ou *OrderUpdate) Mutation() *OrderMutation

Mutation returns the OrderMutation object of the builder.

func (*OrderUpdate) RemoveItemIDs

func (ou *OrderUpdate) RemoveItemIDs(ids ...int) *OrderUpdate

RemoveItemIDs removes the "items" edge to Item entities by IDs.

func (*OrderUpdate) RemoveItems

func (ou *OrderUpdate) RemoveItems(i ...*Item) *OrderUpdate

RemoveItems removes "items" edges to Item entities.

func (*OrderUpdate) Save

func (ou *OrderUpdate) Save(ctx context.Context) (int, error)

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

func (*OrderUpdate) SaveX

func (ou *OrderUpdate) SaveX(ctx context.Context) int

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

func (*OrderUpdate) SetCreatedAt

func (ou *OrderUpdate) SetCreatedAt(t time.Time) *OrderUpdate

SetCreatedAt sets the "created_at" field.

func (*OrderUpdate) SetNillableCreatedAt

func (ou *OrderUpdate) SetNillableCreatedAt(t *time.Time) *OrderUpdate

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

func (*OrderUpdate) SetNillableStatus

func (ou *OrderUpdate) SetNillableStatus(s *string) *OrderUpdate

SetNillableStatus sets the "status" field if the given value is not nil.

func (*OrderUpdate) SetStatus

func (ou *OrderUpdate) SetStatus(s string) *OrderUpdate

SetStatus sets the "status" field.

func (*OrderUpdate) SetUpdatedAt

func (ou *OrderUpdate) SetUpdatedAt(t time.Time) *OrderUpdate

SetUpdatedAt sets the "updated_at" field.

func (*OrderUpdate) SetUserID

func (ou *OrderUpdate) SetUserID(s string) *OrderUpdate

SetUserID sets the "user_id" field.

func (*OrderUpdate) Where

func (ou *OrderUpdate) Where(ps ...predicate.Order) *OrderUpdate

Where adds a new predicate for the OrderUpdate builder.

type OrderUpdateOne

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

OrderUpdateOne is the builder for updating a single Order entity.

func (*OrderUpdateOne) AddItemIDs

func (ouo *OrderUpdateOne) AddItemIDs(ids ...int) *OrderUpdateOne

AddItemIDs adds the "items" edge to the Item entity by IDs.

func (*OrderUpdateOne) AddItems

func (ouo *OrderUpdateOne) AddItems(i ...*Item) *OrderUpdateOne

AddItems adds the "items" edges to the Item entity.

func (*OrderUpdateOne) ClearItems

func (ouo *OrderUpdateOne) ClearItems() *OrderUpdateOne

ClearItems clears all "items" edges to the Item entity.

func (*OrderUpdateOne) Exec

func (ouo *OrderUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*OrderUpdateOne) ExecX

func (ouo *OrderUpdateOne) ExecX(ctx context.Context)

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

func (*OrderUpdateOne) Mutation

func (ouo *OrderUpdateOne) Mutation() *OrderMutation

Mutation returns the OrderMutation object of the builder.

func (*OrderUpdateOne) RemoveItemIDs

func (ouo *OrderUpdateOne) RemoveItemIDs(ids ...int) *OrderUpdateOne

RemoveItemIDs removes the "items" edge to Item entities by IDs.

func (*OrderUpdateOne) RemoveItems

func (ouo *OrderUpdateOne) RemoveItems(i ...*Item) *OrderUpdateOne

RemoveItems removes "items" edges to Item entities.

func (*OrderUpdateOne) Save

func (ouo *OrderUpdateOne) Save(ctx context.Context) (*Order, error)

Save executes the query and returns the updated Order entity.

func (*OrderUpdateOne) SaveX

func (ouo *OrderUpdateOne) SaveX(ctx context.Context) *Order

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

func (*OrderUpdateOne) SetCreatedAt

func (ouo *OrderUpdateOne) SetCreatedAt(t time.Time) *OrderUpdateOne

SetCreatedAt sets the "created_at" field.

func (*OrderUpdateOne) SetNillableCreatedAt

func (ouo *OrderUpdateOne) SetNillableCreatedAt(t *time.Time) *OrderUpdateOne

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

func (*OrderUpdateOne) SetNillableStatus

func (ouo *OrderUpdateOne) SetNillableStatus(s *string) *OrderUpdateOne

SetNillableStatus sets the "status" field if the given value is not nil.

func (*OrderUpdateOne) SetStatus

func (ouo *OrderUpdateOne) SetStatus(s string) *OrderUpdateOne

SetStatus sets the "status" field.

func (*OrderUpdateOne) SetUpdatedAt

func (ouo *OrderUpdateOne) SetUpdatedAt(t time.Time) *OrderUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*OrderUpdateOne) SetUserID

func (ouo *OrderUpdateOne) SetUserID(s string) *OrderUpdateOne

SetUserID sets the "user_id" field.

type Orders

type Orders []*Order

Orders is a parsable slice of 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 Tx

type Tx struct {

	// Item is the client for interacting with the Item builders.
	Item *ItemClient
	// Order is the client for interacting with the Order builders.
	Order *OrderClient
	// 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