ent

package
v0.0.0-...-cca628e Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 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.
	TypeCustomer = "Customer"
	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 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
	// Customer is the client for interacting with the Customer builders.
	Customer *CustomerClient
	// 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().
	Customer.
	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(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Commit(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Customer

type Customer struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Addr holds the value of the "addr" field.
	Addr string `json:"addr,omitempty"`
	// Age holds the value of the "age" field.
	Age int32 `json:"age,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,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
}

Customer is the model entity for the Customer schema.

func (*Customer) String

func (c *Customer) String() string

String implements the fmt.Stringer.

func (*Customer) Unwrap

func (c *Customer) Unwrap() *Customer

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

func (c *Customer) Update() *CustomerUpdateOne

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

type CustomerClient

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

CustomerClient is a client for the Customer schema.

func NewCustomerClient

func NewCustomerClient(c config) *CustomerClient

NewCustomerClient returns a client for the Customer from the given config.

func (*CustomerClient) Create

func (c *CustomerClient) Create() *CustomerCreate

Create returns a create builder for Customer.

func (*CustomerClient) CreateBulk

func (c *CustomerClient) CreateBulk(builders ...*CustomerCreate) *CustomerCreateBulk

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

func (*CustomerClient) Delete

func (c *CustomerClient) Delete() *CustomerDelete

Delete returns a delete builder for Customer.

func (*CustomerClient) DeleteOne

func (c *CustomerClient) DeleteOne(cu *Customer) *CustomerDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*CustomerClient) DeleteOneID

func (c *CustomerClient) DeleteOneID(id int) *CustomerDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*CustomerClient) Get

func (c *CustomerClient) Get(ctx context.Context, id int) (*Customer, error)

Get returns a Customer entity by its id.

func (*CustomerClient) GetX

func (c *CustomerClient) GetX(ctx context.Context, id int) *Customer

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

func (*CustomerClient) Hooks

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

Hooks returns the client hooks.

func (*CustomerClient) Query

func (c *CustomerClient) Query() *CustomerQuery

Query returns a query builder for Customer.

func (*CustomerClient) Update

func (c *CustomerClient) Update() *CustomerUpdate

Update returns an update builder for Customer.

func (*CustomerClient) UpdateOne

func (c *CustomerClient) UpdateOne(cu *Customer) *CustomerUpdateOne

UpdateOne returns an update builder for the given entity.

func (*CustomerClient) UpdateOneID

func (c *CustomerClient) UpdateOneID(id int) *CustomerUpdateOne

UpdateOneID returns an update builder for the given id.

func (*CustomerClient) Use

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

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

type CustomerCreate

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

CustomerCreate is the builder for creating a Customer entity.

func (*CustomerCreate) Exec

func (cc *CustomerCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*CustomerCreate) ExecX

func (cc *CustomerCreate) ExecX(ctx context.Context)

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

func (*CustomerCreate) Mutation

func (cc *CustomerCreate) Mutation() *CustomerMutation

Mutation returns the CustomerMutation object of the builder.

func (*CustomerCreate) Save

func (cc *CustomerCreate) Save(ctx context.Context) (*Customer, error)

Save creates the Customer in the database.

func (*CustomerCreate) SaveX

func (cc *CustomerCreate) SaveX(ctx context.Context) *Customer

SaveX calls Save and panics if Save returns an error.

func (*CustomerCreate) SetAddr

func (cc *CustomerCreate) SetAddr(s string) *CustomerCreate

SetAddr sets the "addr" field.

func (*CustomerCreate) SetAge

func (cc *CustomerCreate) SetAge(i int32) *CustomerCreate

SetAge sets the "age" field.

func (*CustomerCreate) SetCreatedAt

func (cc *CustomerCreate) SetCreatedAt(t time.Time) *CustomerCreate

SetCreatedAt sets the "created_at" field.

func (*CustomerCreate) SetID

func (cc *CustomerCreate) SetID(i int) *CustomerCreate

SetID sets the "id" field.

func (*CustomerCreate) SetName

func (cc *CustomerCreate) SetName(s string) *CustomerCreate

SetName sets the "name" field.

func (*CustomerCreate) SetUpdatedAt

func (cc *CustomerCreate) SetUpdatedAt(t time.Time) *CustomerCreate

SetUpdatedAt sets the "updated_at" field.

type CustomerCreateBulk

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

CustomerCreateBulk is the builder for creating many Customer entities in bulk.

func (*CustomerCreateBulk) Exec

func (ccb *CustomerCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*CustomerCreateBulk) ExecX

func (ccb *CustomerCreateBulk) ExecX(ctx context.Context)

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

func (*CustomerCreateBulk) Save

func (ccb *CustomerCreateBulk) Save(ctx context.Context) ([]*Customer, error)

Save creates the Customer entities in the database.

func (*CustomerCreateBulk) SaveX

func (ccb *CustomerCreateBulk) SaveX(ctx context.Context) []*Customer

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

type CustomerDelete

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

CustomerDelete is the builder for deleting a Customer entity.

func (*CustomerDelete) Exec

func (cd *CustomerDelete) Exec(ctx context.Context) (int, error)

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

func (*CustomerDelete) ExecX

func (cd *CustomerDelete) ExecX(ctx context.Context) int

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

func (*CustomerDelete) Where

func (cd *CustomerDelete) Where(ps ...predicate.Customer) *CustomerDelete

Where appends a list predicates to the CustomerDelete builder.

type CustomerDeleteOne

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

CustomerDeleteOne is the builder for deleting a single Customer entity.

func (*CustomerDeleteOne) Exec

func (cdo *CustomerDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*CustomerDeleteOne) ExecX

func (cdo *CustomerDeleteOne) ExecX(ctx context.Context)

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

type CustomerGroupBy

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

CustomerGroupBy is the group-by builder for Customer entities.

func (*CustomerGroupBy) Aggregate

func (cgb *CustomerGroupBy) Aggregate(fns ...AggregateFunc) *CustomerGroupBy

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

func (*CustomerGroupBy) Bool

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

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

func (*CustomerGroupBy) BoolX

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

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

func (*CustomerGroupBy) Bools

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

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

func (*CustomerGroupBy) BoolsX

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

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

func (*CustomerGroupBy) Float64

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

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

func (*CustomerGroupBy) Float64X

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

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

func (*CustomerGroupBy) Float64s

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

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

func (*CustomerGroupBy) Float64sX

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

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

func (*CustomerGroupBy) Int

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

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

func (*CustomerGroupBy) IntX

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

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

func (*CustomerGroupBy) Ints

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

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

func (*CustomerGroupBy) IntsX

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

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

func (*CustomerGroupBy) Scan

func (cgb *CustomerGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*CustomerGroupBy) ScanX

func (s *CustomerGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*CustomerGroupBy) String

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

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

func (*CustomerGroupBy) StringX

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

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

func (*CustomerGroupBy) Strings

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

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

func (*CustomerGroupBy) StringsX

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

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

type CustomerMutation

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

CustomerMutation represents an operation that mutates the Customer nodes in the graph.

func (*CustomerMutation) AddAge

func (m *CustomerMutation) AddAge(i int32)

AddAge adds i to the "age" field.

func (*CustomerMutation) AddField

func (m *CustomerMutation) 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 (*CustomerMutation) AddedAge

func (m *CustomerMutation) AddedAge() (r int32, exists bool)

AddedAge returns the value that was added to the "age" field in this mutation.

func (*CustomerMutation) AddedEdges

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

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

func (*CustomerMutation) AddedField

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

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

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

func (*CustomerMutation) AddedIDs

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

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

func (*CustomerMutation) Addr

func (m *CustomerMutation) Addr() (r string, exists bool)

Addr returns the value of the "addr" field in the mutation.

func (*CustomerMutation) Age

func (m *CustomerMutation) Age() (r int32, exists bool)

Age returns the value of the "age" field in the mutation.

func (*CustomerMutation) ClearEdge

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

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

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

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

func (*CustomerMutation) ClearedFields

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

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

func (CustomerMutation) Client

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

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

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

func (*CustomerMutation) EdgeCleared

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

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

func (*CustomerMutation) Field

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

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

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

func (*CustomerMutation) Fields

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

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

func (m *CustomerMutation) IDs(ctx context.Context) ([]int, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*CustomerMutation) Name

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

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

func (*CustomerMutation) OldAddr

func (m *CustomerMutation) OldAddr(ctx context.Context) (v string, err error)

OldAddr returns the old "addr" field's value of the Customer entity. If the Customer 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 (*CustomerMutation) OldAge

func (m *CustomerMutation) OldAge(ctx context.Context) (v int32, err error)

OldAge returns the old "age" field's value of the Customer entity. If the Customer 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 (*CustomerMutation) OldCreatedAt

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

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

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

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

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

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

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

func (m *CustomerMutation) Op() Op

Op returns the operation name.

func (*CustomerMutation) RemovedEdges

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

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

func (*CustomerMutation) RemovedIDs

func (m *CustomerMutation) 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 (*CustomerMutation) ResetAddr

func (m *CustomerMutation) ResetAddr()

ResetAddr resets all changes to the "addr" field.

func (*CustomerMutation) ResetAge

func (m *CustomerMutation) ResetAge()

ResetAge resets all changes to the "age" field.

func (*CustomerMutation) ResetCreatedAt

func (m *CustomerMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*CustomerMutation) ResetEdge

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

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

func (m *CustomerMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*CustomerMutation) ResetUpdatedAt

func (m *CustomerMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*CustomerMutation) SetAddr

func (m *CustomerMutation) SetAddr(s string)

SetAddr sets the "addr" field.

func (*CustomerMutation) SetAge

func (m *CustomerMutation) SetAge(i int32)

SetAge sets the "age" field.

func (*CustomerMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*CustomerMutation) SetField

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

func (m *CustomerMutation) SetID(id int)

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

func (*CustomerMutation) SetName

func (m *CustomerMutation) SetName(s string)

SetName sets the "name" field.

func (*CustomerMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (CustomerMutation) Tx

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

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

func (*CustomerMutation) Type

func (m *CustomerMutation) Type() string

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

func (*CustomerMutation) UpdatedAt

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

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

func (*CustomerMutation) Where

func (m *CustomerMutation) Where(ps ...predicate.Customer)

Where appends a list predicates to the CustomerMutation builder.

type CustomerQuery

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

CustomerQuery is the builder for querying Customer entities.

func (*CustomerQuery) All

func (cq *CustomerQuery) All(ctx context.Context) ([]*Customer, error)

All executes the query and returns a list of Customers.

func (*CustomerQuery) AllX

func (cq *CustomerQuery) AllX(ctx context.Context) []*Customer

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

func (*CustomerQuery) Clone

func (cq *CustomerQuery) Clone() *CustomerQuery

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

func (*CustomerQuery) Count

func (cq *CustomerQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*CustomerQuery) CountX

func (cq *CustomerQuery) CountX(ctx context.Context) int

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

func (*CustomerQuery) Exist

func (cq *CustomerQuery) Exist(ctx context.Context) (bool, error)

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

func (*CustomerQuery) ExistX

func (cq *CustomerQuery) ExistX(ctx context.Context) bool

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

func (*CustomerQuery) First

func (cq *CustomerQuery) First(ctx context.Context) (*Customer, error)

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

func (*CustomerQuery) FirstID

func (cq *CustomerQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*CustomerQuery) FirstIDX

func (cq *CustomerQuery) FirstIDX(ctx context.Context) int

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

func (*CustomerQuery) FirstX

func (cq *CustomerQuery) FirstX(ctx context.Context) *Customer

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

func (*CustomerQuery) GroupBy

func (cq *CustomerQuery) GroupBy(field string, fields ...string) *CustomerGroupBy

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

client.Customer.Query().
	GroupBy(customer.FieldAddr).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*CustomerQuery) IDs

func (cq *CustomerQuery) IDs(ctx context.Context) ([]int, error)

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

func (*CustomerQuery) IDsX

func (cq *CustomerQuery) IDsX(ctx context.Context) []int

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

func (*CustomerQuery) Limit

func (cq *CustomerQuery) Limit(limit int) *CustomerQuery

Limit adds a limit step to the query.

func (*CustomerQuery) Offset

func (cq *CustomerQuery) Offset(offset int) *CustomerQuery

Offset adds an offset step to the query.

func (*CustomerQuery) Only

func (cq *CustomerQuery) Only(ctx context.Context) (*Customer, error)

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

func (*CustomerQuery) OnlyID

func (cq *CustomerQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*CustomerQuery) OnlyIDX

func (cq *CustomerQuery) OnlyIDX(ctx context.Context) int

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

func (*CustomerQuery) OnlyX

func (cq *CustomerQuery) OnlyX(ctx context.Context) *Customer

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

func (*CustomerQuery) Order

func (cq *CustomerQuery) Order(o ...OrderFunc) *CustomerQuery

Order adds an order step to the query.

func (*CustomerQuery) Select

func (cq *CustomerQuery) Select(fields ...string) *CustomerSelect

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

client.Customer.Query().
	Select(customer.FieldAddr).
	Scan(ctx, &v)

func (*CustomerQuery) Unique

func (cq *CustomerQuery) Unique(unique bool) *CustomerQuery

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

func (cq *CustomerQuery) Where(ps ...predicate.Customer) *CustomerQuery

Where adds a new predicate for the CustomerQuery builder.

type CustomerSelect

type CustomerSelect struct {
	*CustomerQuery
	// contains filtered or unexported fields
}

CustomerSelect is the builder for selecting fields of Customer entities.

func (*CustomerSelect) Bool

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

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

func (*CustomerSelect) BoolX

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

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

func (*CustomerSelect) Bools

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

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

func (*CustomerSelect) BoolsX

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

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

func (*CustomerSelect) Float64

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

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

func (*CustomerSelect) Float64X

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

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

func (*CustomerSelect) Float64s

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

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

func (*CustomerSelect) Float64sX

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

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

func (*CustomerSelect) Int

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

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

func (*CustomerSelect) IntX

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

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

func (*CustomerSelect) Ints

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

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

func (*CustomerSelect) IntsX

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

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

func (*CustomerSelect) Scan

func (cs *CustomerSelect) Scan(ctx context.Context, v interface{}) error

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

func (*CustomerSelect) ScanX

func (s *CustomerSelect) ScanX(ctx context.Context, v interface{})

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

func (*CustomerSelect) String

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

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

func (*CustomerSelect) StringX

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

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

func (*CustomerSelect) Strings

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

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

func (*CustomerSelect) StringsX

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

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

type CustomerUpdate

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

CustomerUpdate is the builder for updating Customer entities.

func (*CustomerUpdate) AddAge

func (cu *CustomerUpdate) AddAge(i int32) *CustomerUpdate

AddAge adds i to the "age" field.

func (*CustomerUpdate) Exec

func (cu *CustomerUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*CustomerUpdate) ExecX

func (cu *CustomerUpdate) ExecX(ctx context.Context)

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

func (*CustomerUpdate) Mutation

func (cu *CustomerUpdate) Mutation() *CustomerMutation

Mutation returns the CustomerMutation object of the builder.

func (*CustomerUpdate) Save

func (cu *CustomerUpdate) Save(ctx context.Context) (int, error)

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

func (*CustomerUpdate) SaveX

func (cu *CustomerUpdate) SaveX(ctx context.Context) int

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

func (*CustomerUpdate) SetAddr

func (cu *CustomerUpdate) SetAddr(s string) *CustomerUpdate

SetAddr sets the "addr" field.

func (*CustomerUpdate) SetAge

func (cu *CustomerUpdate) SetAge(i int32) *CustomerUpdate

SetAge sets the "age" field.

func (*CustomerUpdate) SetCreatedAt

func (cu *CustomerUpdate) SetCreatedAt(t time.Time) *CustomerUpdate

SetCreatedAt sets the "created_at" field.

func (*CustomerUpdate) SetName

func (cu *CustomerUpdate) SetName(s string) *CustomerUpdate

SetName sets the "name" field.

func (*CustomerUpdate) SetUpdatedAt

func (cu *CustomerUpdate) SetUpdatedAt(t time.Time) *CustomerUpdate

SetUpdatedAt sets the "updated_at" field.

func (*CustomerUpdate) Where

func (cu *CustomerUpdate) Where(ps ...predicate.Customer) *CustomerUpdate

Where appends a list predicates to the CustomerUpdate builder.

type CustomerUpdateOne

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

CustomerUpdateOne is the builder for updating a single Customer entity.

func (*CustomerUpdateOne) AddAge

func (cuo *CustomerUpdateOne) AddAge(i int32) *CustomerUpdateOne

AddAge adds i to the "age" field.

func (*CustomerUpdateOne) Exec

func (cuo *CustomerUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*CustomerUpdateOne) ExecX

func (cuo *CustomerUpdateOne) ExecX(ctx context.Context)

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

func (*CustomerUpdateOne) Mutation

func (cuo *CustomerUpdateOne) Mutation() *CustomerMutation

Mutation returns the CustomerMutation object of the builder.

func (*CustomerUpdateOne) Save

func (cuo *CustomerUpdateOne) Save(ctx context.Context) (*Customer, error)

Save executes the query and returns the updated Customer entity.

func (*CustomerUpdateOne) SaveX

func (cuo *CustomerUpdateOne) SaveX(ctx context.Context) *Customer

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

func (*CustomerUpdateOne) Select

func (cuo *CustomerUpdateOne) Select(field string, fields ...string) *CustomerUpdateOne

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

func (*CustomerUpdateOne) SetAddr

func (cuo *CustomerUpdateOne) SetAddr(s string) *CustomerUpdateOne

SetAddr sets the "addr" field.

func (*CustomerUpdateOne) SetAge

func (cuo *CustomerUpdateOne) SetAge(i int32) *CustomerUpdateOne

SetAge sets the "age" field.

func (*CustomerUpdateOne) SetCreatedAt

func (cuo *CustomerUpdateOne) SetCreatedAt(t time.Time) *CustomerUpdateOne

SetCreatedAt sets the "created_at" field.

func (*CustomerUpdateOne) SetName

func (cuo *CustomerUpdateOne) SetName(s string) *CustomerUpdateOne

SetName sets the "name" field.

func (*CustomerUpdateOne) SetUpdatedAt

func (cuo *CustomerUpdateOne) SetUpdatedAt(t time.Time) *CustomerUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Customers

type Customers []*Customer

Customers is a parsable slice of Customer.

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 Order

type Order struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// CustomerID holds the value of the "customer_id" field.
	CustomerID int `json:"customer_id,omitempty"`
	// Addr holds the value of the "addr" field.
	Addr string `json:"addr,omitempty"`
	// Price holds the value of the "price" field.
	Price float64 `json:"price,omitempty"`
	// Status holds the value of the "status" field.
	Status int32 `json:"status,omitempty"`
	// contains filtered or unexported fields
}

Order is the model entity for the Order schema.

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 int) *OrderDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*OrderClient) Get

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

Get returns a Order entity by its id.

func (*OrderClient) GetX

func (c *OrderClient) GetX(ctx context.Context, id int) *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) 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 int) *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) Exec

func (oc *OrderCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*OrderCreate) ExecX

func (oc *OrderCreate) ExecX(ctx context.Context)

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

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

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

SetAddr sets the "addr" field.

func (*OrderCreate) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*OrderCreate) SetCustomerID

func (oc *OrderCreate) SetCustomerID(i int) *OrderCreate

SetCustomerID sets the "customer_id" field.

func (*OrderCreate) SetID

func (oc *OrderCreate) SetID(i int) *OrderCreate

SetID sets the "id" field.

func (*OrderCreate) SetPrice

func (oc *OrderCreate) SetPrice(f float64) *OrderCreate

SetPrice sets the "price" field.

func (*OrderCreate) SetStatus

func (oc *OrderCreate) SetStatus(i int32) *OrderCreate

SetStatus sets the "status" field.

func (*OrderCreate) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

type OrderCreateBulk

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

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

func (*OrderCreateBulk) Exec

func (ocb *OrderCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*OrderCreateBulk) ExecX

func (ocb *OrderCreateBulk) ExecX(ctx context.Context)

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

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 appends a list predicates 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 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 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 (s *OrderGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*OrderGroupBy) BoolX

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

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

func (*OrderGroupBy) Bools

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

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

func (*OrderGroupBy) BoolsX

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

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

func (*OrderGroupBy) Float64

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

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

func (*OrderGroupBy) Float64X

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

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

func (*OrderGroupBy) Float64s

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

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

func (*OrderGroupBy) Float64sX

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

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

func (*OrderGroupBy) Int

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

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

func (*OrderGroupBy) IntX

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

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

func (*OrderGroupBy) Ints

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

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

func (*OrderGroupBy) IntsX

func (s *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 (s *OrderGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*OrderGroupBy) String

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

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

func (*OrderGroupBy) StringX

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

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

func (*OrderGroupBy) Strings

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

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

func (*OrderGroupBy) StringsX

func (s *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) AddCustomerID

func (m *OrderMutation) AddCustomerID(i int)

AddCustomerID adds i to the "customer_id" field.

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

func (m *OrderMutation) AddPrice(f float64)

AddPrice adds f to the "price" field.

func (*OrderMutation) AddStatus

func (m *OrderMutation) AddStatus(i int32)

AddStatus adds i to the "status" field.

func (*OrderMutation) AddedCustomerID

func (m *OrderMutation) AddedCustomerID() (r int, exists bool)

AddedCustomerID returns the value that was added to the "customer_id" field in this mutation.

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

func (m *OrderMutation) AddedPrice() (r float64, exists bool)

AddedPrice returns the value that was added to the "price" field in this mutation.

func (*OrderMutation) AddedStatus

func (m *OrderMutation) AddedStatus() (r int32, exists bool)

AddedStatus returns the value that was added to the "status" field in this mutation.

func (*OrderMutation) Addr

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

Addr returns the value of the "addr" field in the 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) 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) CustomerID

func (m *OrderMutation) CustomerID() (r int, exists bool)

CustomerID returns the value of the "customer_id" 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 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 (*OrderMutation) IDs

func (m *OrderMutation) IDs(ctx context.Context) ([]int, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*OrderMutation) OldAddr

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

OldAddr returns the old "addr" 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) 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) OldCustomerID

func (m *OrderMutation) OldCustomerID(ctx context.Context) (v int, err error)

OldCustomerID returns the old "customer_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) 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) OldPrice

func (m *OrderMutation) OldPrice(ctx context.Context) (v float64, err error)

OldPrice returns the old "price" 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) OldStatus

func (m *OrderMutation) OldStatus(ctx context.Context) (v int32, 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) Op

func (m *OrderMutation) Op() Op

Op returns the operation name.

func (*OrderMutation) Price

func (m *OrderMutation) Price() (r float64, exists bool)

Price returns the value of the "price" field in the mutation.

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

func (m *OrderMutation) ResetAddr()

ResetAddr resets all changes to the "addr" field.

func (*OrderMutation) ResetCreatedAt

func (m *OrderMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*OrderMutation) ResetCustomerID

func (m *OrderMutation) ResetCustomerID()

ResetCustomerID resets all changes to the "customer_id" 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) ResetPrice

func (m *OrderMutation) ResetPrice()

ResetPrice resets all changes to the "price" field.

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

func (m *OrderMutation) SetAddr(s string)

SetAddr sets the "addr" field.

func (*OrderMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*OrderMutation) SetCustomerID

func (m *OrderMutation) SetCustomerID(i int)

SetCustomerID sets the "customer_id" 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 int)

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

func (*OrderMutation) SetPrice

func (m *OrderMutation) SetPrice(f float64)

SetPrice sets the "price" field.

func (*OrderMutation) SetStatus

func (m *OrderMutation) SetStatus(i int32)

SetStatus sets the "status" field.

func (*OrderMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*OrderMutation) Status

func (m *OrderMutation) Status() (r int32, 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) Where

func (m *OrderMutation) Where(ps ...predicate.Order)

Where appends a list predicates to the OrderMutation builder.

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

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

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

func (*OrderQuery) IDs

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

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

func (*OrderQuery) IDsX

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

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 more than one Order entity is found. Returns a *NotFoundError when no Order entities are found.

func (*OrderQuery) OnlyID

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

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

func (*OrderQuery) OnlyIDX

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

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

func (oq *OrderQuery) Select(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 {
	CreatedAt time.Time `json:"created_at,omitempty"`
}

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

func (*OrderQuery) Unique

func (oq *OrderQuery) Unique(unique bool) *OrderQuery

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

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

Where adds a new predicate for the OrderQuery builder.

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 (s *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 (s *OrderSelect) BoolX(ctx context.Context) bool

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

func (*OrderSelect) Bools

func (s *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 (s *OrderSelect) BoolsX(ctx context.Context) []bool

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

func (*OrderSelect) Float64

func (s *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 (s *OrderSelect) Float64X(ctx context.Context) float64

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

func (*OrderSelect) Float64s

func (s *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 (s *OrderSelect) Float64sX(ctx context.Context) []float64

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

func (*OrderSelect) Int

func (s *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 (s *OrderSelect) IntX(ctx context.Context) int

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

func (*OrderSelect) Ints

func (s *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 (s *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 (s *OrderSelect) ScanX(ctx context.Context, v interface{})

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

func (*OrderSelect) String

func (s *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 (s *OrderSelect) StringX(ctx context.Context) string

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

func (*OrderSelect) Strings

func (s *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 (s *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) AddCustomerID

func (ou *OrderUpdate) AddCustomerID(i int) *OrderUpdate

AddCustomerID adds i to the "customer_id" field.

func (*OrderUpdate) AddPrice

func (ou *OrderUpdate) AddPrice(f float64) *OrderUpdate

AddPrice adds f to the "price" field.

func (*OrderUpdate) AddStatus

func (ou *OrderUpdate) AddStatus(i int32) *OrderUpdate

AddStatus adds i to the "status" field.

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

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

SetAddr sets the "addr" field.

func (*OrderUpdate) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*OrderUpdate) SetCustomerID

func (ou *OrderUpdate) SetCustomerID(i int) *OrderUpdate

SetCustomerID sets the "customer_id" field.

func (*OrderUpdate) SetPrice

func (ou *OrderUpdate) SetPrice(f float64) *OrderUpdate

SetPrice sets the "price" field.

func (*OrderUpdate) SetStatus

func (ou *OrderUpdate) SetStatus(i int32) *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) Where

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

Where appends a list predicates to 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) AddCustomerID

func (ouo *OrderUpdateOne) AddCustomerID(i int) *OrderUpdateOne

AddCustomerID adds i to the "customer_id" field.

func (*OrderUpdateOne) AddPrice

func (ouo *OrderUpdateOne) AddPrice(f float64) *OrderUpdateOne

AddPrice adds f to the "price" field.

func (*OrderUpdateOne) AddStatus

func (ouo *OrderUpdateOne) AddStatus(i int32) *OrderUpdateOne

AddStatus adds i to the "status" field.

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

func (ouo *OrderUpdateOne) Select(field string, fields ...string) *OrderUpdateOne

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

func (*OrderUpdateOne) SetAddr

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

SetAddr sets the "addr" field.

func (*OrderUpdateOne) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*OrderUpdateOne) SetCustomerID

func (ouo *OrderUpdateOne) SetCustomerID(i int) *OrderUpdateOne

SetCustomerID sets the "customer_id" field.

func (*OrderUpdateOne) SetPrice

func (ouo *OrderUpdateOne) SetPrice(f float64) *OrderUpdateOne

SetPrice sets the "price" field.

func (*OrderUpdateOne) SetStatus

func (ouo *OrderUpdateOne) SetStatus(i int32) *OrderUpdateOne

SetStatus sets the "status" field.

func (*OrderUpdateOne) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" 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(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Rollback(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Rollbacker

type Rollbacker interface {
	Rollback(context.Context, *Tx) error
}

Rollbacker is the interface that wraps the Rollback method.

type Tx

type Tx struct {

	// Customer is the client for interacting with the Customer builders.
	Customer *CustomerClient
	// 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 or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL