db

package
v1.0.0-beta.106 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypeExample1 = "Example1"
)

Variables

View Source
var ErrTxStarted = errors.New("db: cannot start a transaction within a transaction")

ErrTxStarted is returned when trying to start a new transaction from a transactional client.

Functions

func Asc

func Asc(fields ...string) func(*sql.Selector)

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) func(*sql.Selector)

Desc applies the given fields in DESC order.

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(db.As(db.Sum(field1), "sum_field1"), (db.As(db.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
	// Example1 is the client for interacting with the Example1 builders.
	Example1 *Example1Client
	// 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().
	Example1.
	Query().
	Count(ctx)

func (*Client) GetConfig

func (c *Client) GetConfig() *entutils.RawEntConfig

func (*Client) HijackTx

HijackTx returns a new transaction driver with the provided options. The returned transaction can later be used to instanciate new clients.

func (*Client) Intercept

func (c *Client) Intercept(interceptors ...Interceptor)

Intercept adds the query interceptors to all the entity clients. In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error)

Mutate implements the ent.Mutator interface.

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 Example1

type Example1 struct {

	// ID of the ent.
	ID string `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"`
	// DeletedAt holds the value of the "deleted_at" field.
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
	// ExampleValue1 holds the value of the "example_value_1" field.
	ExampleValue1 string `json:"example_value_1,omitempty"`
	// contains filtered or unexported fields
}

Example1 is the model entity for the Example1 schema.

func (*Example1) String

func (e *Example1) String() string

String implements the fmt.Stringer.

func (*Example1) Unwrap

func (e *Example1) Unwrap() *Example1

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

func (e *Example1) Update() *Example1UpdateOne

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

func (*Example1) Value

func (e *Example1) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the Example1. This includes values selected through modifiers, order, etc.

type Example1Client

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

Example1Client is a client for the Example1 schema.

func NewExample1Client

func NewExample1Client(c config) *Example1Client

NewExample1Client returns a client for the Example1 from the given config.

func (*Example1Client) Create

func (c *Example1Client) Create() *Example1Create

Create returns a builder for creating a Example1 entity.

func (*Example1Client) CreateBulk

func (c *Example1Client) CreateBulk(builders ...*Example1Create) *Example1CreateBulk

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

func (*Example1Client) Delete

func (c *Example1Client) Delete() *Example1Delete

Delete returns a delete builder for Example1.

func (*Example1Client) DeleteOne

func (c *Example1Client) DeleteOne(e *Example1) *Example1DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*Example1Client) DeleteOneID

func (c *Example1Client) DeleteOneID(id string) *Example1DeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*Example1Client) Get

func (c *Example1Client) Get(ctx context.Context, id string) (*Example1, error)

Get returns a Example1 entity by its id.

func (*Example1Client) GetX

func (c *Example1Client) GetX(ctx context.Context, id string) *Example1

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

func (*Example1Client) Hooks

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

Hooks returns the client hooks.

func (*Example1Client) Intercept

func (c *Example1Client) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `example1.Intercept(f(g(h())))`.

func (*Example1Client) Interceptors

func (c *Example1Client) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*Example1Client) MapCreateBulk

func (c *Example1Client) MapCreateBulk(slice any, setFunc func(*Example1Create, int)) *Example1CreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*Example1Client) Query

func (c *Example1Client) Query() *Example1Query

Query returns a query builder for Example1.

func (*Example1Client) Update

func (c *Example1Client) Update() *Example1Update

Update returns an update builder for Example1.

func (*Example1Client) UpdateOne

func (c *Example1Client) UpdateOne(e *Example1) *Example1UpdateOne

UpdateOne returns an update builder for the given entity.

func (*Example1Client) UpdateOneID

func (c *Example1Client) UpdateOneID(id string) *Example1UpdateOne

UpdateOneID returns an update builder for the given id.

func (*Example1Client) Use

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

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

type Example1Create

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

Example1Create is the builder for creating a Example1 entity.

func (*Example1Create) Exec

func (e *Example1Create) Exec(ctx context.Context) error

Exec executes the query.

func (*Example1Create) ExecX

func (e *Example1Create) ExecX(ctx context.Context)

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

func (*Example1Create) Mutation

func (e *Example1Create) Mutation() *Example1Mutation

Mutation returns the Example1Mutation object of the builder.

func (*Example1Create) OnConflict

func (e *Example1Create) OnConflict(opts ...sql.ConflictOption) *Example1UpsertOne

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.Example1.Create().
	SetCreatedAt(v).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.Example1Upsert) {
		SetCreatedAt(v+v).
	}).
	Exec(ctx)

func (*Example1Create) OnConflictColumns

func (e *Example1Create) OnConflictColumns(columns ...string) *Example1UpsertOne

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.Example1.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*Example1Create) Save

func (e *Example1Create) Save(ctx context.Context) (*Example1, error)

Save creates the Example1 in the database.

func (*Example1Create) SaveX

func (e *Example1Create) SaveX(ctx context.Context) *Example1

SaveX calls Save and panics if Save returns an error.

func (*Example1Create) SetCreatedAt

func (e *Example1Create) SetCreatedAt(t time.Time) *Example1Create

SetCreatedAt sets the "created_at" field.

func (*Example1Create) SetDeletedAt

func (e *Example1Create) SetDeletedAt(t time.Time) *Example1Create

SetDeletedAt sets the "deleted_at" field.

func (*Example1Create) SetExampleValue1

func (e *Example1Create) SetExampleValue1(s string) *Example1Create

SetExampleValue1 sets the "example_value_1" field.

func (*Example1Create) SetID

func (e *Example1Create) SetID(s string) *Example1Create

SetID sets the "id" field.

func (*Example1Create) SetNillableCreatedAt

func (e *Example1Create) SetNillableCreatedAt(t *time.Time) *Example1Create

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

func (*Example1Create) SetNillableDeletedAt

func (e *Example1Create) SetNillableDeletedAt(t *time.Time) *Example1Create

SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.

func (*Example1Create) SetNillableUpdatedAt

func (e *Example1Create) SetNillableUpdatedAt(t *time.Time) *Example1Create

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

func (*Example1Create) SetUpdatedAt

func (e *Example1Create) SetUpdatedAt(t time.Time) *Example1Create

SetUpdatedAt sets the "updated_at" field.

type Example1CreateBulk

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

Example1CreateBulk is the builder for creating many Example1 entities in bulk.

func (*Example1CreateBulk) Exec

func (eb *Example1CreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*Example1CreateBulk) ExecX

func (eb *Example1CreateBulk) ExecX(ctx context.Context)

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

func (*Example1CreateBulk) OnConflict

func (eb *Example1CreateBulk) OnConflict(opts ...sql.ConflictOption) *Example1UpsertBulk

OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:

client.Example1.CreateBulk(builders...).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.Example1Upsert) {
		SetCreatedAt(v+v).
	}).
	Exec(ctx)

func (*Example1CreateBulk) OnConflictColumns

func (eb *Example1CreateBulk) OnConflictColumns(columns ...string) *Example1UpsertBulk

OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:

client.Example1.Create().
	OnConflict(sql.ConflictColumns(columns...)).
	Exec(ctx)

func (*Example1CreateBulk) Save

func (eb *Example1CreateBulk) Save(ctx context.Context) ([]*Example1, error)

Save creates the Example1 entities in the database.

func (*Example1CreateBulk) SaveX

func (eb *Example1CreateBulk) SaveX(ctx context.Context) []*Example1

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

type Example1Delete

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

Example1Delete is the builder for deleting a Example1 entity.

func (*Example1Delete) Exec

func (e *Example1Delete) Exec(ctx context.Context) (int, error)

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

func (*Example1Delete) ExecX

func (e *Example1Delete) ExecX(ctx context.Context) int

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

func (*Example1Delete) Where

Where appends a list predicates to the Example1Delete builder.

type Example1DeleteOne

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

Example1DeleteOne is the builder for deleting a single Example1 entity.

func (*Example1DeleteOne) Exec

func (eo *Example1DeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*Example1DeleteOne) ExecX

func (eo *Example1DeleteOne) ExecX(ctx context.Context)

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

func (*Example1DeleteOne) Where

Where appends a list predicates to the Example1Delete builder.

type Example1GroupBy

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

Example1GroupBy is the group-by builder for Example1 entities.

func (*Example1GroupBy) Aggregate

func (eb *Example1GroupBy) Aggregate(fns ...AggregateFunc) *Example1GroupBy

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

func (*Example1GroupBy) Bool

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

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

func (*Example1GroupBy) BoolX

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

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

func (*Example1GroupBy) Bools

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

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

func (*Example1GroupBy) BoolsX

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

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

func (*Example1GroupBy) Float64

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

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

func (*Example1GroupBy) Float64X

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

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

func (*Example1GroupBy) Float64s

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

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

func (*Example1GroupBy) Float64sX

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

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

func (*Example1GroupBy) Int

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

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

func (*Example1GroupBy) IntX

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

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

func (*Example1GroupBy) Ints

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

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

func (*Example1GroupBy) IntsX

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

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

func (*Example1GroupBy) Scan

func (eb *Example1GroupBy) Scan(ctx context.Context, v any) error

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

func (*Example1GroupBy) ScanX

func (s *Example1GroupBy) ScanX(ctx context.Context, v any)

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

func (*Example1GroupBy) String

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

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

func (*Example1GroupBy) StringX

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

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

func (*Example1GroupBy) Strings

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

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

func (*Example1GroupBy) StringsX

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

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

type Example1Mutation

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

Example1Mutation represents an operation that mutates the Example1 nodes in the graph.

func (*Example1Mutation) AddField

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

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

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

func (*Example1Mutation) AddedField

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

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

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

func (*Example1Mutation) AddedIDs

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

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

func (*Example1Mutation) ClearDeletedAt

func (m *Example1Mutation) ClearDeletedAt()

ClearDeletedAt clears the value of the "deleted_at" field.

func (*Example1Mutation) ClearEdge

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

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

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

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

func (*Example1Mutation) ClearedFields

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

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

func (Example1Mutation) Client

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

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

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

func (*Example1Mutation) DeletedAt

func (m *Example1Mutation) DeletedAt() (r time.Time, exists bool)

DeletedAt returns the value of the "deleted_at" field in the mutation.

func (*Example1Mutation) DeletedAtCleared

func (m *Example1Mutation) DeletedAtCleared() bool

DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.

func (*Example1Mutation) EdgeCleared

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

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

func (*Example1Mutation) ExampleValue1

func (m *Example1Mutation) ExampleValue1() (r string, exists bool)

ExampleValue1 returns the value of the "example_value_1" field in the mutation.

func (*Example1Mutation) Field

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

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

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

func (*Example1Mutation) Fields

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

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

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

func (*Example1Mutation) IDs

func (m *Example1Mutation) IDs(ctx context.Context) ([]string, 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 (*Example1Mutation) OldCreatedAt

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

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

func (m *Example1Mutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error)

OldDeletedAt returns the old "deleted_at" field's value of the Example1 entity. If the Example1 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 (*Example1Mutation) OldExampleValue1

func (m *Example1Mutation) OldExampleValue1(ctx context.Context) (v string, err error)

OldExampleValue1 returns the old "example_value_1" field's value of the Example1 entity. If the Example1 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 (*Example1Mutation) OldField

func (m *Example1Mutation) 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 (*Example1Mutation) OldUpdatedAt

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

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

func (m *Example1Mutation) Op() Op

Op returns the operation name.

func (*Example1Mutation) RemovedEdges

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

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

func (*Example1Mutation) RemovedIDs

func (m *Example1Mutation) 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 (*Example1Mutation) ResetCreatedAt

func (m *Example1Mutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*Example1Mutation) ResetDeletedAt

func (m *Example1Mutation) ResetDeletedAt()

ResetDeletedAt resets all changes to the "deleted_at" field.

func (*Example1Mutation) ResetEdge

func (m *Example1Mutation) 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 (*Example1Mutation) ResetExampleValue1

func (m *Example1Mutation) ResetExampleValue1()

ResetExampleValue1 resets all changes to the "example_value_1" field.

func (*Example1Mutation) ResetField

func (m *Example1Mutation) 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 (*Example1Mutation) ResetUpdatedAt

func (m *Example1Mutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*Example1Mutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*Example1Mutation) SetDeletedAt

func (m *Example1Mutation) SetDeletedAt(t time.Time)

SetDeletedAt sets the "deleted_at" field.

func (*Example1Mutation) SetExampleValue1

func (m *Example1Mutation) SetExampleValue1(s string)

SetExampleValue1 sets the "example_value_1" field.

func (*Example1Mutation) SetField

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

func (m *Example1Mutation) SetID(id string)

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

func (*Example1Mutation) SetOp

func (m *Example1Mutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*Example1Mutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (Example1Mutation) Tx

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

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

func (*Example1Mutation) Type

func (m *Example1Mutation) Type() string

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

func (*Example1Mutation) UpdatedAt

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

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

func (*Example1Mutation) Where

func (m *Example1Mutation) Where(ps ...predicate.Example1)

Where appends a list predicates to the Example1Mutation builder.

func (*Example1Mutation) WhereP

func (m *Example1Mutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the Example1Mutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type Example1Query

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

Example1Query is the builder for querying Example1 entities.

func (*Example1Query) Aggregate

func (e *Example1Query) Aggregate(fns ...AggregateFunc) *Example1Select

Aggregate returns a Example1Select configured with the given aggregations.

func (*Example1Query) All

func (e *Example1Query) All(ctx context.Context) ([]*Example1, error)

All executes the query and returns a list of Example1s.

func (*Example1Query) AllX

func (e *Example1Query) AllX(ctx context.Context) []*Example1

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

func (*Example1Query) Clone

func (e *Example1Query) Clone() *Example1Query

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

func (*Example1Query) Count

func (e *Example1Query) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*Example1Query) CountX

func (e *Example1Query) CountX(ctx context.Context) int

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

func (*Example1Query) Exist

func (e *Example1Query) Exist(ctx context.Context) (bool, error)

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

func (*Example1Query) ExistX

func (e *Example1Query) ExistX(ctx context.Context) bool

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

func (*Example1Query) First

func (e *Example1Query) First(ctx context.Context) (*Example1, error)

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

func (*Example1Query) FirstID

func (e *Example1Query) FirstID(ctx context.Context) (id string, err error)

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

func (*Example1Query) FirstIDX

func (e *Example1Query) FirstIDX(ctx context.Context) string

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

func (*Example1Query) FirstX

func (e *Example1Query) FirstX(ctx context.Context) *Example1

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

func (*Example1Query) ForShare

func (e *Example1Query) ForShare(opts ...sql.LockOption) *Example1Query

ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock on any rows that are read. Other sessions can read the rows, but cannot modify them until your transaction commits.

func (*Example1Query) ForUpdate

func (e *Example1Query) ForUpdate(opts ...sql.LockOption) *Example1Query

ForUpdate locks the selected rows against concurrent updates, and prevent them from being updated, deleted or "selected ... for update" by other sessions, until the transaction is either committed or rolled-back.

func (*Example1Query) GroupBy

func (e *Example1Query) GroupBy(field string, fields ...string) *Example1GroupBy

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.Example1.Query().
	GroupBy(example1.FieldCreatedAt).
	Aggregate(db.Count()).
	Scan(ctx, &v)

func (*Example1Query) IDs

func (e *Example1Query) IDs(ctx context.Context) (ids []string, err error)

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

func (*Example1Query) IDsX

func (e *Example1Query) IDsX(ctx context.Context) []string

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

func (*Example1Query) Limit

func (e *Example1Query) Limit(limit int) *Example1Query

Limit the number of records to be returned by this query.

func (*Example1Query) Offset

func (e *Example1Query) Offset(offset int) *Example1Query

Offset to start from.

func (*Example1Query) Only

func (e *Example1Query) Only(ctx context.Context) (*Example1, error)

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

func (*Example1Query) OnlyID

func (e *Example1Query) OnlyID(ctx context.Context) (id string, err error)

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

func (*Example1Query) OnlyIDX

func (e *Example1Query) OnlyIDX(ctx context.Context) string

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

func (*Example1Query) OnlyX

func (e *Example1Query) OnlyX(ctx context.Context) *Example1

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

func (*Example1Query) Order

Order specifies how the records should be ordered.

func (*Example1Query) Select

func (e *Example1Query) Select(fields ...string) *Example1Select

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.Example1.Query().
	Select(example1.FieldCreatedAt).
	Scan(ctx, &v)

func (*Example1Query) Unique

func (e *Example1Query) Unique(unique bool) *Example1Query

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

func (e *Example1Query) Where(ps ...predicate.Example1) *Example1Query

Where adds a new predicate for the Example1Query builder.

type Example1Select

type Example1Select struct {
	*Example1Query
	// contains filtered or unexported fields
}

Example1Select is the builder for selecting fields of Example1 entities.

func (*Example1Select) Aggregate

func (e *Example1Select) Aggregate(fns ...AggregateFunc) *Example1Select

Aggregate adds the given aggregation functions to the selector query.

func (*Example1Select) Bool

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

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

func (*Example1Select) BoolX

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

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

func (*Example1Select) Bools

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

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

func (*Example1Select) BoolsX

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

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

func (*Example1Select) Float64

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

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

func (*Example1Select) Float64X

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

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

func (*Example1Select) Float64s

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

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

func (*Example1Select) Float64sX

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

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

func (*Example1Select) Int

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

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

func (*Example1Select) IntX

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

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

func (*Example1Select) Ints

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

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

func (*Example1Select) IntsX

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

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

func (*Example1Select) Scan

func (e *Example1Select) Scan(ctx context.Context, v any) error

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

func (*Example1Select) ScanX

func (s *Example1Select) ScanX(ctx context.Context, v any)

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

func (*Example1Select) String

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

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

func (*Example1Select) StringX

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

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

func (*Example1Select) Strings

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

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

func (*Example1Select) StringsX

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

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

type Example1Update

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

Example1Update is the builder for updating Example1 entities.

func (*Example1Update) ClearDeletedAt

func (e *Example1Update) ClearDeletedAt() *Example1Update

ClearDeletedAt clears the value of the "deleted_at" field.

func (*Example1Update) Exec

func (e *Example1Update) Exec(ctx context.Context) error

Exec executes the query.

func (*Example1Update) ExecX

func (e *Example1Update) ExecX(ctx context.Context)

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

func (*Example1Update) Mutation

func (e *Example1Update) Mutation() *Example1Mutation

Mutation returns the Example1Mutation object of the builder.

func (*Example1Update) Save

func (e *Example1Update) Save(ctx context.Context) (int, error)

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

func (*Example1Update) SaveX

func (e *Example1Update) SaveX(ctx context.Context) int

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

func (*Example1Update) SetDeletedAt

func (e *Example1Update) SetDeletedAt(t time.Time) *Example1Update

SetDeletedAt sets the "deleted_at" field.

func (*Example1Update) SetExampleValue1

func (e *Example1Update) SetExampleValue1(s string) *Example1Update

SetExampleValue1 sets the "example_value_1" field.

func (*Example1Update) SetNillableDeletedAt

func (e *Example1Update) SetNillableDeletedAt(t *time.Time) *Example1Update

SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.

func (*Example1Update) SetNillableExampleValue1

func (e *Example1Update) SetNillableExampleValue1(s *string) *Example1Update

SetNillableExampleValue1 sets the "example_value_1" field if the given value is not nil.

func (*Example1Update) SetUpdatedAt

func (e *Example1Update) SetUpdatedAt(t time.Time) *Example1Update

SetUpdatedAt sets the "updated_at" field.

func (*Example1Update) Where

Where appends a list predicates to the Example1Update builder.

type Example1UpdateOne

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

Example1UpdateOne is the builder for updating a single Example1 entity.

func (*Example1UpdateOne) ClearDeletedAt

func (eo *Example1UpdateOne) ClearDeletedAt() *Example1UpdateOne

ClearDeletedAt clears the value of the "deleted_at" field.

func (*Example1UpdateOne) Exec

func (eo *Example1UpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*Example1UpdateOne) ExecX

func (eo *Example1UpdateOne) ExecX(ctx context.Context)

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

func (*Example1UpdateOne) Mutation

func (eo *Example1UpdateOne) Mutation() *Example1Mutation

Mutation returns the Example1Mutation object of the builder.

func (*Example1UpdateOne) Save

func (eo *Example1UpdateOne) Save(ctx context.Context) (*Example1, error)

Save executes the query and returns the updated Example1 entity.

func (*Example1UpdateOne) SaveX

func (eo *Example1UpdateOne) SaveX(ctx context.Context) *Example1

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

func (*Example1UpdateOne) Select

func (eo *Example1UpdateOne) Select(field string, fields ...string) *Example1UpdateOne

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

func (*Example1UpdateOne) SetDeletedAt

func (eo *Example1UpdateOne) SetDeletedAt(t time.Time) *Example1UpdateOne

SetDeletedAt sets the "deleted_at" field.

func (*Example1UpdateOne) SetExampleValue1

func (eo *Example1UpdateOne) SetExampleValue1(s string) *Example1UpdateOne

SetExampleValue1 sets the "example_value_1" field.

func (*Example1UpdateOne) SetNillableDeletedAt

func (eo *Example1UpdateOne) SetNillableDeletedAt(t *time.Time) *Example1UpdateOne

SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.

func (*Example1UpdateOne) SetNillableExampleValue1

func (eo *Example1UpdateOne) SetNillableExampleValue1(s *string) *Example1UpdateOne

SetNillableExampleValue1 sets the "example_value_1" field if the given value is not nil.

func (*Example1UpdateOne) SetUpdatedAt

func (eo *Example1UpdateOne) SetUpdatedAt(t time.Time) *Example1UpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*Example1UpdateOne) Where

Where appends a list predicates to the Example1Update builder.

type Example1Upsert

type Example1Upsert struct {
	*sql.UpdateSet
}

Example1Upsert is the "OnConflict" setter.

func (*Example1Upsert) ClearDeletedAt

func (u *Example1Upsert) ClearDeletedAt() *Example1Upsert

ClearDeletedAt clears the value of the "deleted_at" field.

func (*Example1Upsert) SetDeletedAt

func (u *Example1Upsert) SetDeletedAt(v time.Time) *Example1Upsert

SetDeletedAt sets the "deleted_at" field.

func (*Example1Upsert) SetExampleValue1

func (u *Example1Upsert) SetExampleValue1(v string) *Example1Upsert

SetExampleValue1 sets the "example_value_1" field.

func (*Example1Upsert) SetUpdatedAt

func (u *Example1Upsert) SetUpdatedAt(v time.Time) *Example1Upsert

SetUpdatedAt sets the "updated_at" field.

func (*Example1Upsert) UpdateDeletedAt

func (u *Example1Upsert) UpdateDeletedAt() *Example1Upsert

UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.

func (*Example1Upsert) UpdateExampleValue1

func (u *Example1Upsert) UpdateExampleValue1() *Example1Upsert

UpdateExampleValue1 sets the "example_value_1" field to the value that was provided on create.

func (*Example1Upsert) UpdateUpdatedAt

func (u *Example1Upsert) UpdateUpdatedAt() *Example1Upsert

UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.

type Example1UpsertBulk

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

Example1UpsertBulk is the builder for "upsert"-ing a bulk of Example1 nodes.

func (*Example1UpsertBulk) ClearDeletedAt

func (u *Example1UpsertBulk) ClearDeletedAt() *Example1UpsertBulk

ClearDeletedAt clears the value of the "deleted_at" field.

func (*Example1UpsertBulk) DoNothing

func (u *Example1UpsertBulk) DoNothing() *Example1UpsertBulk

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*Example1UpsertBulk) Exec

func (u *Example1UpsertBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*Example1UpsertBulk) ExecX

func (u *Example1UpsertBulk) ExecX(ctx context.Context)

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

func (*Example1UpsertBulk) Ignore

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.Example1.Create().
	OnConflict(sql.ResolveWithIgnore()).
	Exec(ctx)

func (*Example1UpsertBulk) SetDeletedAt

func (u *Example1UpsertBulk) SetDeletedAt(v time.Time) *Example1UpsertBulk

SetDeletedAt sets the "deleted_at" field.

func (*Example1UpsertBulk) SetExampleValue1

func (u *Example1UpsertBulk) SetExampleValue1(v string) *Example1UpsertBulk

SetExampleValue1 sets the "example_value_1" field.

func (*Example1UpsertBulk) SetUpdatedAt

func (u *Example1UpsertBulk) SetUpdatedAt(v time.Time) *Example1UpsertBulk

SetUpdatedAt sets the "updated_at" field.

func (*Example1UpsertBulk) Update

func (u *Example1UpsertBulk) Update(set func(*Example1Upsert)) *Example1UpsertBulk

Update allows overriding fields `UPDATE` values. See the Example1CreateBulk.OnConflict documentation for more info.

func (*Example1UpsertBulk) UpdateDeletedAt

func (u *Example1UpsertBulk) UpdateDeletedAt() *Example1UpsertBulk

UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.

func (*Example1UpsertBulk) UpdateExampleValue1

func (u *Example1UpsertBulk) UpdateExampleValue1() *Example1UpsertBulk

UpdateExampleValue1 sets the "example_value_1" field to the value that was provided on create.

func (*Example1UpsertBulk) UpdateNewValues

func (u *Example1UpsertBulk) UpdateNewValues() *Example1UpsertBulk

UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:

client.Example1.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
		sql.ResolveWith(func(u *sql.UpdateSet) {
			u.SetIgnore(example1.FieldID)
		}),
	).
	Exec(ctx)

func (*Example1UpsertBulk) UpdateUpdatedAt

func (u *Example1UpsertBulk) UpdateUpdatedAt() *Example1UpsertBulk

UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.

type Example1UpsertOne

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

Example1UpsertOne is the builder for "upsert"-ing

one Example1 node.

func (*Example1UpsertOne) ClearDeletedAt

func (u *Example1UpsertOne) ClearDeletedAt() *Example1UpsertOne

ClearDeletedAt clears the value of the "deleted_at" field.

func (*Example1UpsertOne) DoNothing

func (u *Example1UpsertOne) DoNothing() *Example1UpsertOne

DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.

func (*Example1UpsertOne) Exec

func (u *Example1UpsertOne) Exec(ctx context.Context) error

Exec executes the query.

func (*Example1UpsertOne) ExecX

func (u *Example1UpsertOne) ExecX(ctx context.Context)

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

func (*Example1UpsertOne) ID

func (u *Example1UpsertOne) ID(ctx context.Context) (id string, err error)

Exec executes the UPSERT query and returns the inserted/updated ID.

func (*Example1UpsertOne) IDX

IDX is like ID, but panics if an error occurs.

func (*Example1UpsertOne) Ignore

func (u *Example1UpsertOne) Ignore() *Example1UpsertOne

Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:

client.Example1.Create().
    OnConflict(sql.ResolveWithIgnore()).
    Exec(ctx)

func (*Example1UpsertOne) SetDeletedAt

func (u *Example1UpsertOne) SetDeletedAt(v time.Time) *Example1UpsertOne

SetDeletedAt sets the "deleted_at" field.

func (*Example1UpsertOne) SetExampleValue1

func (u *Example1UpsertOne) SetExampleValue1(v string) *Example1UpsertOne

SetExampleValue1 sets the "example_value_1" field.

func (*Example1UpsertOne) SetUpdatedAt

func (u *Example1UpsertOne) SetUpdatedAt(v time.Time) *Example1UpsertOne

SetUpdatedAt sets the "updated_at" field.

func (*Example1UpsertOne) Update

func (u *Example1UpsertOne) Update(set func(*Example1Upsert)) *Example1UpsertOne

Update allows overriding fields `UPDATE` values. See the Example1Create.OnConflict documentation for more info.

func (*Example1UpsertOne) UpdateDeletedAt

func (u *Example1UpsertOne) UpdateDeletedAt() *Example1UpsertOne

UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.

func (*Example1UpsertOne) UpdateExampleValue1

func (u *Example1UpsertOne) UpdateExampleValue1() *Example1UpsertOne

UpdateExampleValue1 sets the "example_value_1" field to the value that was provided on create.

func (*Example1UpsertOne) UpdateNewValues

func (u *Example1UpsertOne) UpdateNewValues() *Example1UpsertOne

UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. Using this option is equivalent to using:

client.Example1.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
		sql.ResolveWith(func(u *sql.UpdateSet) {
			u.SetIgnore(example1.FieldID)
		}),
	).
	Exec(ctx)

func (*Example1UpsertOne) UpdateUpdatedAt

func (u *Example1UpsertOne) UpdateUpdatedAt() *Example1UpsertOne

UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.

type Example1s

type Example1s []*Example1

Example1s is a parsable slice of Example1.

type ExposedTxDriver

type ExposedTxDriver struct {
	Driver *txDriver
}

func (*ExposedTxDriver) Commit

func (d *ExposedTxDriver) Commit() error

ignores hooks

func (*ExposedTxDriver) Rollback

func (d *ExposedTxDriver) Rollback() error

ignores hooks

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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(...any)) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector. Deprecated: Use Asc/Desc functions or the package builders instead.

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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 QueryContext

type QueryContext = ent.QueryContext

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 TraverseFunc

type TraverseFunc = ent.TraverseFunc

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

type Traverser

type Traverser = ent.Traverser

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

type Tx

type Tx struct {

	// Example1 is the client for interacting with the Example1 builders.
	Example1 *Example1Client
	// contains filtered or unexported fields
}

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

func NewTxClientFromRawConfig

func NewTxClientFromRawConfig(ctx context.Context, cfg entutils.RawEntConfig) *Tx

NewTxClientFromConfig creates a new transactional client from a (hijacked) configuration.

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