local

package
v0.0.0-...-3b51f2e Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: Apache-2.0 Imports: 18 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.
	TypeKV = "KV"
)

Variables

This section is empty.

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

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 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 KV

type KV struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Key holds the value of the "key" field.
	Key string `json:"key,omitempty"`
	// Value holds the value of the "value" field.
	Value string `json:"value,omitempty"`
	// ExpiresAt holds the value of the "expires_at" field.
	ExpiresAt time.Time `json:"expires_at,omitempty"`
	// contains filtered or unexported fields
}

KV is the model entity for the KV schema.

func (*KV) GetValue

func (k *KV) GetValue(name string) (ent.Value, error)

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

func (*KV) String

func (k *KV) String() string

String implements the fmt.Stringer.

func (*KV) Unwrap

func (k *KV) Unwrap() *KV

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

func (k *KV) Update() *KVUpdateOne

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

type KVClient

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

KVClient is a client for the KV schema.

func NewKVClient

func NewKVClient(c config) *KVClient

NewKVClient returns a client for the KV from the given config.

func (*KVClient) Create

func (c *KVClient) Create() *KVCreate

Create returns a builder for creating a KV entity.

func (*KVClient) CreateBulk

func (c *KVClient) CreateBulk(builders ...*KVCreate) *KVCreateBulk

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

func (*KVClient) Delete

func (c *KVClient) Delete() *KVDelete

Delete returns a delete builder for KV.

func (*KVClient) DeleteOne

func (c *KVClient) DeleteOne(k *KV) *KVDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*KVClient) DeleteOneID

func (c *KVClient) DeleteOneID(id int) *KVDeleteOne

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

func (*KVClient) Get

func (c *KVClient) Get(ctx context.Context, id int) (*KV, error)

Get returns a KV entity by its id.

func (*KVClient) GetX

func (c *KVClient) GetX(ctx context.Context, id int) *KV

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

func (*KVClient) Hooks

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

Hooks returns the client hooks.

func (*KVClient) Intercept

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

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

func (*KVClient) Interceptors

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

Interceptors returns the client interceptors.

func (*KVClient) Query

func (c *KVClient) Query() *KVQuery

Query returns a query builder for KV.

func (*KVClient) Update

func (c *KVClient) Update() *KVUpdate

Update returns an update builder for KV.

func (*KVClient) UpdateOne

func (c *KVClient) UpdateOne(k *KV) *KVUpdateOne

UpdateOne returns an update builder for the given entity.

func (*KVClient) UpdateOneID

func (c *KVClient) UpdateOneID(id int) *KVUpdateOne

UpdateOneID returns an update builder for the given id.

func (*KVClient) Use

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

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

type KVCreate

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

KVCreate is the builder for creating a KV entity.

func (*KVCreate) Exec

func (kc *KVCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*KVCreate) ExecX

func (kc *KVCreate) ExecX(ctx context.Context)

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

func (*KVCreate) Mutation

func (kc *KVCreate) Mutation() *KVMutation

Mutation returns the KVMutation object of the builder.

func (*KVCreate) OnConflict

func (kc *KVCreate) OnConflict(opts ...sql.ConflictOption) *KVUpsertOne

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

client.KV.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.KVUpsert) {
		SetCreatedAt(v+v).
	}).
	Exec(ctx)

func (*KVCreate) OnConflictColumns

func (kc *KVCreate) OnConflictColumns(columns ...string) *KVUpsertOne

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

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

func (*KVCreate) Save

func (kc *KVCreate) Save(ctx context.Context) (*KV, error)

Save creates the KV in the database.

func (*KVCreate) SaveX

func (kc *KVCreate) SaveX(ctx context.Context) *KV

SaveX calls Save and panics if Save returns an error.

func (*KVCreate) SetCreatedAt

func (kc *KVCreate) SetCreatedAt(t time.Time) *KVCreate

SetCreatedAt sets the "created_at" field.

func (*KVCreate) SetExpiresAt

func (kc *KVCreate) SetExpiresAt(t time.Time) *KVCreate

SetExpiresAt sets the "expires_at" field.

func (*KVCreate) SetKey

func (kc *KVCreate) SetKey(s string) *KVCreate

SetKey sets the "key" field.

func (*KVCreate) SetNillableCreatedAt

func (kc *KVCreate) SetNillableCreatedAt(t *time.Time) *KVCreate

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

func (*KVCreate) SetNillableExpiresAt

func (kc *KVCreate) SetNillableExpiresAt(t *time.Time) *KVCreate

SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.

func (*KVCreate) SetNillableUpdatedAt

func (kc *KVCreate) SetNillableUpdatedAt(t *time.Time) *KVCreate

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

func (*KVCreate) SetUpdatedAt

func (kc *KVCreate) SetUpdatedAt(t time.Time) *KVCreate

SetUpdatedAt sets the "updated_at" field.

func (*KVCreate) SetValue

func (kc *KVCreate) SetValue(s string) *KVCreate

SetValue sets the "value" field.

type KVCreateBulk

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

KVCreateBulk is the builder for creating many KV entities in bulk.

func (*KVCreateBulk) Exec

func (kcb *KVCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*KVCreateBulk) ExecX

func (kcb *KVCreateBulk) ExecX(ctx context.Context)

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

func (*KVCreateBulk) OnConflict

func (kcb *KVCreateBulk) OnConflict(opts ...sql.ConflictOption) *KVUpsertBulk

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

client.KV.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.KVUpsert) {
		SetCreatedAt(v+v).
	}).
	Exec(ctx)

func (*KVCreateBulk) OnConflictColumns

func (kcb *KVCreateBulk) OnConflictColumns(columns ...string) *KVUpsertBulk

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

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

func (*KVCreateBulk) Save

func (kcb *KVCreateBulk) Save(ctx context.Context) ([]*KV, error)

Save creates the KV entities in the database.

func (*KVCreateBulk) SaveX

func (kcb *KVCreateBulk) SaveX(ctx context.Context) []*KV

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

type KVDelete

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

KVDelete is the builder for deleting a KV entity.

func (*KVDelete) Exec

func (kd *KVDelete) Exec(ctx context.Context) (int, error)

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

func (*KVDelete) ExecX

func (kd *KVDelete) ExecX(ctx context.Context) int

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

func (*KVDelete) Where

func (kd *KVDelete) Where(ps ...predicate.KV) *KVDelete

Where appends a list predicates to the KVDelete builder.

type KVDeleteOne

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

KVDeleteOne is the builder for deleting a single KV entity.

func (*KVDeleteOne) Exec

func (kdo *KVDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*KVDeleteOne) ExecX

func (kdo *KVDeleteOne) ExecX(ctx context.Context)

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

func (*KVDeleteOne) Where

func (kdo *KVDeleteOne) Where(ps ...predicate.KV) *KVDeleteOne

Where appends a list predicates to the KVDelete builder.

type KVGroupBy

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

KVGroupBy is the group-by builder for KV entities.

func (*KVGroupBy) Aggregate

func (kgb *KVGroupBy) Aggregate(fns ...AggregateFunc) *KVGroupBy

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

func (*KVGroupBy) Bool

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

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

func (*KVGroupBy) BoolX

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

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

func (*KVGroupBy) Bools

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

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

func (*KVGroupBy) BoolsX

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

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

func (*KVGroupBy) Float64

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

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

func (*KVGroupBy) Float64X

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

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

func (*KVGroupBy) Float64s

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

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

func (*KVGroupBy) Float64sX

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

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

func (*KVGroupBy) Int

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

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

func (*KVGroupBy) IntX

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

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

func (*KVGroupBy) Ints

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

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

func (*KVGroupBy) IntsX

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

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

func (*KVGroupBy) Scan

func (kgb *KVGroupBy) Scan(ctx context.Context, v any) error

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

func (*KVGroupBy) ScanX

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

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

func (*KVGroupBy) String

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

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

func (*KVGroupBy) StringX

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

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

func (*KVGroupBy) Strings

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

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

func (*KVGroupBy) StringsX

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

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

type KVMutation

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

KVMutation represents an operation that mutates the KV nodes in the graph.

func (*KVMutation) AddField

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

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

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

func (*KVMutation) AddedField

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

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

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

func (*KVMutation) AddedIDs

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

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

func (*KVMutation) ClearEdge

func (m *KVMutation) 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 (*KVMutation) ClearExpiresAt

func (m *KVMutation) ClearExpiresAt()

ClearExpiresAt clears the value of the "expires_at" field.

func (*KVMutation) ClearField

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

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

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

func (*KVMutation) ClearedFields

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

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

func (KVMutation) Client

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

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

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

func (*KVMutation) EdgeCleared

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

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

func (*KVMutation) ExpiresAt

func (m *KVMutation) ExpiresAt() (r time.Time, exists bool)

ExpiresAt returns the value of the "expires_at" field in the mutation.

func (*KVMutation) ExpiresAtCleared

func (m *KVMutation) ExpiresAtCleared() bool

ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.

func (*KVMutation) Field

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

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

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

func (*KVMutation) Fields

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

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

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

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

func (*KVMutation) Key

func (m *KVMutation) Key() (r string, exists bool)

Key returns the value of the "key" field in the mutation.

func (*KVMutation) OldCreatedAt

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

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

func (m *KVMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error)

OldExpiresAt returns the old "expires_at" field's value of the KV entity. If the KV 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 (*KVMutation) OldField

func (m *KVMutation) 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 (*KVMutation) OldKey

func (m *KVMutation) OldKey(ctx context.Context) (v string, err error)

OldKey returns the old "key" field's value of the KV entity. If the KV 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 (*KVMutation) OldUpdatedAt

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

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

func (m *KVMutation) OldValue(ctx context.Context) (v string, err error)

OldValue returns the old "value" field's value of the KV entity. If the KV 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 (*KVMutation) Op

func (m *KVMutation) Op() Op

Op returns the operation name.

func (*KVMutation) RemovedEdges

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

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

func (*KVMutation) RemovedIDs

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

func (m *KVMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*KVMutation) ResetEdge

func (m *KVMutation) 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 (*KVMutation) ResetExpiresAt

func (m *KVMutation) ResetExpiresAt()

ResetExpiresAt resets all changes to the "expires_at" field.

func (*KVMutation) ResetField

func (m *KVMutation) 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 (*KVMutation) ResetKey

func (m *KVMutation) ResetKey()

ResetKey resets all changes to the "key" field.

func (*KVMutation) ResetUpdatedAt

func (m *KVMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*KVMutation) ResetValue

func (m *KVMutation) ResetValue()

ResetValue resets all changes to the "value" field.

func (*KVMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*KVMutation) SetExpiresAt

func (m *KVMutation) SetExpiresAt(t time.Time)

SetExpiresAt sets the "expires_at" field.

func (*KVMutation) SetField

func (m *KVMutation) 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 (*KVMutation) SetKey

func (m *KVMutation) SetKey(s string)

SetKey sets the "key" field.

func (*KVMutation) SetOp

func (m *KVMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*KVMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*KVMutation) SetValue

func (m *KVMutation) SetValue(s string)

SetValue sets the "value" field.

func (KVMutation) Tx

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

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

func (*KVMutation) Type

func (m *KVMutation) Type() string

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

func (*KVMutation) UpdatedAt

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

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

func (*KVMutation) Value

func (m *KVMutation) Value() (r string, exists bool)

Value returns the value of the "value" field in the mutation.

func (*KVMutation) Where

func (m *KVMutation) Where(ps ...predicate.KV)

Where appends a list predicates to the KVMutation builder.

func (*KVMutation) WhereP

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

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

type KVQuery

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

KVQuery is the builder for querying KV entities.

func (*KVQuery) Aggregate

func (kq *KVQuery) Aggregate(fns ...AggregateFunc) *KVSelect

Aggregate returns a KVSelect configured with the given aggregations.

func (*KVQuery) All

func (kq *KVQuery) All(ctx context.Context) ([]*KV, error)

All executes the query and returns a list of KVs.

func (*KVQuery) AllX

func (kq *KVQuery) AllX(ctx context.Context) []*KV

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

func (*KVQuery) Clone

func (kq *KVQuery) Clone() *KVQuery

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

func (*KVQuery) Count

func (kq *KVQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*KVQuery) CountX

func (kq *KVQuery) CountX(ctx context.Context) int

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

func (*KVQuery) Exist

func (kq *KVQuery) Exist(ctx context.Context) (bool, error)

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

func (*KVQuery) ExistX

func (kq *KVQuery) ExistX(ctx context.Context) bool

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

func (*KVQuery) First

func (kq *KVQuery) First(ctx context.Context) (*KV, error)

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

func (*KVQuery) FirstID

func (kq *KVQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*KVQuery) FirstIDX

func (kq *KVQuery) FirstIDX(ctx context.Context) int

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

func (*KVQuery) FirstX

func (kq *KVQuery) FirstX(ctx context.Context) *KV

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

func (*KVQuery) GroupBy

func (kq *KVQuery) GroupBy(field string, fields ...string) *KVGroupBy

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.KV.Query().
	GroupBy(kv.FieldCreatedAt).
	Aggregate(local.Count()).
	Scan(ctx, &v)

func (*KVQuery) IDs

func (kq *KVQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*KVQuery) IDsX

func (kq *KVQuery) IDsX(ctx context.Context) []int

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

func (*KVQuery) Limit

func (kq *KVQuery) Limit(limit int) *KVQuery

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

func (*KVQuery) Modify

func (kq *KVQuery) Modify(modifiers ...func(s *sql.Selector)) *KVSelect

Modify adds a query modifier for attaching custom logic to queries.

func (*KVQuery) Offset

func (kq *KVQuery) Offset(offset int) *KVQuery

Offset to start from.

func (*KVQuery) Only

func (kq *KVQuery) Only(ctx context.Context) (*KV, error)

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

func (*KVQuery) OnlyID

func (kq *KVQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*KVQuery) OnlyIDX

func (kq *KVQuery) OnlyIDX(ctx context.Context) int

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

func (*KVQuery) OnlyX

func (kq *KVQuery) OnlyX(ctx context.Context) *KV

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

func (*KVQuery) Order

func (kq *KVQuery) Order(o ...kv.OrderOption) *KVQuery

Order specifies how the records should be ordered.

func (*KVQuery) Select

func (kq *KVQuery) Select(fields ...string) *KVSelect

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

func (*KVQuery) Unique

func (kq *KVQuery) Unique(unique bool) *KVQuery

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

func (kq *KVQuery) Where(ps ...predicate.KV) *KVQuery

Where adds a new predicate for the KVQuery builder.

type KVSelect

type KVSelect struct {
	*KVQuery
	// contains filtered or unexported fields
}

KVSelect is the builder for selecting fields of KV entities.

func (*KVSelect) Aggregate

func (ks *KVSelect) Aggregate(fns ...AggregateFunc) *KVSelect

Aggregate adds the given aggregation functions to the selector query.

func (*KVSelect) Bool

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

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

func (*KVSelect) BoolX

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

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

func (*KVSelect) Bools

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

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

func (*KVSelect) BoolsX

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

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

func (*KVSelect) Float64

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

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

func (*KVSelect) Float64X

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

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

func (*KVSelect) Float64s

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

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

func (*KVSelect) Float64sX

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

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

func (*KVSelect) Int

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

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

func (*KVSelect) IntX

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

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

func (*KVSelect) Ints

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

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

func (*KVSelect) IntsX

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

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

func (*KVSelect) Modify

func (ks *KVSelect) Modify(modifiers ...func(s *sql.Selector)) *KVSelect

Modify adds a query modifier for attaching custom logic to queries.

func (*KVSelect) Scan

func (ks *KVSelect) Scan(ctx context.Context, v any) error

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

func (*KVSelect) ScanX

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

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

func (*KVSelect) String

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

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

func (*KVSelect) StringX

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

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

func (*KVSelect) Strings

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

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

func (*KVSelect) StringsX

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

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

type KVUpdate

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

KVUpdate is the builder for updating KV entities.

func (*KVUpdate) ClearExpiresAt

func (ku *KVUpdate) ClearExpiresAt() *KVUpdate

ClearExpiresAt clears the value of the "expires_at" field.

func (*KVUpdate) Exec

func (ku *KVUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*KVUpdate) ExecX

func (ku *KVUpdate) ExecX(ctx context.Context)

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

func (*KVUpdate) Modify

func (ku *KVUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *KVUpdate

Modify adds a statement modifier for attaching custom logic to the UPDATE statement.

func (*KVUpdate) Mutation

func (ku *KVUpdate) Mutation() *KVMutation

Mutation returns the KVMutation object of the builder.

func (*KVUpdate) Save

func (ku *KVUpdate) Save(ctx context.Context) (int, error)

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

func (*KVUpdate) SaveX

func (ku *KVUpdate) SaveX(ctx context.Context) int

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

func (*KVUpdate) SetExpiresAt

func (ku *KVUpdate) SetExpiresAt(t time.Time) *KVUpdate

SetExpiresAt sets the "expires_at" field.

func (*KVUpdate) SetKey

func (ku *KVUpdate) SetKey(s string) *KVUpdate

SetKey sets the "key" field.

func (*KVUpdate) SetNillableExpiresAt

func (ku *KVUpdate) SetNillableExpiresAt(t *time.Time) *KVUpdate

SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.

func (*KVUpdate) SetUpdatedAt

func (ku *KVUpdate) SetUpdatedAt(t time.Time) *KVUpdate

SetUpdatedAt sets the "updated_at" field.

func (*KVUpdate) SetValue

func (ku *KVUpdate) SetValue(s string) *KVUpdate

SetValue sets the "value" field.

func (*KVUpdate) Where

func (ku *KVUpdate) Where(ps ...predicate.KV) *KVUpdate

Where appends a list predicates to the KVUpdate builder.

type KVUpdateOne

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

KVUpdateOne is the builder for updating a single KV entity.

func (*KVUpdateOne) ClearExpiresAt

func (kuo *KVUpdateOne) ClearExpiresAt() *KVUpdateOne

ClearExpiresAt clears the value of the "expires_at" field.

func (*KVUpdateOne) Exec

func (kuo *KVUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*KVUpdateOne) ExecX

func (kuo *KVUpdateOne) ExecX(ctx context.Context)

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

func (*KVUpdateOne) Modify

func (kuo *KVUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *KVUpdateOne

Modify adds a statement modifier for attaching custom logic to the UPDATE statement.

func (*KVUpdateOne) Mutation

func (kuo *KVUpdateOne) Mutation() *KVMutation

Mutation returns the KVMutation object of the builder.

func (*KVUpdateOne) Save

func (kuo *KVUpdateOne) Save(ctx context.Context) (*KV, error)

Save executes the query and returns the updated KV entity.

func (*KVUpdateOne) SaveX

func (kuo *KVUpdateOne) SaveX(ctx context.Context) *KV

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

func (*KVUpdateOne) Select

func (kuo *KVUpdateOne) Select(field string, fields ...string) *KVUpdateOne

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

func (*KVUpdateOne) SetExpiresAt

func (kuo *KVUpdateOne) SetExpiresAt(t time.Time) *KVUpdateOne

SetExpiresAt sets the "expires_at" field.

func (*KVUpdateOne) SetKey

func (kuo *KVUpdateOne) SetKey(s string) *KVUpdateOne

SetKey sets the "key" field.

func (*KVUpdateOne) SetNillableExpiresAt

func (kuo *KVUpdateOne) SetNillableExpiresAt(t *time.Time) *KVUpdateOne

SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.

func (*KVUpdateOne) SetUpdatedAt

func (kuo *KVUpdateOne) SetUpdatedAt(t time.Time) *KVUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*KVUpdateOne) SetValue

func (kuo *KVUpdateOne) SetValue(s string) *KVUpdateOne

SetValue sets the "value" field.

func (*KVUpdateOne) Where

func (kuo *KVUpdateOne) Where(ps ...predicate.KV) *KVUpdateOne

Where appends a list predicates to the KVUpdate builder.

type KVUpsert

type KVUpsert struct {
	*sql.UpdateSet
}

KVUpsert is the "OnConflict" setter.

func (*KVUpsert) ClearExpiresAt

func (u *KVUpsert) ClearExpiresAt() *KVUpsert

ClearExpiresAt clears the value of the "expires_at" field.

func (*KVUpsert) SetExpiresAt

func (u *KVUpsert) SetExpiresAt(v time.Time) *KVUpsert

SetExpiresAt sets the "expires_at" field.

func (*KVUpsert) SetKey

func (u *KVUpsert) SetKey(v string) *KVUpsert

SetKey sets the "key" field.

func (*KVUpsert) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*KVUpsert) SetValue

func (u *KVUpsert) SetValue(v string) *KVUpsert

SetValue sets the "value" field.

func (*KVUpsert) UpdateExpiresAt

func (u *KVUpsert) UpdateExpiresAt() *KVUpsert

UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.

func (*KVUpsert) UpdateKey

func (u *KVUpsert) UpdateKey() *KVUpsert

UpdateKey sets the "key" field to the value that was provided on create.

func (*KVUpsert) UpdateUpdatedAt

func (u *KVUpsert) UpdateUpdatedAt() *KVUpsert

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

func (*KVUpsert) UpdateValue

func (u *KVUpsert) UpdateValue() *KVUpsert

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

type KVUpsertBulk

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

KVUpsertBulk is the builder for "upsert"-ing a bulk of KV nodes.

func (*KVUpsertBulk) ClearExpiresAt

func (u *KVUpsertBulk) ClearExpiresAt() *KVUpsertBulk

ClearExpiresAt clears the value of the "expires_at" field.

func (*KVUpsertBulk) DoNothing

func (u *KVUpsertBulk) DoNothing() *KVUpsertBulk

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

func (*KVUpsertBulk) Exec

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

Exec executes the query.

func (*KVUpsertBulk) ExecX

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

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

func (*KVUpsertBulk) Ignore

func (u *KVUpsertBulk) Ignore() *KVUpsertBulk

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

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

func (*KVUpsertBulk) SetExpiresAt

func (u *KVUpsertBulk) SetExpiresAt(v time.Time) *KVUpsertBulk

SetExpiresAt sets the "expires_at" field.

func (*KVUpsertBulk) SetKey

func (u *KVUpsertBulk) SetKey(v string) *KVUpsertBulk

SetKey sets the "key" field.

func (*KVUpsertBulk) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*KVUpsertBulk) SetValue

func (u *KVUpsertBulk) SetValue(v string) *KVUpsertBulk

SetValue sets the "value" field.

func (*KVUpsertBulk) Update

func (u *KVUpsertBulk) Update(set func(*KVUpsert)) *KVUpsertBulk

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

func (*KVUpsertBulk) UpdateExpiresAt

func (u *KVUpsertBulk) UpdateExpiresAt() *KVUpsertBulk

UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.

func (*KVUpsertBulk) UpdateKey

func (u *KVUpsertBulk) UpdateKey() *KVUpsertBulk

UpdateKey sets the "key" field to the value that was provided on create.

func (*KVUpsertBulk) UpdateNewValues

func (u *KVUpsertBulk) UpdateNewValues() *KVUpsertBulk

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

client.KV.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

func (*KVUpsertBulk) UpdateUpdatedAt

func (u *KVUpsertBulk) UpdateUpdatedAt() *KVUpsertBulk

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

func (*KVUpsertBulk) UpdateValue

func (u *KVUpsertBulk) UpdateValue() *KVUpsertBulk

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

type KVUpsertOne

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

KVUpsertOne is the builder for "upsert"-ing

one KV node.

func (*KVUpsertOne) ClearExpiresAt

func (u *KVUpsertOne) ClearExpiresAt() *KVUpsertOne

ClearExpiresAt clears the value of the "expires_at" field.

func (*KVUpsertOne) DoNothing

func (u *KVUpsertOne) DoNothing() *KVUpsertOne

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

func (*KVUpsertOne) Exec

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

Exec executes the query.

func (*KVUpsertOne) ExecX

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

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

func (*KVUpsertOne) ID

func (u *KVUpsertOne) ID(ctx context.Context) (id int, err error)

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

func (*KVUpsertOne) IDX

func (u *KVUpsertOne) IDX(ctx context.Context) int

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

func (*KVUpsertOne) Ignore

func (u *KVUpsertOne) Ignore() *KVUpsertOne

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

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

func (*KVUpsertOne) SetExpiresAt

func (u *KVUpsertOne) SetExpiresAt(v time.Time) *KVUpsertOne

SetExpiresAt sets the "expires_at" field.

func (*KVUpsertOne) SetKey

func (u *KVUpsertOne) SetKey(v string) *KVUpsertOne

SetKey sets the "key" field.

func (*KVUpsertOne) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*KVUpsertOne) SetValue

func (u *KVUpsertOne) SetValue(v string) *KVUpsertOne

SetValue sets the "value" field.

func (*KVUpsertOne) Update

func (u *KVUpsertOne) Update(set func(*KVUpsert)) *KVUpsertOne

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

func (*KVUpsertOne) UpdateExpiresAt

func (u *KVUpsertOne) UpdateExpiresAt() *KVUpsertOne

UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.

func (*KVUpsertOne) UpdateKey

func (u *KVUpsertOne) UpdateKey() *KVUpsertOne

UpdateKey sets the "key" field to the value that was provided on create.

func (*KVUpsertOne) UpdateNewValues

func (u *KVUpsertOne) UpdateNewValues() *KVUpsertOne

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

client.KV.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
	).
	Exec(ctx)

func (*KVUpsertOne) UpdateUpdatedAt

func (u *KVUpsertOne) UpdateUpdatedAt() *KVUpsertOne

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

func (*KVUpsertOne) UpdateValue

func (u *KVUpsertOne) UpdateValue() *KVUpsertOne

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

type KVs

type KVs []*KV

KVs is a parsable slice of KV.

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 {

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

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

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

TxFromContext returns a Tx stored inside a context, or nil if there isn't one.

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidationError

type ValidationError struct {
	Name string // Field or edge name.
	// contains filtered or unexported fields
}

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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