ent

package
v0.0.0-...-6f1b090 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: Apache-2.0 Imports: 30 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.
	TypeOtherTest = "OtherTest"
	TypeTest      = "Test"
)

Variables

View Source
var DefaultOtherTestOrder = &OtherTestOrder{
	Direction: OrderDirectionAsc,
	Field: &OtherTestOrderField{
		field: othertest.FieldID,
		toCursor: func(ot *OtherTest) Cursor {
			return Cursor{ID: ot.ID}
		},
	},
}

DefaultOtherTestOrder is the default ordering of OtherTest.

View Source
var DefaultTestOrder = &TestOrder{
	Direction: OrderDirectionAsc,
	Field: &TestOrderField{
		field: test.FieldID,
		toCursor: func(t *Test) Cursor {
			return Cursor{ID: t.ID}
		},
	},
}

DefaultTestOrder is the default ordering of Test.

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.

func OpenTxFromContext

func OpenTxFromContext(ctx context.Context) (context.Context, driver.Tx, error)

OpenTxFromContext open transactions from client stored in context.

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
	// OtherTest is the client for interacting with the OtherTest builders.
	OtherTest *OtherTestClient
	// Test is the client for interacting with the Test builders.
	Test *TestClient
	// 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().
	OtherTest.
	Query().
	Count(ctx)

func (*Client) Node

func (c *Client) Node(ctx context.Context, id int) (*Node, error)

func (*Client) Noder

func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error)

Noder returns a Node by its id. If the NodeType was not provided, it will be derived from the id value according to the universal-id configuration.

c.Noder(ctx, id)
c.Noder(ctx, id, ent.WithNodeType(pet.Table))

func (*Client) Noders

func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]Noder, error)

func (*Client) OpenTx

func (c *Client) OpenTx(ctx context.Context) (context.Context, driver.Tx, error)

OpenTx opens a transaction and returns a transactional context along with the created transaction.

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 Cursor

type Cursor struct {
	ID    int   `msgpack:"i"`
	Value Value `msgpack:"v,omitempty"`
}

Cursor of an edge type.

func (Cursor) MarshalGQL

func (c Cursor) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (*Cursor) UnmarshalGQL

func (c *Cursor) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements graphql.Unmarshaler interface.

type Edge

type Edge struct {
	Type string `json:"type,omitempty"` // edge type.
	Name string `json:"name,omitempty"` // edge name.
	IDs  []int  `json:"ids,omitempty"`  // node ids (where this edge point to).
}

Edges between two nodes.

type Field

type Field struct {
	Type  string `json:"type,omitempty"`  // field type.
	Name  string `json:"name,omitempty"`  // field name (as in struct).
	Value string `json:"value,omitempty"` // stringified value.
}

Field of a node.

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 Node

type Node struct {
	ID     int      `json:"id,omitempty"`     // node id.
	Type   string   `json:"type,omitempty"`   // node type.
	Fields []*Field `json:"fields,omitempty"` // node fields.
	Edges  []*Edge  `json:"edges,omitempty"`  // node edges.
}

Node in the graph.

type NodeOption

type NodeOption func(*nodeOptions)

NodeOption allows configuring the Noder execution using functional options.

func WithFixedNodeType

func WithFixedNodeType(t string) NodeOption

WithFixedNodeType sets the Type of the node to a fixed value.

func WithNodeType

func WithNodeType(f func(context.Context, int) (string, error)) NodeOption

WithNodeType sets the node Type resolver function (i.e. the table to query). If was not provided, the table will be derived from the universal-id configuration as described in: https://entgo.io/docs/migrate/#universal-ids.

type Noder

type Noder interface {
	Node(context.Context) (*Node, error)
}

Noder wraps the basic Node method.

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 OrderDirection

type OrderDirection string

OrderDirection defines the directions in which to order a list of items.

const (
	// OrderDirectionAsc specifies an ascending order.
	OrderDirectionAsc OrderDirection = "ASC"
	// OrderDirectionDesc specifies a descending order.
	OrderDirectionDesc OrderDirection = "DESC"
)

func (OrderDirection) MarshalGQL

func (o OrderDirection) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (OrderDirection) String

func (o OrderDirection) String() string

String implements fmt.Stringer interface.

func (*OrderDirection) UnmarshalGQL

func (o *OrderDirection) UnmarshalGQL(val interface{}) error

UnmarshalGQL implements graphql.Unmarshaler interface.

func (OrderDirection) Validate

func (o OrderDirection) Validate() error

Validate the order direction value.

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 OtherTest

type OtherTest struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Test holds the value of the "test" field.
	Test othertest.Test `json:"test,omitempty"`
	// contains filtered or unexported fields
}

OtherTest is the model entity for the OtherTest schema.

func (*OtherTest) Node

func (ot *OtherTest) Node(ctx context.Context) (node *Node, err error)

func (*OtherTest) String

func (ot *OtherTest) String() string

String implements the fmt.Stringer.

func (*OtherTest) ToEdge

func (ot *OtherTest) ToEdge(order *OtherTestOrder) *OtherTestEdge

ToEdge converts OtherTest into OtherTestEdge.

func (*OtherTest) Unwrap

func (ot *OtherTest) Unwrap() *OtherTest

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

func (ot *OtherTest) Update() *OtherTestUpdateOne

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

type OtherTestClient

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

OtherTestClient is a client for the OtherTest schema.

func NewOtherTestClient

func NewOtherTestClient(c config) *OtherTestClient

NewOtherTestClient returns a client for the OtherTest from the given config.

func (*OtherTestClient) Create

func (c *OtherTestClient) Create() *OtherTestCreate

Create returns a create builder for OtherTest.

func (*OtherTestClient) CreateBulk

func (c *OtherTestClient) CreateBulk(builders ...*OtherTestCreate) *OtherTestCreateBulk

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

func (*OtherTestClient) Delete

func (c *OtherTestClient) Delete() *OtherTestDelete

Delete returns a delete builder for OtherTest.

func (*OtherTestClient) DeleteOne

func (c *OtherTestClient) DeleteOne(ot *OtherTest) *OtherTestDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*OtherTestClient) DeleteOneID

func (c *OtherTestClient) DeleteOneID(id int) *OtherTestDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*OtherTestClient) Get

func (c *OtherTestClient) Get(ctx context.Context, id int) (*OtherTest, error)

Get returns a OtherTest entity by its id.

func (*OtherTestClient) GetX

func (c *OtherTestClient) GetX(ctx context.Context, id int) *OtherTest

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

func (*OtherTestClient) Hooks

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

Hooks returns the client hooks.

func (*OtherTestClient) Query

func (c *OtherTestClient) Query() *OtherTestQuery

Query returns a query builder for OtherTest.

func (*OtherTestClient) Update

func (c *OtherTestClient) Update() *OtherTestUpdate

Update returns an update builder for OtherTest.

func (*OtherTestClient) UpdateOne

func (c *OtherTestClient) UpdateOne(ot *OtherTest) *OtherTestUpdateOne

UpdateOne returns an update builder for the given entity.

func (*OtherTestClient) UpdateOneID

func (c *OtherTestClient) UpdateOneID(id int) *OtherTestUpdateOne

UpdateOneID returns an update builder for the given id.

func (*OtherTestClient) Use

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

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

type OtherTestConnection

type OtherTestConnection struct {
	Edges      []*OtherTestEdge `json:"edges"`
	PageInfo   PageInfo         `json:"pageInfo"`
	TotalCount int              `json:"totalCount"`
}

OtherTestConnection is the connection containing edges to OtherTest.

type OtherTestCreate

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

OtherTestCreate is the builder for creating a OtherTest entity.

func (*OtherTestCreate) Exec

func (otc *OtherTestCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*OtherTestCreate) ExecX

func (otc *OtherTestCreate) ExecX(ctx context.Context)

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

func (*OtherTestCreate) Mutation

func (otc *OtherTestCreate) Mutation() *OtherTestMutation

Mutation returns the OtherTestMutation object of the builder.

func (*OtherTestCreate) Save

func (otc *OtherTestCreate) Save(ctx context.Context) (*OtherTest, error)

Save creates the OtherTest in the database.

func (*OtherTestCreate) SaveX

func (otc *OtherTestCreate) SaveX(ctx context.Context) *OtherTest

SaveX calls Save and panics if Save returns an error.

func (*OtherTestCreate) SetTest

func (otc *OtherTestCreate) SetTest(o othertest.Test) *OtherTestCreate

SetTest sets the "test" field.

type OtherTestCreateBulk

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

OtherTestCreateBulk is the builder for creating many OtherTest entities in bulk.

func (*OtherTestCreateBulk) Exec

func (otcb *OtherTestCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*OtherTestCreateBulk) ExecX

func (otcb *OtherTestCreateBulk) ExecX(ctx context.Context)

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

func (*OtherTestCreateBulk) Save

func (otcb *OtherTestCreateBulk) Save(ctx context.Context) ([]*OtherTest, error)

Save creates the OtherTest entities in the database.

func (*OtherTestCreateBulk) SaveX

func (otcb *OtherTestCreateBulk) SaveX(ctx context.Context) []*OtherTest

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

type OtherTestDelete

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

OtherTestDelete is the builder for deleting a OtherTest entity.

func (*OtherTestDelete) Exec

func (otd *OtherTestDelete) Exec(ctx context.Context) (int, error)

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

func (*OtherTestDelete) ExecX

func (otd *OtherTestDelete) ExecX(ctx context.Context) int

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

func (*OtherTestDelete) Where

Where appends a list predicates to the OtherTestDelete builder.

type OtherTestDeleteOne

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

OtherTestDeleteOne is the builder for deleting a single OtherTest entity.

func (*OtherTestDeleteOne) Exec

func (otdo *OtherTestDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*OtherTestDeleteOne) ExecX

func (otdo *OtherTestDeleteOne) ExecX(ctx context.Context)

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

type OtherTestEdge

type OtherTestEdge struct {
	Node   *OtherTest `json:"node"`
	Cursor Cursor     `json:"cursor"`
}

OtherTestEdge is the edge representation of OtherTest.

type OtherTestGroupBy

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

OtherTestGroupBy is the group-by builder for OtherTest entities.

func (*OtherTestGroupBy) Aggregate

func (otgb *OtherTestGroupBy) Aggregate(fns ...AggregateFunc) *OtherTestGroupBy

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

func (*OtherTestGroupBy) Bool

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) BoolX

func (otgb *OtherTestGroupBy) BoolX(ctx context.Context) bool

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

func (*OtherTestGroupBy) Bools

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) BoolsX

func (otgb *OtherTestGroupBy) BoolsX(ctx context.Context) []bool

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

func (*OtherTestGroupBy) Float64

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) Float64X

func (otgb *OtherTestGroupBy) Float64X(ctx context.Context) float64

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

func (*OtherTestGroupBy) Float64s

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) Float64sX

func (otgb *OtherTestGroupBy) Float64sX(ctx context.Context) []float64

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

func (*OtherTestGroupBy) Int

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) IntX

func (otgb *OtherTestGroupBy) IntX(ctx context.Context) int

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

func (*OtherTestGroupBy) Ints

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) IntsX

func (otgb *OtherTestGroupBy) IntsX(ctx context.Context) []int

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

func (*OtherTestGroupBy) Scan

func (otgb *OtherTestGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*OtherTestGroupBy) ScanX

func (otgb *OtherTestGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*OtherTestGroupBy) String

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) StringX

func (otgb *OtherTestGroupBy) StringX(ctx context.Context) string

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

func (*OtherTestGroupBy) Strings

func (otgb *OtherTestGroupBy) 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 (*OtherTestGroupBy) StringsX

func (otgb *OtherTestGroupBy) StringsX(ctx context.Context) []string

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

type OtherTestMutation

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

OtherTestMutation represents an operation that mutates the OtherTest nodes in the graph.

func (*OtherTestMutation) AddField

func (m *OtherTestMutation) 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 (*OtherTestMutation) AddedEdges

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

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

func (*OtherTestMutation) AddedField

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

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

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

func (*OtherTestMutation) AddedIDs

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

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

func (*OtherTestMutation) ClearEdge

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

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

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

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

func (*OtherTestMutation) ClearedFields

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

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

func (OtherTestMutation) Client

func (m OtherTestMutation) 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 (*OtherTestMutation) EdgeCleared

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

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

func (*OtherTestMutation) Field

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

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

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

func (*OtherTestMutation) Fields

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

func (m *OtherTestMutation) 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 (*OtherTestMutation) OldField

func (m *OtherTestMutation) 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 (*OtherTestMutation) OldTest

func (m *OtherTestMutation) OldTest(ctx context.Context) (v othertest.Test, err error)

OldTest returns the old "test" field's value of the OtherTest entity. If the OtherTest 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 (*OtherTestMutation) Op

func (m *OtherTestMutation) Op() Op

Op returns the operation name.

func (*OtherTestMutation) RemovedEdges

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

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

func (*OtherTestMutation) RemovedIDs

func (m *OtherTestMutation) 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 (*OtherTestMutation) ResetEdge

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

func (m *OtherTestMutation) 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 (*OtherTestMutation) ResetTest

func (m *OtherTestMutation) ResetTest()

ResetTest resets all changes to the "test" field.

func (*OtherTestMutation) SetField

func (m *OtherTestMutation) 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 (*OtherTestMutation) SetTest

func (m *OtherTestMutation) SetTest(o othertest.Test)

SetTest sets the "test" field.

func (*OtherTestMutation) Test

func (m *OtherTestMutation) Test() (r othertest.Test, exists bool)

Test returns the value of the "test" field in the mutation.

func (OtherTestMutation) Tx

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

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

func (*OtherTestMutation) Type

func (m *OtherTestMutation) Type() string

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

func (*OtherTestMutation) Where

func (m *OtherTestMutation) Where(ps ...predicate.OtherTest)

Where appends a list predicates to the OtherTestMutation builder.

type OtherTestOrder

type OtherTestOrder struct {
	Direction OrderDirection       `json:"direction"`
	Field     *OtherTestOrderField `json:"field"`
}

OtherTestOrder defines the ordering of OtherTest.

type OtherTestOrderField

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

OtherTestOrderField defines the ordering field of OtherTest.

type OtherTestPaginateOption

type OtherTestPaginateOption func(*otherTestPager) error

OtherTestPaginateOption enables pagination customization.

func WithOtherTestFilter

func WithOtherTestFilter(filter func(*OtherTestQuery) (*OtherTestQuery, error)) OtherTestPaginateOption

WithOtherTestFilter configures pagination filter.

func WithOtherTestOrder

func WithOtherTestOrder(order *OtherTestOrder) OtherTestPaginateOption

WithOtherTestOrder configures pagination ordering.

type OtherTestQuery

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

OtherTestQuery is the builder for querying OtherTest entities.

func (*OtherTestQuery) All

func (otq *OtherTestQuery) All(ctx context.Context) ([]*OtherTest, error)

All executes the query and returns a list of OtherTests.

func (*OtherTestQuery) AllX

func (otq *OtherTestQuery) AllX(ctx context.Context) []*OtherTest

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

func (*OtherTestQuery) Clone

func (otq *OtherTestQuery) Clone() *OtherTestQuery

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

func (*OtherTestQuery) CollectFields

func (ot *OtherTestQuery) CollectFields(ctx context.Context, satisfies ...string) *OtherTestQuery

CollectFields tells the query-builder to eagerly load connected nodes by resolver context.

func (*OtherTestQuery) Count

func (otq *OtherTestQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*OtherTestQuery) CountX

func (otq *OtherTestQuery) CountX(ctx context.Context) int

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

func (*OtherTestQuery) Exist

func (otq *OtherTestQuery) Exist(ctx context.Context) (bool, error)

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

func (*OtherTestQuery) ExistX

func (otq *OtherTestQuery) ExistX(ctx context.Context) bool

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

func (*OtherTestQuery) First

func (otq *OtherTestQuery) First(ctx context.Context) (*OtherTest, error)

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

func (*OtherTestQuery) FirstID

func (otq *OtherTestQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*OtherTestQuery) FirstIDX

func (otq *OtherTestQuery) FirstIDX(ctx context.Context) int

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

func (*OtherTestQuery) FirstX

func (otq *OtherTestQuery) FirstX(ctx context.Context) *OtherTest

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

func (*OtherTestQuery) GroupBy

func (otq *OtherTestQuery) GroupBy(field string, fields ...string) *OtherTestGroupBy

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 {
	Test othertest.Test `json:"test,omitempty"`
	Count int `json:"count,omitempty"`
}

client.OtherTest.Query().
	GroupBy(othertest.FieldTest).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*OtherTestQuery) IDs

func (otq *OtherTestQuery) IDs(ctx context.Context) ([]int, error)

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

func (*OtherTestQuery) IDsX

func (otq *OtherTestQuery) IDsX(ctx context.Context) []int

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

func (*OtherTestQuery) Limit

func (otq *OtherTestQuery) Limit(limit int) *OtherTestQuery

Limit adds a limit step to the query.

func (*OtherTestQuery) Offset

func (otq *OtherTestQuery) Offset(offset int) *OtherTestQuery

Offset adds an offset step to the query.

func (*OtherTestQuery) Only

func (otq *OtherTestQuery) Only(ctx context.Context) (*OtherTest, error)

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

func (*OtherTestQuery) OnlyID

func (otq *OtherTestQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*OtherTestQuery) OnlyIDX

func (otq *OtherTestQuery) OnlyIDX(ctx context.Context) int

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

func (*OtherTestQuery) OnlyX

func (otq *OtherTestQuery) OnlyX(ctx context.Context) *OtherTest

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

func (*OtherTestQuery) Order

func (otq *OtherTestQuery) Order(o ...OrderFunc) *OtherTestQuery

Order adds an order step to the query.

func (*OtherTestQuery) Paginate

func (ot *OtherTestQuery) Paginate(
	ctx context.Context, after *Cursor, first *int,
	before *Cursor, last *int, opts ...OtherTestPaginateOption,
) (*OtherTestConnection, error)

Paginate executes the query and returns a relay based cursor connection to OtherTest.

func (*OtherTestQuery) Select

func (otq *OtherTestQuery) Select(fields ...string) *OtherTestSelect

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 {
	Test othertest.Test `json:"test,omitempty"`
}

client.OtherTest.Query().
	Select(othertest.FieldTest).
	Scan(ctx, &v)

func (*OtherTestQuery) Unique

func (otq *OtherTestQuery) Unique(unique bool) *OtherTestQuery

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

func (otq *OtherTestQuery) Where(ps ...predicate.OtherTest) *OtherTestQuery

Where adds a new predicate for the OtherTestQuery builder.

type OtherTestSelect

type OtherTestSelect struct {
	*OtherTestQuery
	// contains filtered or unexported fields
}

OtherTestSelect is the builder for selecting fields of OtherTest entities.

func (*OtherTestSelect) Bool

func (ots *OtherTestSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*OtherTestSelect) BoolX

func (ots *OtherTestSelect) BoolX(ctx context.Context) bool

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

func (*OtherTestSelect) Bools

func (ots *OtherTestSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*OtherTestSelect) BoolsX

func (ots *OtherTestSelect) BoolsX(ctx context.Context) []bool

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

func (*OtherTestSelect) Float64

func (ots *OtherTestSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*OtherTestSelect) Float64X

func (ots *OtherTestSelect) Float64X(ctx context.Context) float64

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

func (*OtherTestSelect) Float64s

func (ots *OtherTestSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*OtherTestSelect) Float64sX

func (ots *OtherTestSelect) Float64sX(ctx context.Context) []float64

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

func (*OtherTestSelect) Int

func (ots *OtherTestSelect) Int(ctx context.Context) (_ int, err error)

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

func (*OtherTestSelect) IntX

func (ots *OtherTestSelect) IntX(ctx context.Context) int

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

func (*OtherTestSelect) Ints

func (ots *OtherTestSelect) Ints(ctx context.Context) ([]int, error)

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

func (*OtherTestSelect) IntsX

func (ots *OtherTestSelect) IntsX(ctx context.Context) []int

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

func (*OtherTestSelect) Scan

func (ots *OtherTestSelect) Scan(ctx context.Context, v interface{}) error

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

func (*OtherTestSelect) ScanX

func (ots *OtherTestSelect) ScanX(ctx context.Context, v interface{})

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

func (*OtherTestSelect) String

func (ots *OtherTestSelect) String(ctx context.Context) (_ string, err error)

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

func (*OtherTestSelect) StringX

func (ots *OtherTestSelect) StringX(ctx context.Context) string

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

func (*OtherTestSelect) Strings

func (ots *OtherTestSelect) Strings(ctx context.Context) ([]string, error)

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

func (*OtherTestSelect) StringsX

func (ots *OtherTestSelect) StringsX(ctx context.Context) []string

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

type OtherTestUpdate

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

OtherTestUpdate is the builder for updating OtherTest entities.

func (*OtherTestUpdate) Exec

func (otu *OtherTestUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*OtherTestUpdate) ExecX

func (otu *OtherTestUpdate) ExecX(ctx context.Context)

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

func (*OtherTestUpdate) Mutation

func (otu *OtherTestUpdate) Mutation() *OtherTestMutation

Mutation returns the OtherTestMutation object of the builder.

func (*OtherTestUpdate) Save

func (otu *OtherTestUpdate) Save(ctx context.Context) (int, error)

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

func (*OtherTestUpdate) SaveX

func (otu *OtherTestUpdate) SaveX(ctx context.Context) int

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

func (*OtherTestUpdate) SetTest

func (otu *OtherTestUpdate) SetTest(o othertest.Test) *OtherTestUpdate

SetTest sets the "test" field.

func (*OtherTestUpdate) Where

Where appends a list predicates to the OtherTestUpdate builder.

type OtherTestUpdateOne

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

OtherTestUpdateOne is the builder for updating a single OtherTest entity.

func (*OtherTestUpdateOne) Exec

func (otuo *OtherTestUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*OtherTestUpdateOne) ExecX

func (otuo *OtherTestUpdateOne) ExecX(ctx context.Context)

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

func (*OtherTestUpdateOne) Mutation

func (otuo *OtherTestUpdateOne) Mutation() *OtherTestMutation

Mutation returns the OtherTestMutation object of the builder.

func (*OtherTestUpdateOne) Save

func (otuo *OtherTestUpdateOne) Save(ctx context.Context) (*OtherTest, error)

Save executes the query and returns the updated OtherTest entity.

func (*OtherTestUpdateOne) SaveX

func (otuo *OtherTestUpdateOne) SaveX(ctx context.Context) *OtherTest

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

func (*OtherTestUpdateOne) Select

func (otuo *OtherTestUpdateOne) Select(field string, fields ...string) *OtherTestUpdateOne

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

func (*OtherTestUpdateOne) SetTest

SetTest sets the "test" field.

type OtherTestWhereInput

type OtherTestWhereInput struct {
	Not *OtherTestWhereInput   `json:"not,omitempty"`
	Or  []*OtherTestWhereInput `json:"or,omitempty"`
	And []*OtherTestWhereInput `json:"and,omitempty"`

	// "id" field predicates.
	ID      *int  `json:"id,omitempty"`
	IDNEQ   *int  `json:"idNEQ,omitempty"`
	IDIn    []int `json:"idIn,omitempty"`
	IDNotIn []int `json:"idNotIn,omitempty"`
	IDGT    *int  `json:"idGT,omitempty"`
	IDGTE   *int  `json:"idGTE,omitempty"`
	IDLT    *int  `json:"idLT,omitempty"`
	IDLTE   *int  `json:"idLTE,omitempty"`

	// "test" field predicates.
	Test      *othertest.Test  `json:"test,omitempty"`
	TestNEQ   *othertest.Test  `json:"testNEQ,omitempty"`
	TestIn    []othertest.Test `json:"testIn,omitempty"`
	TestNotIn []othertest.Test `json:"testNotIn,omitempty"`
}

OtherTestWhereInput represents a where input for filtering OtherTest queries.

func (*OtherTestWhereInput) Filter

Filter applies the OtherTestWhereInput filter on the OtherTestQuery builder.

func (*OtherTestWhereInput) P

P returns a predicate for filtering othertests. An error is returned if the input is empty or invalid.

type OtherTests

type OtherTests []*OtherTest

OtherTests is a parsable slice of OtherTest.

type PageInfo

type PageInfo struct {
	HasNextPage     bool    `json:"hasNextPage"`
	HasPreviousPage bool    `json:"hasPreviousPage"`
	StartCursor     *Cursor `json:"startCursor"`
	EndCursor       *Cursor `json:"endCursor"`
}

PageInfo of a connection type.

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 Test

type Test struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Test holds the value of the "test" field.
	Test test.Test `json:"test,omitempty"`
	// contains filtered or unexported fields
}

Test is the model entity for the Test schema.

func (*Test) Node

func (t *Test) Node(ctx context.Context) (node *Node, err error)

func (*Test) String

func (t *Test) String() string

String implements the fmt.Stringer.

func (*Test) ToEdge

func (t *Test) ToEdge(order *TestOrder) *TestEdge

ToEdge converts Test into TestEdge.

func (*Test) Unwrap

func (t *Test) Unwrap() *Test

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

func (t *Test) Update() *TestUpdateOne

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

type TestClient

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

TestClient is a client for the Test schema.

func NewTestClient

func NewTestClient(c config) *TestClient

NewTestClient returns a client for the Test from the given config.

func (*TestClient) Create

func (c *TestClient) Create() *TestCreate

Create returns a create builder for Test.

func (*TestClient) CreateBulk

func (c *TestClient) CreateBulk(builders ...*TestCreate) *TestCreateBulk

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

func (*TestClient) Delete

func (c *TestClient) Delete() *TestDelete

Delete returns a delete builder for Test.

func (*TestClient) DeleteOne

func (c *TestClient) DeleteOne(t *Test) *TestDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*TestClient) DeleteOneID

func (c *TestClient) DeleteOneID(id int) *TestDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*TestClient) Get

func (c *TestClient) Get(ctx context.Context, id int) (*Test, error)

Get returns a Test entity by its id.

func (*TestClient) GetX

func (c *TestClient) GetX(ctx context.Context, id int) *Test

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

func (*TestClient) Hooks

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

Hooks returns the client hooks.

func (*TestClient) Query

func (c *TestClient) Query() *TestQuery

Query returns a query builder for Test.

func (*TestClient) Update

func (c *TestClient) Update() *TestUpdate

Update returns an update builder for Test.

func (*TestClient) UpdateOne

func (c *TestClient) UpdateOne(t *Test) *TestUpdateOne

UpdateOne returns an update builder for the given entity.

func (*TestClient) UpdateOneID

func (c *TestClient) UpdateOneID(id int) *TestUpdateOne

UpdateOneID returns an update builder for the given id.

func (*TestClient) Use

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

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

type TestConnection

type TestConnection struct {
	Edges      []*TestEdge `json:"edges"`
	PageInfo   PageInfo    `json:"pageInfo"`
	TotalCount int         `json:"totalCount"`
}

TestConnection is the connection containing edges to Test.

type TestCreate

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

TestCreate is the builder for creating a Test entity.

func (*TestCreate) Exec

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

Exec executes the query.

func (*TestCreate) ExecX

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

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

func (*TestCreate) Mutation

func (tc *TestCreate) Mutation() *TestMutation

Mutation returns the TestMutation object of the builder.

func (*TestCreate) Save

func (tc *TestCreate) Save(ctx context.Context) (*Test, error)

Save creates the Test in the database.

func (*TestCreate) SaveX

func (tc *TestCreate) SaveX(ctx context.Context) *Test

SaveX calls Save and panics if Save returns an error.

func (*TestCreate) SetTest

func (tc *TestCreate) SetTest(t test.Test) *TestCreate

SetTest sets the "test" field.

type TestCreateBulk

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

TestCreateBulk is the builder for creating many Test entities in bulk.

func (*TestCreateBulk) Exec

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

Exec executes the query.

func (*TestCreateBulk) ExecX

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

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

func (*TestCreateBulk) Save

func (tcb *TestCreateBulk) Save(ctx context.Context) ([]*Test, error)

Save creates the Test entities in the database.

func (*TestCreateBulk) SaveX

func (tcb *TestCreateBulk) SaveX(ctx context.Context) []*Test

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

type TestDelete

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

TestDelete is the builder for deleting a Test entity.

func (*TestDelete) Exec

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

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

func (*TestDelete) ExecX

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

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

func (*TestDelete) Where

func (td *TestDelete) Where(ps ...predicate.Test) *TestDelete

Where appends a list predicates to the TestDelete builder.

type TestDeleteOne

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

TestDeleteOne is the builder for deleting a single Test entity.

func (*TestDeleteOne) Exec

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

Exec executes the deletion query.

func (*TestDeleteOne) ExecX

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

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

type TestEdge

type TestEdge struct {
	Node   *Test  `json:"node"`
	Cursor Cursor `json:"cursor"`
}

TestEdge is the edge representation of Test.

type TestGroupBy

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

TestGroupBy is the group-by builder for Test entities.

func (*TestGroupBy) Aggregate

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

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

func (*TestGroupBy) Bool

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

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

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

func (*TestGroupBy) Bools

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

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

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

func (*TestGroupBy) Float64

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

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

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

func (*TestGroupBy) Float64s

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

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

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

func (*TestGroupBy) Int

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

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

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

func (*TestGroupBy) Ints

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

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

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

func (*TestGroupBy) Scan

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

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

func (*TestGroupBy) ScanX

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

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

func (*TestGroupBy) String

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

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

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

func (*TestGroupBy) Strings

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

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

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

type TestMutation

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

TestMutation represents an operation that mutates the Test nodes in the graph.

func (*TestMutation) AddField

func (m *TestMutation) 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 (*TestMutation) AddedEdges

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

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

func (*TestMutation) AddedField

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

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

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

func (*TestMutation) AddedIDs

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

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

func (*TestMutation) ClearEdge

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

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

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

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

func (*TestMutation) ClearedFields

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

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

func (TestMutation) Client

func (m TestMutation) 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 (*TestMutation) EdgeCleared

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

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

func (*TestMutation) Field

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

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

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

func (*TestMutation) Fields

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

func (m *TestMutation) 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 (*TestMutation) OldField

func (m *TestMutation) 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 (*TestMutation) OldTest

func (m *TestMutation) OldTest(ctx context.Context) (v test.Test, err error)

OldTest returns the old "test" field's value of the Test entity. If the Test 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 (*TestMutation) Op

func (m *TestMutation) Op() Op

Op returns the operation name.

func (*TestMutation) RemovedEdges

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

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

func (*TestMutation) RemovedIDs

func (m *TestMutation) 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 (*TestMutation) ResetEdge

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

func (m *TestMutation) 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 (*TestMutation) ResetTest

func (m *TestMutation) ResetTest()

ResetTest resets all changes to the "test" field.

func (*TestMutation) SetField

func (m *TestMutation) 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 (*TestMutation) SetTest

func (m *TestMutation) SetTest(t test.Test)

SetTest sets the "test" field.

func (*TestMutation) Test

func (m *TestMutation) Test() (r test.Test, exists bool)

Test returns the value of the "test" field in the mutation.

func (TestMutation) Tx

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

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

func (*TestMutation) Type

func (m *TestMutation) Type() string

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

func (*TestMutation) Where

func (m *TestMutation) Where(ps ...predicate.Test)

Where appends a list predicates to the TestMutation builder.

type TestOrder

type TestOrder struct {
	Direction OrderDirection  `json:"direction"`
	Field     *TestOrderField `json:"field"`
}

TestOrder defines the ordering of Test.

type TestOrderField

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

TestOrderField defines the ordering field of Test.

type TestPaginateOption

type TestPaginateOption func(*testPager) error

TestPaginateOption enables pagination customization.

func WithTestFilter

func WithTestFilter(filter func(*TestQuery) (*TestQuery, error)) TestPaginateOption

WithTestFilter configures pagination filter.

func WithTestOrder

func WithTestOrder(order *TestOrder) TestPaginateOption

WithTestOrder configures pagination ordering.

type TestQuery

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

TestQuery is the builder for querying Test entities.

func (*TestQuery) All

func (tq *TestQuery) All(ctx context.Context) ([]*Test, error)

All executes the query and returns a list of Tests.

func (*TestQuery) AllX

func (tq *TestQuery) AllX(ctx context.Context) []*Test

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

func (*TestQuery) Clone

func (tq *TestQuery) Clone() *TestQuery

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

func (*TestQuery) CollectFields

func (t *TestQuery) CollectFields(ctx context.Context, satisfies ...string) *TestQuery

CollectFields tells the query-builder to eagerly load connected nodes by resolver context.

func (*TestQuery) Count

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

Count returns the count of the given query.

func (*TestQuery) CountX

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

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

func (*TestQuery) Exist

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

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

func (*TestQuery) ExistX

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

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

func (*TestQuery) First

func (tq *TestQuery) First(ctx context.Context) (*Test, error)

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

func (*TestQuery) FirstID

func (tq *TestQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*TestQuery) FirstIDX

func (tq *TestQuery) FirstIDX(ctx context.Context) int

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

func (*TestQuery) FirstX

func (tq *TestQuery) FirstX(ctx context.Context) *Test

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

func (*TestQuery) GroupBy

func (tq *TestQuery) GroupBy(field string, fields ...string) *TestGroupBy

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 {
	Test test.Test `json:"test,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Test.Query().
	GroupBy(test.FieldTest).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*TestQuery) IDs

func (tq *TestQuery) IDs(ctx context.Context) ([]int, error)

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

func (*TestQuery) IDsX

func (tq *TestQuery) IDsX(ctx context.Context) []int

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

func (*TestQuery) Limit

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

Limit adds a limit step to the query.

func (*TestQuery) Offset

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

Offset adds an offset step to the query.

func (*TestQuery) Only

func (tq *TestQuery) Only(ctx context.Context) (*Test, error)

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

func (*TestQuery) OnlyID

func (tq *TestQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*TestQuery) OnlyIDX

func (tq *TestQuery) OnlyIDX(ctx context.Context) int

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

func (*TestQuery) OnlyX

func (tq *TestQuery) OnlyX(ctx context.Context) *Test

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

func (*TestQuery) Order

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

Order adds an order step to the query.

func (*TestQuery) Paginate

func (t *TestQuery) Paginate(
	ctx context.Context, after *Cursor, first *int,
	before *Cursor, last *int, opts ...TestPaginateOption,
) (*TestConnection, error)

Paginate executes the query and returns a relay based cursor connection to Test.

func (*TestQuery) Select

func (tq *TestQuery) Select(fields ...string) *TestSelect

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 {
	Test test.Test `json:"test,omitempty"`
}

client.Test.Query().
	Select(test.FieldTest).
	Scan(ctx, &v)

func (*TestQuery) Unique

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

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

func (tq *TestQuery) Where(ps ...predicate.Test) *TestQuery

Where adds a new predicate for the TestQuery builder.

type TestSelect

type TestSelect struct {
	*TestQuery
	// contains filtered or unexported fields
}

TestSelect is the builder for selecting fields of Test entities.

func (*TestSelect) Bool

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

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

func (*TestSelect) BoolX

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

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

func (*TestSelect) Bools

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

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

func (*TestSelect) BoolsX

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

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

func (*TestSelect) Float64

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

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

func (*TestSelect) Float64X

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

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

func (*TestSelect) Float64s

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

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

func (*TestSelect) Float64sX

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

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

func (*TestSelect) Int

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

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

func (*TestSelect) IntX

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

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

func (*TestSelect) Ints

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

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

func (*TestSelect) IntsX

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

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

func (*TestSelect) Scan

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

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

func (*TestSelect) ScanX

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

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

func (*TestSelect) String

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

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

func (*TestSelect) StringX

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

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

func (*TestSelect) Strings

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

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

func (*TestSelect) StringsX

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

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

type TestUpdate

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

TestUpdate is the builder for updating Test entities.

func (*TestUpdate) Exec

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

Exec executes the query.

func (*TestUpdate) ExecX

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

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

func (*TestUpdate) Mutation

func (tu *TestUpdate) Mutation() *TestMutation

Mutation returns the TestMutation object of the builder.

func (*TestUpdate) Save

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

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

func (*TestUpdate) SaveX

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

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

func (*TestUpdate) SetTest

func (tu *TestUpdate) SetTest(t test.Test) *TestUpdate

SetTest sets the "test" field.

func (*TestUpdate) Where

func (tu *TestUpdate) Where(ps ...predicate.Test) *TestUpdate

Where appends a list predicates to the TestUpdate builder.

type TestUpdateOne

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

TestUpdateOne is the builder for updating a single Test entity.

func (*TestUpdateOne) Exec

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

Exec executes the query on the entity.

func (*TestUpdateOne) ExecX

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

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

func (*TestUpdateOne) Mutation

func (tuo *TestUpdateOne) Mutation() *TestMutation

Mutation returns the TestMutation object of the builder.

func (*TestUpdateOne) Save

func (tuo *TestUpdateOne) Save(ctx context.Context) (*Test, error)

Save executes the query and returns the updated Test entity.

func (*TestUpdateOne) SaveX

func (tuo *TestUpdateOne) SaveX(ctx context.Context) *Test

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

func (*TestUpdateOne) Select

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

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

func (*TestUpdateOne) SetTest

func (tuo *TestUpdateOne) SetTest(t test.Test) *TestUpdateOne

SetTest sets the "test" field.

type TestWhereInput

type TestWhereInput struct {
	Not *TestWhereInput   `json:"not,omitempty"`
	Or  []*TestWhereInput `json:"or,omitempty"`
	And []*TestWhereInput `json:"and,omitempty"`

	// "id" field predicates.
	ID      *int  `json:"id,omitempty"`
	IDNEQ   *int  `json:"idNEQ,omitempty"`
	IDIn    []int `json:"idIn,omitempty"`
	IDNotIn []int `json:"idNotIn,omitempty"`
	IDGT    *int  `json:"idGT,omitempty"`
	IDGTE   *int  `json:"idGTE,omitempty"`
	IDLT    *int  `json:"idLT,omitempty"`
	IDLTE   *int  `json:"idLTE,omitempty"`

	// "test" field predicates.
	Test      *test.Test  `json:"test,omitempty"`
	TestNEQ   *test.Test  `json:"testNEQ,omitempty"`
	TestIn    []test.Test `json:"testIn,omitempty"`
	TestNotIn []test.Test `json:"testNotIn,omitempty"`
}

TestWhereInput represents a where input for filtering Test queries.

func (*TestWhereInput) Filter

func (i *TestWhereInput) Filter(q *TestQuery) (*TestQuery, error)

Filter applies the TestWhereInput filter on the TestQuery builder.

func (*TestWhereInput) P

func (i *TestWhereInput) P() (predicate.Test, error)

P returns a predicate for filtering tests. An error is returned if the input is empty or invalid.

type Tests

type Tests []*Test

Tests is a parsable slice of Test.

type Tx

type Tx struct {

	// OtherTest is the client for interacting with the OtherTest builders.
	OtherTest *OtherTestClient
	// Test is the client for interacting with the Test builders.
	Test *TestClient
	// 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