ent

package
v0.0.0-...-afacdd9 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeLeaderElect = "LeaderElect"
)

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(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
Scan(ctx, &v)

func Count

func Count() AggregateFunc

Count applies the "count" aggregation function on each group.

func Max

func Max(field string) AggregateFunc

Max applies the "max" aggregation function on the given field of each group.

func Mean

func Mean(field string) AggregateFunc

Mean applies the "mean" aggregation function on the given field of each group.

func Min

func Min(field string) AggregateFunc

Min applies the "min" aggregation function on the given field of each group.

func Sum

func Sum(field string) AggregateFunc

Sum applies the "sum" aggregation function on the given field of each group.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// LeaderElect is the client for interacting with the LeaderElect builders.
	LeaderElect *LeaderElectClient
	// 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().
	LeaderElect.
	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 LeaderElect

type LeaderElect struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// 版本号
	ResourceVersion string `json:"resource_version,omitempty"`
	// LeaseDurationSeconds holds the value of the "lease_duration_seconds" field.
	LeaseDurationSeconds int `json:"lease_duration_seconds,omitempty"`
	// AcquireTime holds the value of the "acquire_time" field.
	AcquireTime int64 `json:"acquire_time,omitempty"`
	// RenewTime holds the value of the "renew_time" field.
	RenewTime int64 `json:"renew_time,omitempty"`
	// LeaderTransitions holds the value of the "leader_transitions" field.
	LeaderTransitions int `json:"leader_transitions,omitempty"`
	// HolderIdentity holds the value of the "holder_identity" field.
	HolderIdentity string `json:"holder_identity,omitempty"`
	// contains filtered or unexported fields
}

LeaderElect is the model entity for the LeaderElect schema.

func (*LeaderElect) String

func (le *LeaderElect) String() string

String implements the fmt.Stringer.

func (*LeaderElect) Unwrap

func (le *LeaderElect) Unwrap() *LeaderElect

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

func (le *LeaderElect) Update() *LeaderElectUpdateOne

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

func (*LeaderElect) Value

func (le *LeaderElect) Value(name string) (ent.Value, error)

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

type LeaderElectClient

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

LeaderElectClient is a client for the LeaderElect schema.

func NewLeaderElectClient

func NewLeaderElectClient(c config) *LeaderElectClient

NewLeaderElectClient returns a client for the LeaderElect from the given config.

func (*LeaderElectClient) Create

func (c *LeaderElectClient) Create() *LeaderElectCreate

Create returns a builder for creating a LeaderElect entity.

func (*LeaderElectClient) CreateBulk

func (c *LeaderElectClient) CreateBulk(builders ...*LeaderElectCreate) *LeaderElectCreateBulk

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

func (*LeaderElectClient) Delete

func (c *LeaderElectClient) Delete() *LeaderElectDelete

Delete returns a delete builder for LeaderElect.

func (*LeaderElectClient) DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*LeaderElectClient) DeleteOneID

func (c *LeaderElectClient) DeleteOneID(id string) *LeaderElectDeleteOne

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

func (*LeaderElectClient) Get

Get returns a LeaderElect entity by its id.

func (*LeaderElectClient) GetX

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

func (*LeaderElectClient) Hooks

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

Hooks returns the client hooks.

func (*LeaderElectClient) Intercept

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

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

func (*LeaderElectClient) Interceptors

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

Interceptors returns the client interceptors.

func (*LeaderElectClient) Query

func (c *LeaderElectClient) Query() *LeaderElectQuery

Query returns a query builder for LeaderElect.

func (*LeaderElectClient) Update

func (c *LeaderElectClient) Update() *LeaderElectUpdate

Update returns an update builder for LeaderElect.

func (*LeaderElectClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*LeaderElectClient) UpdateOneID

func (c *LeaderElectClient) UpdateOneID(id string) *LeaderElectUpdateOne

UpdateOneID returns an update builder for the given id.

func (*LeaderElectClient) Use

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

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

type LeaderElectCreate

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

LeaderElectCreate is the builder for creating a LeaderElect entity.

func (*LeaderElectCreate) Exec

func (lec *LeaderElectCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*LeaderElectCreate) ExecX

func (lec *LeaderElectCreate) ExecX(ctx context.Context)

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

func (*LeaderElectCreate) Mutation

func (lec *LeaderElectCreate) Mutation() *LeaderElectMutation

Mutation returns the LeaderElectMutation object of the builder.

func (*LeaderElectCreate) OnConflict

func (lec *LeaderElectCreate) OnConflict(opts ...sql.ConflictOption) *LeaderElectUpsertOne

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

client.LeaderElect.Create().
	SetResourceVersion(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.LeaderElectUpsert) {
		SetResourceVersion(v+v).
	}).
	Exec(ctx)

func (*LeaderElectCreate) OnConflictColumns

func (lec *LeaderElectCreate) OnConflictColumns(columns ...string) *LeaderElectUpsertOne

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

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

func (*LeaderElectCreate) Save

func (lec *LeaderElectCreate) Save(ctx context.Context) (*LeaderElect, error)

Save creates the LeaderElect in the database.

func (*LeaderElectCreate) SaveX

func (lec *LeaderElectCreate) SaveX(ctx context.Context) *LeaderElect

SaveX calls Save and panics if Save returns an error.

func (*LeaderElectCreate) SetAcquireTime

func (lec *LeaderElectCreate) SetAcquireTime(i int64) *LeaderElectCreate

SetAcquireTime sets the "acquire_time" field.

func (*LeaderElectCreate) SetHolderIdentity

func (lec *LeaderElectCreate) SetHolderIdentity(s string) *LeaderElectCreate

SetHolderIdentity sets the "holder_identity" field.

func (*LeaderElectCreate) SetID

SetID sets the "id" field.

func (*LeaderElectCreate) SetLeaderTransitions

func (lec *LeaderElectCreate) SetLeaderTransitions(i int) *LeaderElectCreate

SetLeaderTransitions sets the "leader_transitions" field.

func (*LeaderElectCreate) SetLeaseDurationSeconds

func (lec *LeaderElectCreate) SetLeaseDurationSeconds(i int) *LeaderElectCreate

SetLeaseDurationSeconds sets the "lease_duration_seconds" field.

func (*LeaderElectCreate) SetNillableResourceVersion

func (lec *LeaderElectCreate) SetNillableResourceVersion(s *string) *LeaderElectCreate

SetNillableResourceVersion sets the "resource_version" field if the given value is not nil.

func (*LeaderElectCreate) SetRenewTime

func (lec *LeaderElectCreate) SetRenewTime(i int64) *LeaderElectCreate

SetRenewTime sets the "renew_time" field.

func (*LeaderElectCreate) SetResourceVersion

func (lec *LeaderElectCreate) SetResourceVersion(s string) *LeaderElectCreate

SetResourceVersion sets the "resource_version" field.

type LeaderElectCreateBulk

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

LeaderElectCreateBulk is the builder for creating many LeaderElect entities in bulk.

func (*LeaderElectCreateBulk) Exec

func (lecb *LeaderElectCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*LeaderElectCreateBulk) ExecX

func (lecb *LeaderElectCreateBulk) ExecX(ctx context.Context)

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

func (*LeaderElectCreateBulk) OnConflict

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

client.LeaderElect.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.LeaderElectUpsert) {
		SetResourceVersion(v+v).
	}).
	Exec(ctx)

func (*LeaderElectCreateBulk) OnConflictColumns

func (lecb *LeaderElectCreateBulk) OnConflictColumns(columns ...string) *LeaderElectUpsertBulk

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

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

func (*LeaderElectCreateBulk) Save

func (lecb *LeaderElectCreateBulk) Save(ctx context.Context) ([]*LeaderElect, error)

Save creates the LeaderElect entities in the database.

func (*LeaderElectCreateBulk) SaveX

func (lecb *LeaderElectCreateBulk) SaveX(ctx context.Context) []*LeaderElect

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

type LeaderElectDelete

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

LeaderElectDelete is the builder for deleting a LeaderElect entity.

func (*LeaderElectDelete) Exec

func (led *LeaderElectDelete) Exec(ctx context.Context) (int, error)

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

func (*LeaderElectDelete) ExecX

func (led *LeaderElectDelete) ExecX(ctx context.Context) int

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

func (*LeaderElectDelete) Where

Where appends a list predicates to the LeaderElectDelete builder.

type LeaderElectDeleteOne

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

LeaderElectDeleteOne is the builder for deleting a single LeaderElect entity.

func (*LeaderElectDeleteOne) Exec

func (ledo *LeaderElectDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*LeaderElectDeleteOne) ExecX

func (ledo *LeaderElectDeleteOne) ExecX(ctx context.Context)

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

func (*LeaderElectDeleteOne) Where

Where appends a list predicates to the LeaderElectDelete builder.

type LeaderElectGroupBy

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

LeaderElectGroupBy is the group-by builder for LeaderElect entities.

func (*LeaderElectGroupBy) Aggregate

func (legb *LeaderElectGroupBy) Aggregate(fns ...AggregateFunc) *LeaderElectGroupBy

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

func (*LeaderElectGroupBy) Bool

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

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

func (*LeaderElectGroupBy) BoolX

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

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

func (*LeaderElectGroupBy) Bools

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

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

func (*LeaderElectGroupBy) BoolsX

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

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

func (*LeaderElectGroupBy) Float64

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

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

func (*LeaderElectGroupBy) Float64X

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

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

func (*LeaderElectGroupBy) Float64s

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

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

func (*LeaderElectGroupBy) Float64sX

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

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

func (*LeaderElectGroupBy) Int

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

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

func (*LeaderElectGroupBy) IntX

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

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

func (*LeaderElectGroupBy) Ints

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

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

func (*LeaderElectGroupBy) IntsX

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

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

func (*LeaderElectGroupBy) Scan

func (legb *LeaderElectGroupBy) Scan(ctx context.Context, v any) error

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

func (*LeaderElectGroupBy) ScanX

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

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

func (*LeaderElectGroupBy) String

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

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

func (*LeaderElectGroupBy) StringX

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

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

func (*LeaderElectGroupBy) Strings

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

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

func (*LeaderElectGroupBy) StringsX

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

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

type LeaderElectMutation

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

LeaderElectMutation represents an operation that mutates the LeaderElect nodes in the graph.

func (*LeaderElectMutation) AcquireTime

func (m *LeaderElectMutation) AcquireTime() (r int64, exists bool)

AcquireTime returns the value of the "acquire_time" field in the mutation.

func (*LeaderElectMutation) AddAcquireTime

func (m *LeaderElectMutation) AddAcquireTime(i int64)

AddAcquireTime adds i to the "acquire_time" field.

func (*LeaderElectMutation) AddField

func (m *LeaderElectMutation) 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 (*LeaderElectMutation) AddLeaderTransitions

func (m *LeaderElectMutation) AddLeaderTransitions(i int)

AddLeaderTransitions adds i to the "leader_transitions" field.

func (*LeaderElectMutation) AddLeaseDurationSeconds

func (m *LeaderElectMutation) AddLeaseDurationSeconds(i int)

AddLeaseDurationSeconds adds i to the "lease_duration_seconds" field.

func (*LeaderElectMutation) AddRenewTime

func (m *LeaderElectMutation) AddRenewTime(i int64)

AddRenewTime adds i to the "renew_time" field.

func (*LeaderElectMutation) AddedAcquireTime

func (m *LeaderElectMutation) AddedAcquireTime() (r int64, exists bool)

AddedAcquireTime returns the value that was added to the "acquire_time" field in this mutation.

func (*LeaderElectMutation) AddedEdges

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

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

func (*LeaderElectMutation) AddedField

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

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

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

func (*LeaderElectMutation) AddedIDs

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

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

func (*LeaderElectMutation) AddedLeaderTransitions

func (m *LeaderElectMutation) AddedLeaderTransitions() (r int, exists bool)

AddedLeaderTransitions returns the value that was added to the "leader_transitions" field in this mutation.

func (*LeaderElectMutation) AddedLeaseDurationSeconds

func (m *LeaderElectMutation) AddedLeaseDurationSeconds() (r int, exists bool)

AddedLeaseDurationSeconds returns the value that was added to the "lease_duration_seconds" field in this mutation.

func (*LeaderElectMutation) AddedRenewTime

func (m *LeaderElectMutation) AddedRenewTime() (r int64, exists bool)

AddedRenewTime returns the value that was added to the "renew_time" field in this mutation.

func (*LeaderElectMutation) ClearEdge

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

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

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

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

func (*LeaderElectMutation) ClearedFields

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

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

func (LeaderElectMutation) Client

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

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

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

func (*LeaderElectMutation) Field

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

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

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

func (*LeaderElectMutation) Fields

func (m *LeaderElectMutation) 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 (*LeaderElectMutation) HolderIdentity

func (m *LeaderElectMutation) HolderIdentity() (r string, exists bool)

HolderIdentity returns the value of the "holder_identity" field in the mutation.

func (*LeaderElectMutation) ID

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

func (m *LeaderElectMutation) 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 (*LeaderElectMutation) LeaderTransitions

func (m *LeaderElectMutation) LeaderTransitions() (r int, exists bool)

LeaderTransitions returns the value of the "leader_transitions" field in the mutation.

func (*LeaderElectMutation) LeaseDurationSeconds

func (m *LeaderElectMutation) LeaseDurationSeconds() (r int, exists bool)

LeaseDurationSeconds returns the value of the "lease_duration_seconds" field in the mutation.

func (*LeaderElectMutation) OldAcquireTime

func (m *LeaderElectMutation) OldAcquireTime(ctx context.Context) (v int64, err error)

OldAcquireTime returns the old "acquire_time" field's value of the LeaderElect entity. If the LeaderElect 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 (*LeaderElectMutation) OldField

func (m *LeaderElectMutation) 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 (*LeaderElectMutation) OldHolderIdentity

func (m *LeaderElectMutation) OldHolderIdentity(ctx context.Context) (v string, err error)

OldHolderIdentity returns the old "holder_identity" field's value of the LeaderElect entity. If the LeaderElect 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 (*LeaderElectMutation) OldLeaderTransitions

func (m *LeaderElectMutation) OldLeaderTransitions(ctx context.Context) (v int, err error)

OldLeaderTransitions returns the old "leader_transitions" field's value of the LeaderElect entity. If the LeaderElect 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 (*LeaderElectMutation) OldLeaseDurationSeconds

func (m *LeaderElectMutation) OldLeaseDurationSeconds(ctx context.Context) (v int, err error)

OldLeaseDurationSeconds returns the old "lease_duration_seconds" field's value of the LeaderElect entity. If the LeaderElect 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 (*LeaderElectMutation) OldRenewTime

func (m *LeaderElectMutation) OldRenewTime(ctx context.Context) (v int64, err error)

OldRenewTime returns the old "renew_time" field's value of the LeaderElect entity. If the LeaderElect 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 (*LeaderElectMutation) OldResourceVersion

func (m *LeaderElectMutation) OldResourceVersion(ctx context.Context) (v string, err error)

OldResourceVersion returns the old "resource_version" field's value of the LeaderElect entity. If the LeaderElect 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 (*LeaderElectMutation) Op

func (m *LeaderElectMutation) Op() Op

Op returns the operation name.

func (*LeaderElectMutation) RemovedEdges

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

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

func (*LeaderElectMutation) RemovedIDs

func (m *LeaderElectMutation) 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 (*LeaderElectMutation) RenewTime

func (m *LeaderElectMutation) RenewTime() (r int64, exists bool)

RenewTime returns the value of the "renew_time" field in the mutation.

func (*LeaderElectMutation) ResetAcquireTime

func (m *LeaderElectMutation) ResetAcquireTime()

ResetAcquireTime resets all changes to the "acquire_time" field.

func (*LeaderElectMutation) ResetEdge

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

func (m *LeaderElectMutation) 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 (*LeaderElectMutation) ResetHolderIdentity

func (m *LeaderElectMutation) ResetHolderIdentity()

ResetHolderIdentity resets all changes to the "holder_identity" field.

func (*LeaderElectMutation) ResetLeaderTransitions

func (m *LeaderElectMutation) ResetLeaderTransitions()

ResetLeaderTransitions resets all changes to the "leader_transitions" field.

func (*LeaderElectMutation) ResetLeaseDurationSeconds

func (m *LeaderElectMutation) ResetLeaseDurationSeconds()

ResetLeaseDurationSeconds resets all changes to the "lease_duration_seconds" field.

func (*LeaderElectMutation) ResetRenewTime

func (m *LeaderElectMutation) ResetRenewTime()

ResetRenewTime resets all changes to the "renew_time" field.

func (*LeaderElectMutation) ResetResourceVersion

func (m *LeaderElectMutation) ResetResourceVersion()

ResetResourceVersion resets all changes to the "resource_version" field.

func (*LeaderElectMutation) ResourceVersion

func (m *LeaderElectMutation) ResourceVersion() (r string, exists bool)

ResourceVersion returns the value of the "resource_version" field in the mutation.

func (*LeaderElectMutation) SetAcquireTime

func (m *LeaderElectMutation) SetAcquireTime(i int64)

SetAcquireTime sets the "acquire_time" field.

func (*LeaderElectMutation) SetField

func (m *LeaderElectMutation) 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 (*LeaderElectMutation) SetHolderIdentity

func (m *LeaderElectMutation) SetHolderIdentity(s string)

SetHolderIdentity sets the "holder_identity" field.

func (*LeaderElectMutation) SetID

func (m *LeaderElectMutation) SetID(id string)

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

func (*LeaderElectMutation) SetLeaderTransitions

func (m *LeaderElectMutation) SetLeaderTransitions(i int)

SetLeaderTransitions sets the "leader_transitions" field.

func (*LeaderElectMutation) SetLeaseDurationSeconds

func (m *LeaderElectMutation) SetLeaseDurationSeconds(i int)

SetLeaseDurationSeconds sets the "lease_duration_seconds" field.

func (*LeaderElectMutation) SetOp

func (m *LeaderElectMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*LeaderElectMutation) SetRenewTime

func (m *LeaderElectMutation) SetRenewTime(i int64)

SetRenewTime sets the "renew_time" field.

func (*LeaderElectMutation) SetResourceVersion

func (m *LeaderElectMutation) SetResourceVersion(s string)

SetResourceVersion sets the "resource_version" field.

func (LeaderElectMutation) Tx

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

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

func (*LeaderElectMutation) Type

func (m *LeaderElectMutation) Type() string

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

func (*LeaderElectMutation) Where

func (m *LeaderElectMutation) Where(ps ...predicate.LeaderElect)

Where appends a list predicates to the LeaderElectMutation builder.

func (*LeaderElectMutation) WhereP

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

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

type LeaderElectQuery

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

LeaderElectQuery is the builder for querying LeaderElect entities.

func (*LeaderElectQuery) Aggregate

func (leq *LeaderElectQuery) Aggregate(fns ...AggregateFunc) *LeaderElectSelect

Aggregate returns a LeaderElectSelect configured with the given aggregations.

func (*LeaderElectQuery) All

func (leq *LeaderElectQuery) All(ctx context.Context) ([]*LeaderElect, error)

All executes the query and returns a list of LeaderElects.

func (*LeaderElectQuery) AllX

func (leq *LeaderElectQuery) AllX(ctx context.Context) []*LeaderElect

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

func (*LeaderElectQuery) Clone

func (leq *LeaderElectQuery) Clone() *LeaderElectQuery

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

func (*LeaderElectQuery) Count

func (leq *LeaderElectQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*LeaderElectQuery) CountX

func (leq *LeaderElectQuery) CountX(ctx context.Context) int

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

func (*LeaderElectQuery) Exist

func (leq *LeaderElectQuery) Exist(ctx context.Context) (bool, error)

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

func (*LeaderElectQuery) ExistX

func (leq *LeaderElectQuery) ExistX(ctx context.Context) bool

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

func (*LeaderElectQuery) First

func (leq *LeaderElectQuery) First(ctx context.Context) (*LeaderElect, error)

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

func (*LeaderElectQuery) FirstID

func (leq *LeaderElectQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*LeaderElectQuery) FirstIDX

func (leq *LeaderElectQuery) FirstIDX(ctx context.Context) string

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

func (*LeaderElectQuery) FirstX

func (leq *LeaderElectQuery) FirstX(ctx context.Context) *LeaderElect

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

func (*LeaderElectQuery) GroupBy

func (leq *LeaderElectQuery) GroupBy(field string, fields ...string) *LeaderElectGroupBy

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

client.LeaderElect.Query().
	GroupBy(leaderelect.FieldResourceVersion).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*LeaderElectQuery) IDs

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

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

func (*LeaderElectQuery) IDsX

func (leq *LeaderElectQuery) IDsX(ctx context.Context) []string

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

func (*LeaderElectQuery) Limit

func (leq *LeaderElectQuery) Limit(limit int) *LeaderElectQuery

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

func (*LeaderElectQuery) Offset

func (leq *LeaderElectQuery) Offset(offset int) *LeaderElectQuery

Offset to start from.

func (*LeaderElectQuery) Only

func (leq *LeaderElectQuery) Only(ctx context.Context) (*LeaderElect, error)

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

func (*LeaderElectQuery) OnlyID

func (leq *LeaderElectQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*LeaderElectQuery) OnlyIDX

func (leq *LeaderElectQuery) OnlyIDX(ctx context.Context) string

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

func (*LeaderElectQuery) OnlyX

func (leq *LeaderElectQuery) OnlyX(ctx context.Context) *LeaderElect

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

func (*LeaderElectQuery) Order

Order specifies how the records should be ordered.

func (*LeaderElectQuery) Select

func (leq *LeaderElectQuery) Select(fields ...string) *LeaderElectSelect

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

client.LeaderElect.Query().
	Select(leaderelect.FieldResourceVersion).
	Scan(ctx, &v)

func (*LeaderElectQuery) Unique

func (leq *LeaderElectQuery) Unique(unique bool) *LeaderElectQuery

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

Where adds a new predicate for the LeaderElectQuery builder.

type LeaderElectSelect

type LeaderElectSelect struct {
	*LeaderElectQuery
	// contains filtered or unexported fields
}

LeaderElectSelect is the builder for selecting fields of LeaderElect entities.

func (*LeaderElectSelect) Aggregate

func (les *LeaderElectSelect) Aggregate(fns ...AggregateFunc) *LeaderElectSelect

Aggregate adds the given aggregation functions to the selector query.

func (*LeaderElectSelect) Bool

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

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

func (*LeaderElectSelect) BoolX

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

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

func (*LeaderElectSelect) Bools

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

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

func (*LeaderElectSelect) BoolsX

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

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

func (*LeaderElectSelect) Float64

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

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

func (*LeaderElectSelect) Float64X

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

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

func (*LeaderElectSelect) Float64s

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

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

func (*LeaderElectSelect) Float64sX

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

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

func (*LeaderElectSelect) Int

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

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

func (*LeaderElectSelect) IntX

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

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

func (*LeaderElectSelect) Ints

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

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

func (*LeaderElectSelect) IntsX

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

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

func (*LeaderElectSelect) Scan

func (les *LeaderElectSelect) Scan(ctx context.Context, v any) error

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

func (*LeaderElectSelect) ScanX

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

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

func (*LeaderElectSelect) String

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

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

func (*LeaderElectSelect) StringX

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

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

func (*LeaderElectSelect) Strings

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

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

func (*LeaderElectSelect) StringsX

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

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

type LeaderElectUpdate

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

LeaderElectUpdate is the builder for updating LeaderElect entities.

func (*LeaderElectUpdate) AddAcquireTime

func (leu *LeaderElectUpdate) AddAcquireTime(i int64) *LeaderElectUpdate

AddAcquireTime adds i to the "acquire_time" field.

func (*LeaderElectUpdate) AddLeaderTransitions

func (leu *LeaderElectUpdate) AddLeaderTransitions(i int) *LeaderElectUpdate

AddLeaderTransitions adds i to the "leader_transitions" field.

func (*LeaderElectUpdate) AddLeaseDurationSeconds

func (leu *LeaderElectUpdate) AddLeaseDurationSeconds(i int) *LeaderElectUpdate

AddLeaseDurationSeconds adds i to the "lease_duration_seconds" field.

func (*LeaderElectUpdate) AddRenewTime

func (leu *LeaderElectUpdate) AddRenewTime(i int64) *LeaderElectUpdate

AddRenewTime adds i to the "renew_time" field.

func (*LeaderElectUpdate) Exec

func (leu *LeaderElectUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*LeaderElectUpdate) ExecX

func (leu *LeaderElectUpdate) ExecX(ctx context.Context)

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

func (*LeaderElectUpdate) Mutation

func (leu *LeaderElectUpdate) Mutation() *LeaderElectMutation

Mutation returns the LeaderElectMutation object of the builder.

func (*LeaderElectUpdate) Save

func (leu *LeaderElectUpdate) Save(ctx context.Context) (int, error)

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

func (*LeaderElectUpdate) SaveX

func (leu *LeaderElectUpdate) SaveX(ctx context.Context) int

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

func (*LeaderElectUpdate) SetAcquireTime

func (leu *LeaderElectUpdate) SetAcquireTime(i int64) *LeaderElectUpdate

SetAcquireTime sets the "acquire_time" field.

func (*LeaderElectUpdate) SetHolderIdentity

func (leu *LeaderElectUpdate) SetHolderIdentity(s string) *LeaderElectUpdate

SetHolderIdentity sets the "holder_identity" field.

func (*LeaderElectUpdate) SetLeaderTransitions

func (leu *LeaderElectUpdate) SetLeaderTransitions(i int) *LeaderElectUpdate

SetLeaderTransitions sets the "leader_transitions" field.

func (*LeaderElectUpdate) SetLeaseDurationSeconds

func (leu *LeaderElectUpdate) SetLeaseDurationSeconds(i int) *LeaderElectUpdate

SetLeaseDurationSeconds sets the "lease_duration_seconds" field.

func (*LeaderElectUpdate) SetNillableResourceVersion

func (leu *LeaderElectUpdate) SetNillableResourceVersion(s *string) *LeaderElectUpdate

SetNillableResourceVersion sets the "resource_version" field if the given value is not nil.

func (*LeaderElectUpdate) SetRenewTime

func (leu *LeaderElectUpdate) SetRenewTime(i int64) *LeaderElectUpdate

SetRenewTime sets the "renew_time" field.

func (*LeaderElectUpdate) SetResourceVersion

func (leu *LeaderElectUpdate) SetResourceVersion(s string) *LeaderElectUpdate

SetResourceVersion sets the "resource_version" field.

func (*LeaderElectUpdate) Where

Where appends a list predicates to the LeaderElectUpdate builder.

type LeaderElectUpdateOne

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

LeaderElectUpdateOne is the builder for updating a single LeaderElect entity.

func (*LeaderElectUpdateOne) AddAcquireTime

func (leuo *LeaderElectUpdateOne) AddAcquireTime(i int64) *LeaderElectUpdateOne

AddAcquireTime adds i to the "acquire_time" field.

func (*LeaderElectUpdateOne) AddLeaderTransitions

func (leuo *LeaderElectUpdateOne) AddLeaderTransitions(i int) *LeaderElectUpdateOne

AddLeaderTransitions adds i to the "leader_transitions" field.

func (*LeaderElectUpdateOne) AddLeaseDurationSeconds

func (leuo *LeaderElectUpdateOne) AddLeaseDurationSeconds(i int) *LeaderElectUpdateOne

AddLeaseDurationSeconds adds i to the "lease_duration_seconds" field.

func (*LeaderElectUpdateOne) AddRenewTime

func (leuo *LeaderElectUpdateOne) AddRenewTime(i int64) *LeaderElectUpdateOne

AddRenewTime adds i to the "renew_time" field.

func (*LeaderElectUpdateOne) Exec

func (leuo *LeaderElectUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*LeaderElectUpdateOne) ExecX

func (leuo *LeaderElectUpdateOne) ExecX(ctx context.Context)

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

func (*LeaderElectUpdateOne) Mutation

func (leuo *LeaderElectUpdateOne) Mutation() *LeaderElectMutation

Mutation returns the LeaderElectMutation object of the builder.

func (*LeaderElectUpdateOne) Save

Save executes the query and returns the updated LeaderElect entity.

func (*LeaderElectUpdateOne) SaveX

func (leuo *LeaderElectUpdateOne) SaveX(ctx context.Context) *LeaderElect

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

func (*LeaderElectUpdateOne) Select

func (leuo *LeaderElectUpdateOne) Select(field string, fields ...string) *LeaderElectUpdateOne

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

func (*LeaderElectUpdateOne) SetAcquireTime

func (leuo *LeaderElectUpdateOne) SetAcquireTime(i int64) *LeaderElectUpdateOne

SetAcquireTime sets the "acquire_time" field.

func (*LeaderElectUpdateOne) SetHolderIdentity

func (leuo *LeaderElectUpdateOne) SetHolderIdentity(s string) *LeaderElectUpdateOne

SetHolderIdentity sets the "holder_identity" field.

func (*LeaderElectUpdateOne) SetLeaderTransitions

func (leuo *LeaderElectUpdateOne) SetLeaderTransitions(i int) *LeaderElectUpdateOne

SetLeaderTransitions sets the "leader_transitions" field.

func (*LeaderElectUpdateOne) SetLeaseDurationSeconds

func (leuo *LeaderElectUpdateOne) SetLeaseDurationSeconds(i int) *LeaderElectUpdateOne

SetLeaseDurationSeconds sets the "lease_duration_seconds" field.

func (*LeaderElectUpdateOne) SetNillableResourceVersion

func (leuo *LeaderElectUpdateOne) SetNillableResourceVersion(s *string) *LeaderElectUpdateOne

SetNillableResourceVersion sets the "resource_version" field if the given value is not nil.

func (*LeaderElectUpdateOne) SetRenewTime

func (leuo *LeaderElectUpdateOne) SetRenewTime(i int64) *LeaderElectUpdateOne

SetRenewTime sets the "renew_time" field.

func (*LeaderElectUpdateOne) SetResourceVersion

func (leuo *LeaderElectUpdateOne) SetResourceVersion(s string) *LeaderElectUpdateOne

SetResourceVersion sets the "resource_version" field.

func (*LeaderElectUpdateOne) Where

Where appends a list predicates to the LeaderElectUpdate builder.

type LeaderElectUpsert

type LeaderElectUpsert struct {
	*sql.UpdateSet
}

LeaderElectUpsert is the "OnConflict" setter.

func (*LeaderElectUpsert) AddAcquireTime

func (u *LeaderElectUpsert) AddAcquireTime(v int64) *LeaderElectUpsert

AddAcquireTime adds v to the "acquire_time" field.

func (*LeaderElectUpsert) AddLeaderTransitions

func (u *LeaderElectUpsert) AddLeaderTransitions(v int) *LeaderElectUpsert

AddLeaderTransitions adds v to the "leader_transitions" field.

func (*LeaderElectUpsert) AddLeaseDurationSeconds

func (u *LeaderElectUpsert) AddLeaseDurationSeconds(v int) *LeaderElectUpsert

AddLeaseDurationSeconds adds v to the "lease_duration_seconds" field.

func (*LeaderElectUpsert) AddRenewTime

func (u *LeaderElectUpsert) AddRenewTime(v int64) *LeaderElectUpsert

AddRenewTime adds v to the "renew_time" field.

func (*LeaderElectUpsert) SetAcquireTime

func (u *LeaderElectUpsert) SetAcquireTime(v int64) *LeaderElectUpsert

SetAcquireTime sets the "acquire_time" field.

func (*LeaderElectUpsert) SetHolderIdentity

func (u *LeaderElectUpsert) SetHolderIdentity(v string) *LeaderElectUpsert

SetHolderIdentity sets the "holder_identity" field.

func (*LeaderElectUpsert) SetLeaderTransitions

func (u *LeaderElectUpsert) SetLeaderTransitions(v int) *LeaderElectUpsert

SetLeaderTransitions sets the "leader_transitions" field.

func (*LeaderElectUpsert) SetLeaseDurationSeconds

func (u *LeaderElectUpsert) SetLeaseDurationSeconds(v int) *LeaderElectUpsert

SetLeaseDurationSeconds sets the "lease_duration_seconds" field.

func (*LeaderElectUpsert) SetRenewTime

func (u *LeaderElectUpsert) SetRenewTime(v int64) *LeaderElectUpsert

SetRenewTime sets the "renew_time" field.

func (*LeaderElectUpsert) SetResourceVersion

func (u *LeaderElectUpsert) SetResourceVersion(v string) *LeaderElectUpsert

SetResourceVersion sets the "resource_version" field.

func (*LeaderElectUpsert) UpdateAcquireTime

func (u *LeaderElectUpsert) UpdateAcquireTime() *LeaderElectUpsert

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

func (*LeaderElectUpsert) UpdateHolderIdentity

func (u *LeaderElectUpsert) UpdateHolderIdentity() *LeaderElectUpsert

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

func (*LeaderElectUpsert) UpdateLeaderTransitions

func (u *LeaderElectUpsert) UpdateLeaderTransitions() *LeaderElectUpsert

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

func (*LeaderElectUpsert) UpdateLeaseDurationSeconds

func (u *LeaderElectUpsert) UpdateLeaseDurationSeconds() *LeaderElectUpsert

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

func (*LeaderElectUpsert) UpdateRenewTime

func (u *LeaderElectUpsert) UpdateRenewTime() *LeaderElectUpsert

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

func (*LeaderElectUpsert) UpdateResourceVersion

func (u *LeaderElectUpsert) UpdateResourceVersion() *LeaderElectUpsert

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

type LeaderElectUpsertBulk

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

LeaderElectUpsertBulk is the builder for "upsert"-ing a bulk of LeaderElect nodes.

func (*LeaderElectUpsertBulk) AddAcquireTime

func (u *LeaderElectUpsertBulk) AddAcquireTime(v int64) *LeaderElectUpsertBulk

AddAcquireTime adds v to the "acquire_time" field.

func (*LeaderElectUpsertBulk) AddLeaderTransitions

func (u *LeaderElectUpsertBulk) AddLeaderTransitions(v int) *LeaderElectUpsertBulk

AddLeaderTransitions adds v to the "leader_transitions" field.

func (*LeaderElectUpsertBulk) AddLeaseDurationSeconds

func (u *LeaderElectUpsertBulk) AddLeaseDurationSeconds(v int) *LeaderElectUpsertBulk

AddLeaseDurationSeconds adds v to the "lease_duration_seconds" field.

func (*LeaderElectUpsertBulk) AddRenewTime

AddRenewTime adds v to the "renew_time" field.

func (*LeaderElectUpsertBulk) DoNothing

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

func (*LeaderElectUpsertBulk) Exec

Exec executes the query.

func (*LeaderElectUpsertBulk) ExecX

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

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

func (*LeaderElectUpsertBulk) Ignore

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

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

func (*LeaderElectUpsertBulk) SetAcquireTime

func (u *LeaderElectUpsertBulk) SetAcquireTime(v int64) *LeaderElectUpsertBulk

SetAcquireTime sets the "acquire_time" field.

func (*LeaderElectUpsertBulk) SetHolderIdentity

func (u *LeaderElectUpsertBulk) SetHolderIdentity(v string) *LeaderElectUpsertBulk

SetHolderIdentity sets the "holder_identity" field.

func (*LeaderElectUpsertBulk) SetLeaderTransitions

func (u *LeaderElectUpsertBulk) SetLeaderTransitions(v int) *LeaderElectUpsertBulk

SetLeaderTransitions sets the "leader_transitions" field.

func (*LeaderElectUpsertBulk) SetLeaseDurationSeconds

func (u *LeaderElectUpsertBulk) SetLeaseDurationSeconds(v int) *LeaderElectUpsertBulk

SetLeaseDurationSeconds sets the "lease_duration_seconds" field.

func (*LeaderElectUpsertBulk) SetRenewTime

SetRenewTime sets the "renew_time" field.

func (*LeaderElectUpsertBulk) SetResourceVersion

func (u *LeaderElectUpsertBulk) SetResourceVersion(v string) *LeaderElectUpsertBulk

SetResourceVersion sets the "resource_version" field.

func (*LeaderElectUpsertBulk) Update

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

func (*LeaderElectUpsertBulk) UpdateAcquireTime

func (u *LeaderElectUpsertBulk) UpdateAcquireTime() *LeaderElectUpsertBulk

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

func (*LeaderElectUpsertBulk) UpdateHolderIdentity

func (u *LeaderElectUpsertBulk) UpdateHolderIdentity() *LeaderElectUpsertBulk

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

func (*LeaderElectUpsertBulk) UpdateLeaderTransitions

func (u *LeaderElectUpsertBulk) UpdateLeaderTransitions() *LeaderElectUpsertBulk

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

func (*LeaderElectUpsertBulk) UpdateLeaseDurationSeconds

func (u *LeaderElectUpsertBulk) UpdateLeaseDurationSeconds() *LeaderElectUpsertBulk

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

func (*LeaderElectUpsertBulk) UpdateNewValues

func (u *LeaderElectUpsertBulk) UpdateNewValues() *LeaderElectUpsertBulk

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

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

func (*LeaderElectUpsertBulk) UpdateRenewTime

func (u *LeaderElectUpsertBulk) UpdateRenewTime() *LeaderElectUpsertBulk

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

func (*LeaderElectUpsertBulk) UpdateResourceVersion

func (u *LeaderElectUpsertBulk) UpdateResourceVersion() *LeaderElectUpsertBulk

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

type LeaderElectUpsertOne

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

LeaderElectUpsertOne is the builder for "upsert"-ing

one LeaderElect node.

func (*LeaderElectUpsertOne) AddAcquireTime

func (u *LeaderElectUpsertOne) AddAcquireTime(v int64) *LeaderElectUpsertOne

AddAcquireTime adds v to the "acquire_time" field.

func (*LeaderElectUpsertOne) AddLeaderTransitions

func (u *LeaderElectUpsertOne) AddLeaderTransitions(v int) *LeaderElectUpsertOne

AddLeaderTransitions adds v to the "leader_transitions" field.

func (*LeaderElectUpsertOne) AddLeaseDurationSeconds

func (u *LeaderElectUpsertOne) AddLeaseDurationSeconds(v int) *LeaderElectUpsertOne

AddLeaseDurationSeconds adds v to the "lease_duration_seconds" field.

func (*LeaderElectUpsertOne) AddRenewTime

func (u *LeaderElectUpsertOne) AddRenewTime(v int64) *LeaderElectUpsertOne

AddRenewTime adds v to the "renew_time" field.

func (*LeaderElectUpsertOne) DoNothing

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

func (*LeaderElectUpsertOne) Exec

Exec executes the query.

func (*LeaderElectUpsertOne) ExecX

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

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

func (*LeaderElectUpsertOne) ID

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

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

func (*LeaderElectUpsertOne) IDX

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

func (*LeaderElectUpsertOne) Ignore

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

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

func (*LeaderElectUpsertOne) SetAcquireTime

func (u *LeaderElectUpsertOne) SetAcquireTime(v int64) *LeaderElectUpsertOne

SetAcquireTime sets the "acquire_time" field.

func (*LeaderElectUpsertOne) SetHolderIdentity

func (u *LeaderElectUpsertOne) SetHolderIdentity(v string) *LeaderElectUpsertOne

SetHolderIdentity sets the "holder_identity" field.

func (*LeaderElectUpsertOne) SetLeaderTransitions

func (u *LeaderElectUpsertOne) SetLeaderTransitions(v int) *LeaderElectUpsertOne

SetLeaderTransitions sets the "leader_transitions" field.

func (*LeaderElectUpsertOne) SetLeaseDurationSeconds

func (u *LeaderElectUpsertOne) SetLeaseDurationSeconds(v int) *LeaderElectUpsertOne

SetLeaseDurationSeconds sets the "lease_duration_seconds" field.

func (*LeaderElectUpsertOne) SetRenewTime

func (u *LeaderElectUpsertOne) SetRenewTime(v int64) *LeaderElectUpsertOne

SetRenewTime sets the "renew_time" field.

func (*LeaderElectUpsertOne) SetResourceVersion

func (u *LeaderElectUpsertOne) SetResourceVersion(v string) *LeaderElectUpsertOne

SetResourceVersion sets the "resource_version" field.

func (*LeaderElectUpsertOne) Update

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

func (*LeaderElectUpsertOne) UpdateAcquireTime

func (u *LeaderElectUpsertOne) UpdateAcquireTime() *LeaderElectUpsertOne

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

func (*LeaderElectUpsertOne) UpdateHolderIdentity

func (u *LeaderElectUpsertOne) UpdateHolderIdentity() *LeaderElectUpsertOne

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

func (*LeaderElectUpsertOne) UpdateLeaderTransitions

func (u *LeaderElectUpsertOne) UpdateLeaderTransitions() *LeaderElectUpsertOne

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

func (*LeaderElectUpsertOne) UpdateLeaseDurationSeconds

func (u *LeaderElectUpsertOne) UpdateLeaseDurationSeconds() *LeaderElectUpsertOne

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

func (*LeaderElectUpsertOne) UpdateNewValues

func (u *LeaderElectUpsertOne) UpdateNewValues() *LeaderElectUpsertOne

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.LeaderElect.Create().
	OnConflict(
		sql.ResolveWithNewValues(),
		sql.ResolveWith(func(u *sql.UpdateSet) {
			u.SetIgnore(leaderelect.FieldID)
		}),
	).
	Exec(ctx)

func (*LeaderElectUpsertOne) UpdateRenewTime

func (u *LeaderElectUpsertOne) UpdateRenewTime() *LeaderElectUpsertOne

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

func (*LeaderElectUpsertOne) UpdateResourceVersion

func (u *LeaderElectUpsertOne) UpdateResourceVersion() *LeaderElectUpsertOne

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

type LeaderElects

type LeaderElects []*LeaderElect

LeaderElects is a parsable slice of LeaderElect.

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 {

	// LeaderElect is the client for interacting with the LeaderElect builders.
	LeaderElect *LeaderElectClient
	// 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