ent

package
v0.1.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

	// Node types.
	TypeLock = "Lock"
)

Variables

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

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

Functions

func Asc

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

Asc applies the given fields in ASC order.

func Desc

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

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

IsConstraintError returns a boolean indicating whether the error is a constraint failure.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns a boolean indicating whether the error is a not found error.

func IsNotLoaded

func IsNotLoaded(err error) bool

IsNotLoaded returns a boolean indicating whether the error is a not loaded error.

func IsNotSingular

func IsNotSingular(err error) bool

IsNotSingular returns a boolean indicating whether the error is a not singular error.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns a boolean indicating whether the error is a validation error.

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

func NewContext(parent context.Context, c *Client) context.Context

NewContext returns a new context with the given Client attached.

func NewTxContext

func NewTxContext(parent context.Context, tx *Tx) context.Context

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

AggregateFunc applies an aggregation step on the group-by traversal/selector.

func As

As is a pseudo aggregation function for renaming another other functions with custom names. For example:

GroupBy(field1, field2).
Aggregate(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
	// Lock is the client for interacting with the Lock builders.
	Lock *LockClient
	// 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().
	Lock.
	Query().
	Count(ctx)

func (*Client) ExecContext

func (c *Client) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

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

func (c *Client) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

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 Lock

type Lock struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// Version holds the value of the "version" field.
	Version uuid.UUID `json:"version,omitempty"`
	// Owner holds the value of the "owner" field.
	Owner string `json:"owner,omitempty"`
	// contains filtered or unexported fields
}

Lock is the model entity for the Lock schema.

func (*Lock) ExecContext

func (c *Lock) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*Lock) QueryContext

func (c *Lock) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*Lock) String

func (l *Lock) String() string

String implements the fmt.Stringer.

func (*Lock) Unwrap

func (l *Lock) Unwrap() *Lock

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

func (l *Lock) Update() *LockUpdateOne

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

func (*Lock) Value

func (l *Lock) Value(name string) (ent.Value, error)

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

type LockClient

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

LockClient is a client for the Lock schema.

func NewLockClient

func NewLockClient(c config) *LockClient

NewLockClient returns a client for the Lock from the given config.

func (*LockClient) Create

func (c *LockClient) Create() *LockCreate

Create returns a builder for creating a Lock entity.

func (*LockClient) CreateBulk

func (c *LockClient) CreateBulk(builders ...*LockCreate) *LockCreateBulk

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

func (*LockClient) Delete

func (c *LockClient) Delete() *LockDelete

Delete returns a delete builder for Lock.

func (*LockClient) DeleteOne

func (c *LockClient) DeleteOne(l *Lock) *LockDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*LockClient) DeleteOneID

func (c *LockClient) DeleteOneID(id string) *LockDeleteOne

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

func (*LockClient) ExecContext

func (c *LockClient) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockClient) Get

func (c *LockClient) Get(ctx context.Context, id string) (*Lock, error)

Get returns a Lock entity by its id.

func (*LockClient) GetX

func (c *LockClient) GetX(ctx context.Context, id string) *Lock

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

func (*LockClient) Hooks

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

Hooks returns the client hooks.

func (*LockClient) Intercept

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

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

func (*LockClient) Interceptors

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

Interceptors returns the client interceptors.

func (*LockClient) MapCreateBulk

func (c *LockClient) MapCreateBulk(slice any, setFunc func(*LockCreate, int)) *LockCreateBulk

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

func (*LockClient) Query

func (c *LockClient) Query() *LockQuery

Query returns a query builder for Lock.

func (*LockClient) QueryContext

func (c *LockClient) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockClient) Update

func (c *LockClient) Update() *LockUpdate

Update returns an update builder for Lock.

func (*LockClient) UpdateOne

func (c *LockClient) UpdateOne(l *Lock) *LockUpdateOne

UpdateOne returns an update builder for the given entity.

func (*LockClient) UpdateOneID

func (c *LockClient) UpdateOneID(id string) *LockUpdateOne

UpdateOneID returns an update builder for the given id.

func (*LockClient) Use

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

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

type LockCreate

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

LockCreate is the builder for creating a Lock entity.

func (*LockCreate) Exec

func (lc *LockCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*LockCreate) ExecContext

func (c *LockCreate) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockCreate) ExecX

func (lc *LockCreate) ExecX(ctx context.Context)

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

func (*LockCreate) Mutation

func (lc *LockCreate) Mutation() *LockMutation

Mutation returns the LockMutation object of the builder.

func (*LockCreate) OnConflict

func (lc *LockCreate) OnConflict(opts ...sql.ConflictOption) *LockUpsertOne

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

client.Lock.Create().
	SetVersion(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.LockUpsert) {
		SetVersion(v+v).
	}).
	Exec(ctx)

func (*LockCreate) OnConflictColumns

func (lc *LockCreate) OnConflictColumns(columns ...string) *LockUpsertOne

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

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

func (*LockCreate) QueryContext

func (c *LockCreate) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockCreate) Save

func (lc *LockCreate) Save(ctx context.Context) (*Lock, error)

Save creates the Lock in the database.

func (*LockCreate) SaveX

func (lc *LockCreate) SaveX(ctx context.Context) *Lock

SaveX calls Save and panics if Save returns an error.

func (*LockCreate) SetID added in v0.1.1

func (lc *LockCreate) SetID(s string) *LockCreate

SetID sets the "id" field.

func (*LockCreate) SetNillableVersion added in v0.1.1

func (lc *LockCreate) SetNillableVersion(u *uuid.UUID) *LockCreate

SetNillableVersion sets the "version" field if the given value is not nil.

func (*LockCreate) SetOwner

func (lc *LockCreate) SetOwner(s string) *LockCreate

SetOwner sets the "owner" field.

func (*LockCreate) SetVersion added in v0.1.1

func (lc *LockCreate) SetVersion(u uuid.UUID) *LockCreate

SetVersion sets the "version" field.

type LockCreateBulk

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

LockCreateBulk is the builder for creating many Lock entities in bulk.

func (*LockCreateBulk) Exec

func (lcb *LockCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*LockCreateBulk) ExecContext

func (c *LockCreateBulk) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockCreateBulk) ExecX

func (lcb *LockCreateBulk) ExecX(ctx context.Context)

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

func (*LockCreateBulk) OnConflict

func (lcb *LockCreateBulk) OnConflict(opts ...sql.ConflictOption) *LockUpsertBulk

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

client.Lock.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.LockUpsert) {
		SetVersion(v+v).
	}).
	Exec(ctx)

func (*LockCreateBulk) OnConflictColumns

func (lcb *LockCreateBulk) OnConflictColumns(columns ...string) *LockUpsertBulk

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

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

func (*LockCreateBulk) QueryContext

func (c *LockCreateBulk) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockCreateBulk) Save

func (lcb *LockCreateBulk) Save(ctx context.Context) ([]*Lock, error)

Save creates the Lock entities in the database.

func (*LockCreateBulk) SaveX

func (lcb *LockCreateBulk) SaveX(ctx context.Context) []*Lock

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

type LockDelete

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

LockDelete is the builder for deleting a Lock entity.

func (*LockDelete) Exec

func (ld *LockDelete) Exec(ctx context.Context) (int, error)

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

func (*LockDelete) ExecContext

func (c *LockDelete) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockDelete) ExecX

func (ld *LockDelete) ExecX(ctx context.Context) int

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

func (*LockDelete) QueryContext

func (c *LockDelete) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockDelete) Where

func (ld *LockDelete) Where(ps ...predicate.Lock) *LockDelete

Where appends a list predicates to the LockDelete builder.

type LockDeleteOne

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

LockDeleteOne is the builder for deleting a single Lock entity.

func (*LockDeleteOne) Exec

func (ldo *LockDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*LockDeleteOne) ExecX

func (ldo *LockDeleteOne) ExecX(ctx context.Context)

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

func (*LockDeleteOne) Where

func (ldo *LockDeleteOne) Where(ps ...predicate.Lock) *LockDeleteOne

Where appends a list predicates to the LockDelete builder.

type LockGroupBy

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

LockGroupBy is the group-by builder for Lock entities.

func (*LockGroupBy) Aggregate

func (lgb *LockGroupBy) Aggregate(fns ...AggregateFunc) *LockGroupBy

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

func (*LockGroupBy) Bool

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

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

func (*LockGroupBy) BoolX

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

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

func (*LockGroupBy) Bools

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

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

func (*LockGroupBy) BoolsX

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

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

func (*LockGroupBy) Float64

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

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

func (*LockGroupBy) Float64X

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

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

func (*LockGroupBy) Float64s

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

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

func (*LockGroupBy) Float64sX

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

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

func (*LockGroupBy) Int

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

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

func (*LockGroupBy) IntX

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

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

func (*LockGroupBy) Ints

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

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

func (*LockGroupBy) IntsX

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

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

func (*LockGroupBy) Scan

func (lgb *LockGroupBy) Scan(ctx context.Context, v any) error

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

func (*LockGroupBy) ScanX

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

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

func (*LockGroupBy) String

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

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

func (*LockGroupBy) StringX

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

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

func (*LockGroupBy) Strings

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

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

func (*LockGroupBy) StringsX

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

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

type LockMutation

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

LockMutation represents an operation that mutates the Lock nodes in the graph.

func (*LockMutation) AddField

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

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

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

func (*LockMutation) AddedField

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

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

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

func (*LockMutation) AddedIDs

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

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

func (*LockMutation) ClearEdge

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

func (m *LockMutation) 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 (*LockMutation) ClearVersion added in v0.1.1

func (m *LockMutation) ClearVersion()

ClearVersion clears the value of the "version" field.

func (*LockMutation) ClearedEdges

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

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

func (*LockMutation) ClearedFields

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

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

func (LockMutation) Client

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

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

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

func (*LockMutation) ExecContext

func (c *LockMutation) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockMutation) Field

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

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

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

func (*LockMutation) Fields

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

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

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

func (m *LockMutation) 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 (*LockMutation) OldOwner

func (m *LockMutation) OldOwner(ctx context.Context) (v string, err error)

OldOwner returns the old "owner" field's value of the Lock entity. If the Lock 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 (*LockMutation) OldVersion added in v0.1.1

func (m *LockMutation) OldVersion(ctx context.Context) (v uuid.UUID, err error)

OldVersion returns the old "version" field's value of the Lock entity. If the Lock 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 (*LockMutation) Op

func (m *LockMutation) Op() Op

Op returns the operation name.

func (*LockMutation) Owner

func (m *LockMutation) Owner() (r string, exists bool)

Owner returns the value of the "owner" field in the mutation.

func (*LockMutation) QueryContext

func (c *LockMutation) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockMutation) RemovedEdges

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

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

func (*LockMutation) RemovedIDs

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

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

func (m *LockMutation) 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 (*LockMutation) ResetOwner

func (m *LockMutation) ResetOwner()

ResetOwner resets all changes to the "owner" field.

func (*LockMutation) ResetVersion added in v0.1.1

func (m *LockMutation) ResetVersion()

ResetVersion resets all changes to the "version" field.

func (*LockMutation) SetField

func (m *LockMutation) 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 (*LockMutation) SetID added in v0.1.1

func (m *LockMutation) SetID(id string)

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

func (*LockMutation) SetOp

func (m *LockMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*LockMutation) SetOwner

func (m *LockMutation) SetOwner(s string)

SetOwner sets the "owner" field.

func (*LockMutation) SetVersion added in v0.1.1

func (m *LockMutation) SetVersion(u uuid.UUID)

SetVersion sets the "version" field.

func (LockMutation) Tx

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

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

func (*LockMutation) Type

func (m *LockMutation) Type() string

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

func (*LockMutation) Version added in v0.1.1

func (m *LockMutation) Version() (r uuid.UUID, exists bool)

Version returns the value of the "version" field in the mutation.

func (*LockMutation) VersionCleared added in v0.1.1

func (m *LockMutation) VersionCleared() bool

VersionCleared returns if the "version" field was cleared in this mutation.

func (*LockMutation) Where

func (m *LockMutation) Where(ps ...predicate.Lock)

Where appends a list predicates to the LockMutation builder.

func (*LockMutation) WhereP

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

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

type LockQuery

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

LockQuery is the builder for querying Lock entities.

func (*LockQuery) Aggregate

func (lq *LockQuery) Aggregate(fns ...AggregateFunc) *LockSelect

Aggregate returns a LockSelect configured with the given aggregations.

func (*LockQuery) All

func (lq *LockQuery) All(ctx context.Context) ([]*Lock, error)

All executes the query and returns a list of Locks.

func (*LockQuery) AllX

func (lq *LockQuery) AllX(ctx context.Context) []*Lock

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

func (*LockQuery) Clone

func (lq *LockQuery) Clone() *LockQuery

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

func (*LockQuery) Count

func (lq *LockQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*LockQuery) CountX

func (lq *LockQuery) CountX(ctx context.Context) int

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

func (*LockQuery) ExecContext

func (c *LockQuery) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockQuery) Exist

func (lq *LockQuery) Exist(ctx context.Context) (bool, error)

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

func (*LockQuery) ExistX

func (lq *LockQuery) ExistX(ctx context.Context) bool

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

func (*LockQuery) First

func (lq *LockQuery) First(ctx context.Context) (*Lock, error)

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

func (*LockQuery) FirstID

func (lq *LockQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*LockQuery) FirstIDX

func (lq *LockQuery) FirstIDX(ctx context.Context) string

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

func (*LockQuery) FirstX

func (lq *LockQuery) FirstX(ctx context.Context) *Lock

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

func (*LockQuery) GroupBy

func (lq *LockQuery) GroupBy(field string, fields ...string) *LockGroupBy

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 {
	Version uuid.UUID `json:"version,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Lock.Query().
	GroupBy(lock.FieldVersion).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*LockQuery) IDs

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

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

func (*LockQuery) IDsX

func (lq *LockQuery) IDsX(ctx context.Context) []string

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

func (*LockQuery) Limit

func (lq *LockQuery) Limit(limit int) *LockQuery

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

func (*LockQuery) Modify

func (lq *LockQuery) Modify(modifiers ...func(s *sql.Selector)) *LockSelect

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

func (*LockQuery) Offset

func (lq *LockQuery) Offset(offset int) *LockQuery

Offset to start from.

func (*LockQuery) Only

func (lq *LockQuery) Only(ctx context.Context) (*Lock, error)

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

func (*LockQuery) OnlyID

func (lq *LockQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*LockQuery) OnlyIDX

func (lq *LockQuery) OnlyIDX(ctx context.Context) string

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

func (*LockQuery) OnlyX

func (lq *LockQuery) OnlyX(ctx context.Context) *Lock

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

func (*LockQuery) Order

func (lq *LockQuery) Order(o ...lock.OrderOption) *LockQuery

Order specifies how the records should be ordered.

func (*LockQuery) QueryContext

func (c *LockQuery) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockQuery) Select

func (lq *LockQuery) Select(fields ...string) *LockSelect

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 {
	Version uuid.UUID `json:"version,omitempty"`
}

client.Lock.Query().
	Select(lock.FieldVersion).
	Scan(ctx, &v)

func (*LockQuery) Unique

func (lq *LockQuery) Unique(unique bool) *LockQuery

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

func (lq *LockQuery) Where(ps ...predicate.Lock) *LockQuery

Where adds a new predicate for the LockQuery builder.

type LockSelect

type LockSelect struct {
	*LockQuery
	// contains filtered or unexported fields
}

LockSelect is the builder for selecting fields of Lock entities.

func (*LockSelect) Aggregate

func (ls *LockSelect) Aggregate(fns ...AggregateFunc) *LockSelect

Aggregate adds the given aggregation functions to the selector query.

func (*LockSelect) Bool

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

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

func (*LockSelect) BoolX

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

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

func (*LockSelect) Bools

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

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

func (*LockSelect) BoolsX

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

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

func (LockSelect) ExecContext

func (c LockSelect) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockSelect) Float64

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

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

func (*LockSelect) Float64X

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

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

func (*LockSelect) Float64s

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

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

func (*LockSelect) Float64sX

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

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

func (*LockSelect) Int

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

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

func (*LockSelect) IntX

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

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

func (*LockSelect) Ints

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

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

func (*LockSelect) IntsX

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

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

func (*LockSelect) Modify

func (ls *LockSelect) Modify(modifiers ...func(s *sql.Selector)) *LockSelect

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

func (LockSelect) QueryContext

func (c LockSelect) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockSelect) Scan

func (ls *LockSelect) Scan(ctx context.Context, v any) error

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

func (*LockSelect) ScanX

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

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

func (*LockSelect) String

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

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

func (*LockSelect) StringX

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

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

func (*LockSelect) Strings

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

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

func (*LockSelect) StringsX

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

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

type LockUpdate

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

LockUpdate is the builder for updating Lock entities.

func (*LockUpdate) ClearVersion added in v0.1.1

func (lu *LockUpdate) ClearVersion() *LockUpdate

ClearVersion clears the value of the "version" field.

func (*LockUpdate) Exec

func (lu *LockUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*LockUpdate) ExecContext

func (c *LockUpdate) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockUpdate) ExecX

func (lu *LockUpdate) ExecX(ctx context.Context)

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

func (*LockUpdate) Modify

func (lu *LockUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *LockUpdate

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

func (*LockUpdate) Mutation

func (lu *LockUpdate) Mutation() *LockMutation

Mutation returns the LockMutation object of the builder.

func (*LockUpdate) QueryContext

func (c *LockUpdate) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockUpdate) Save

func (lu *LockUpdate) Save(ctx context.Context) (int, error)

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

func (*LockUpdate) SaveX

func (lu *LockUpdate) SaveX(ctx context.Context) int

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

func (*LockUpdate) SetNillableOwner

func (lu *LockUpdate) SetNillableOwner(s *string) *LockUpdate

SetNillableOwner sets the "owner" field if the given value is not nil.

func (*LockUpdate) SetNillableVersion added in v0.1.1

func (lu *LockUpdate) SetNillableVersion(u *uuid.UUID) *LockUpdate

SetNillableVersion sets the "version" field if the given value is not nil.

func (*LockUpdate) SetOwner

func (lu *LockUpdate) SetOwner(s string) *LockUpdate

SetOwner sets the "owner" field.

func (*LockUpdate) SetVersion added in v0.1.1

func (lu *LockUpdate) SetVersion(u uuid.UUID) *LockUpdate

SetVersion sets the "version" field.

func (*LockUpdate) Where

func (lu *LockUpdate) Where(ps ...predicate.Lock) *LockUpdate

Where appends a list predicates to the LockUpdate builder.

type LockUpdateOne

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

LockUpdateOne is the builder for updating a single Lock entity.

func (*LockUpdateOne) ClearVersion added in v0.1.1

func (luo *LockUpdateOne) ClearVersion() *LockUpdateOne

ClearVersion clears the value of the "version" field.

func (*LockUpdateOne) Exec

func (luo *LockUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*LockUpdateOne) ExecContext

func (c *LockUpdateOne) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

func (*LockUpdateOne) ExecX

func (luo *LockUpdateOne) ExecX(ctx context.Context)

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

func (*LockUpdateOne) Modify

func (luo *LockUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *LockUpdateOne

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

func (*LockUpdateOne) Mutation

func (luo *LockUpdateOne) Mutation() *LockMutation

Mutation returns the LockMutation object of the builder.

func (*LockUpdateOne) QueryContext

func (c *LockUpdateOne) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

func (*LockUpdateOne) Save

func (luo *LockUpdateOne) Save(ctx context.Context) (*Lock, error)

Save executes the query and returns the updated Lock entity.

func (*LockUpdateOne) SaveX

func (luo *LockUpdateOne) SaveX(ctx context.Context) *Lock

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

func (*LockUpdateOne) Select

func (luo *LockUpdateOne) Select(field string, fields ...string) *LockUpdateOne

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

func (*LockUpdateOne) SetNillableOwner

func (luo *LockUpdateOne) SetNillableOwner(s *string) *LockUpdateOne

SetNillableOwner sets the "owner" field if the given value is not nil.

func (*LockUpdateOne) SetNillableVersion added in v0.1.1

func (luo *LockUpdateOne) SetNillableVersion(u *uuid.UUID) *LockUpdateOne

SetNillableVersion sets the "version" field if the given value is not nil.

func (*LockUpdateOne) SetOwner

func (luo *LockUpdateOne) SetOwner(s string) *LockUpdateOne

SetOwner sets the "owner" field.

func (*LockUpdateOne) SetVersion added in v0.1.1

func (luo *LockUpdateOne) SetVersion(u uuid.UUID) *LockUpdateOne

SetVersion sets the "version" field.

func (*LockUpdateOne) Where

func (luo *LockUpdateOne) Where(ps ...predicate.Lock) *LockUpdateOne

Where appends a list predicates to the LockUpdate builder.

type LockUpsert

type LockUpsert struct {
	*sql.UpdateSet
}

LockUpsert is the "OnConflict" setter.

func (*LockUpsert) ClearVersion added in v0.1.1

func (u *LockUpsert) ClearVersion() *LockUpsert

ClearVersion clears the value of the "version" field.

func (*LockUpsert) SetOwner

func (u *LockUpsert) SetOwner(v string) *LockUpsert

SetOwner sets the "owner" field.

func (*LockUpsert) SetVersion added in v0.1.1

func (u *LockUpsert) SetVersion(v uuid.UUID) *LockUpsert

SetVersion sets the "version" field.

func (*LockUpsert) UpdateOwner

func (u *LockUpsert) UpdateOwner() *LockUpsert

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

func (*LockUpsert) UpdateVersion added in v0.1.1

func (u *LockUpsert) UpdateVersion() *LockUpsert

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

type LockUpsertBulk

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

LockUpsertBulk is the builder for "upsert"-ing a bulk of Lock nodes.

func (*LockUpsertBulk) ClearVersion added in v0.1.1

func (u *LockUpsertBulk) ClearVersion() *LockUpsertBulk

ClearVersion clears the value of the "version" field.

func (*LockUpsertBulk) DoNothing

func (u *LockUpsertBulk) DoNothing() *LockUpsertBulk

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

func (*LockUpsertBulk) Exec

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

Exec executes the query.

func (*LockUpsertBulk) ExecX

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

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

func (*LockUpsertBulk) Ignore

func (u *LockUpsertBulk) Ignore() *LockUpsertBulk

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

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

func (*LockUpsertBulk) SetOwner

func (u *LockUpsertBulk) SetOwner(v string) *LockUpsertBulk

SetOwner sets the "owner" field.

func (*LockUpsertBulk) SetVersion added in v0.1.1

func (u *LockUpsertBulk) SetVersion(v uuid.UUID) *LockUpsertBulk

SetVersion sets the "version" field.

func (*LockUpsertBulk) Update

func (u *LockUpsertBulk) Update(set func(*LockUpsert)) *LockUpsertBulk

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

func (*LockUpsertBulk) UpdateNewValues

func (u *LockUpsertBulk) UpdateNewValues() *LockUpsertBulk

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

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

func (*LockUpsertBulk) UpdateOwner

func (u *LockUpsertBulk) UpdateOwner() *LockUpsertBulk

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

func (*LockUpsertBulk) UpdateVersion added in v0.1.1

func (u *LockUpsertBulk) UpdateVersion() *LockUpsertBulk

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

type LockUpsertOne

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

LockUpsertOne is the builder for "upsert"-ing

one Lock node.

func (*LockUpsertOne) ClearVersion added in v0.1.1

func (u *LockUpsertOne) ClearVersion() *LockUpsertOne

ClearVersion clears the value of the "version" field.

func (*LockUpsertOne) DoNothing

func (u *LockUpsertOne) DoNothing() *LockUpsertOne

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

func (*LockUpsertOne) Exec

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

Exec executes the query.

func (*LockUpsertOne) ExecX

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

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

func (*LockUpsertOne) ID

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

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

func (*LockUpsertOne) IDX

func (u *LockUpsertOne) IDX(ctx context.Context) string

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

func (*LockUpsertOne) Ignore

func (u *LockUpsertOne) Ignore() *LockUpsertOne

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

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

func (*LockUpsertOne) SetOwner

func (u *LockUpsertOne) SetOwner(v string) *LockUpsertOne

SetOwner sets the "owner" field.

func (*LockUpsertOne) SetVersion added in v0.1.1

func (u *LockUpsertOne) SetVersion(v uuid.UUID) *LockUpsertOne

SetVersion sets the "version" field.

func (*LockUpsertOne) Update

func (u *LockUpsertOne) Update(set func(*LockUpsert)) *LockUpsertOne

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

func (*LockUpsertOne) UpdateNewValues

func (u *LockUpsertOne) UpdateNewValues() *LockUpsertOne

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

func (*LockUpsertOne) UpdateOwner

func (u *LockUpsertOne) UpdateOwner() *LockUpsertOne

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

func (*LockUpsertOne) UpdateVersion added in v0.1.1

func (u *LockUpsertOne) UpdateVersion() *LockUpsertOne

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

type Locks

type Locks []*Lock

Locks is a parsable slice of Lock.

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 {

	// Lock is the client for interacting with the Lock builders.
	Lock *LockClient
	// 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) ExecContext

func (c *Tx) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error)

ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. See, database/sql#DB.ExecContext for more information.

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

func (c *Tx) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error)

QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. See, database/sql#DB.QueryContext for more information.

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