ent

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeDLock = "DLock"
)

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
	// DLock is the client for interacting with the DLock builders.
	DLock *DLockClient
	// 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().
	DLock.
	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 DLock

type DLock struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// Holder holds the value of the "holder" field.
	Holder uuid.UUID `json:"holder,omitempty"`
	// Deadline holds the value of the "deadline" field.
	Deadline int64 `json:"deadline,omitempty"`
	// contains filtered or unexported fields
}

DLock is the model entity for the DLock schema.

func (*DLock) String

func (d *DLock) String() string

String implements the fmt.Stringer.

func (*DLock) Unwrap

func (d *DLock) Unwrap() *DLock

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

func (d *DLock) Update() *DLockUpdateOne

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

func (*DLock) Value

func (d *DLock) Value(name string) (ent.Value, error)

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

type DLockClient

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

DLockClient is a client for the DLock schema.

func NewDLockClient

func NewDLockClient(c config) *DLockClient

NewDLockClient returns a client for the DLock from the given config.

func (*DLockClient) Create

func (c *DLockClient) Create() *DLockCreate

Create returns a builder for creating a DLock entity.

func (*DLockClient) CreateBulk

func (c *DLockClient) CreateBulk(builders ...*DLockCreate) *DLockCreateBulk

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

func (*DLockClient) Delete

func (c *DLockClient) Delete() *DLockDelete

Delete returns a delete builder for DLock.

func (*DLockClient) DeleteOne

func (c *DLockClient) DeleteOne(d *DLock) *DLockDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*DLockClient) DeleteOneID

func (c *DLockClient) DeleteOneID(id string) *DLockDeleteOne

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

func (*DLockClient) Get

func (c *DLockClient) Get(ctx context.Context, id string) (*DLock, error)

Get returns a DLock entity by its id.

func (*DLockClient) GetX

func (c *DLockClient) GetX(ctx context.Context, id string) *DLock

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

func (*DLockClient) Hooks

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

Hooks returns the client hooks.

func (*DLockClient) Intercept

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

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

func (*DLockClient) Interceptors

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

Interceptors returns the client interceptors.

func (*DLockClient) MapCreateBulk

func (c *DLockClient) MapCreateBulk(slice any, setFunc func(*DLockCreate, int)) *DLockCreateBulk

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 (*DLockClient) Query

func (c *DLockClient) Query() *DLockQuery

Query returns a query builder for DLock.

func (*DLockClient) Update

func (c *DLockClient) Update() *DLockUpdate

Update returns an update builder for DLock.

func (*DLockClient) UpdateOne

func (c *DLockClient) UpdateOne(d *DLock) *DLockUpdateOne

UpdateOne returns an update builder for the given entity.

func (*DLockClient) UpdateOneID

func (c *DLockClient) UpdateOneID(id string) *DLockUpdateOne

UpdateOneID returns an update builder for the given id.

func (*DLockClient) Use

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

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

type DLockCreate

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

DLockCreate is the builder for creating a DLock entity.

func (*DLockCreate) Exec

func (dc *DLockCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*DLockCreate) ExecX

func (dc *DLockCreate) ExecX(ctx context.Context)

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

func (*DLockCreate) Mutation

func (dc *DLockCreate) Mutation() *DLockMutation

Mutation returns the DLockMutation object of the builder.

func (*DLockCreate) Save

func (dc *DLockCreate) Save(ctx context.Context) (*DLock, error)

Save creates the DLock in the database.

func (*DLockCreate) SaveX

func (dc *DLockCreate) SaveX(ctx context.Context) *DLock

SaveX calls Save and panics if Save returns an error.

func (*DLockCreate) SetDeadline

func (dc *DLockCreate) SetDeadline(i int64) *DLockCreate

SetDeadline sets the "deadline" field.

func (*DLockCreate) SetHolder

func (dc *DLockCreate) SetHolder(u uuid.UUID) *DLockCreate

SetHolder sets the "holder" field.

func (*DLockCreate) SetID

func (dc *DLockCreate) SetID(s string) *DLockCreate

SetID sets the "id" field.

func (*DLockCreate) SetNillableHolder

func (dc *DLockCreate) SetNillableHolder(u *uuid.UUID) *DLockCreate

SetNillableHolder sets the "holder" field if the given value is not nil.

type DLockCreateBulk

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

DLockCreateBulk is the builder for creating many DLock entities in bulk.

func (*DLockCreateBulk) Exec

func (dcb *DLockCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*DLockCreateBulk) ExecX

func (dcb *DLockCreateBulk) ExecX(ctx context.Context)

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

func (*DLockCreateBulk) Save

func (dcb *DLockCreateBulk) Save(ctx context.Context) ([]*DLock, error)

Save creates the DLock entities in the database.

func (*DLockCreateBulk) SaveX

func (dcb *DLockCreateBulk) SaveX(ctx context.Context) []*DLock

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

type DLockDelete

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

DLockDelete is the builder for deleting a DLock entity.

func (*DLockDelete) Exec

func (dd *DLockDelete) Exec(ctx context.Context) (int, error)

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

func (*DLockDelete) ExecX

func (dd *DLockDelete) ExecX(ctx context.Context) int

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

func (*DLockDelete) Where

func (dd *DLockDelete) Where(ps ...predicate.DLock) *DLockDelete

Where appends a list predicates to the DLockDelete builder.

type DLockDeleteOne

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

DLockDeleteOne is the builder for deleting a single DLock entity.

func (*DLockDeleteOne) Exec

func (ddo *DLockDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*DLockDeleteOne) ExecX

func (ddo *DLockDeleteOne) ExecX(ctx context.Context)

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

func (*DLockDeleteOne) Where

func (ddo *DLockDeleteOne) Where(ps ...predicate.DLock) *DLockDeleteOne

Where appends a list predicates to the DLockDelete builder.

type DLockGroupBy

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

DLockGroupBy is the group-by builder for DLock entities.

func (*DLockGroupBy) Aggregate

func (dgb *DLockGroupBy) Aggregate(fns ...AggregateFunc) *DLockGroupBy

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

func (*DLockGroupBy) Bool

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

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

func (*DLockGroupBy) BoolX

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

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

func (*DLockGroupBy) Bools

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

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

func (*DLockGroupBy) BoolsX

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

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

func (*DLockGroupBy) Float64

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

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

func (*DLockGroupBy) Float64X

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

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

func (*DLockGroupBy) Float64s

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

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

func (*DLockGroupBy) Float64sX

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

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

func (*DLockGroupBy) Int

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

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

func (*DLockGroupBy) IntX

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

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

func (*DLockGroupBy) Ints

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

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

func (*DLockGroupBy) IntsX

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

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

func (*DLockGroupBy) Scan

func (dgb *DLockGroupBy) Scan(ctx context.Context, v any) error

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

func (*DLockGroupBy) ScanX

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

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

func (*DLockGroupBy) String

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

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

func (*DLockGroupBy) StringX

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

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

func (*DLockGroupBy) Strings

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

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

func (*DLockGroupBy) StringsX

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

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

type DLockMutation

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

DLockMutation represents an operation that mutates the DLock nodes in the graph.

func (*DLockMutation) AddDeadline

func (m *DLockMutation) AddDeadline(i int64)

AddDeadline adds i to the "deadline" field.

func (*DLockMutation) AddField

func (m *DLockMutation) 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 (*DLockMutation) AddedDeadline

func (m *DLockMutation) AddedDeadline() (r int64, exists bool)

AddedDeadline returns the value that was added to the "deadline" field in this mutation.

func (*DLockMutation) AddedEdges

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

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

func (*DLockMutation) AddedField

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

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

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

func (*DLockMutation) AddedIDs

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

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

func (*DLockMutation) ClearEdge

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

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

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

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

func (*DLockMutation) ClearedFields

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

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

func (DLockMutation) Client

func (m DLockMutation) 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 (*DLockMutation) Deadline

func (m *DLockMutation) Deadline() (r int64, exists bool)

Deadline returns the value of the "deadline" field in the mutation.

func (*DLockMutation) EdgeCleared

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

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

func (*DLockMutation) Field

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

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

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

func (*DLockMutation) Fields

func (m *DLockMutation) 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 (*DLockMutation) Holder

func (m *DLockMutation) Holder() (r uuid.UUID, exists bool)

Holder returns the value of the "holder" field in the mutation.

func (*DLockMutation) ID

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

func (m *DLockMutation) 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 (*DLockMutation) OldDeadline

func (m *DLockMutation) OldDeadline(ctx context.Context) (v int64, err error)

OldDeadline returns the old "deadline" field's value of the DLock entity. If the DLock 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 (*DLockMutation) OldField

func (m *DLockMutation) 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 (*DLockMutation) OldHolder

func (m *DLockMutation) OldHolder(ctx context.Context) (v uuid.UUID, err error)

OldHolder returns the old "holder" field's value of the DLock entity. If the DLock 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 (*DLockMutation) Op

func (m *DLockMutation) Op() Op

Op returns the operation name.

func (*DLockMutation) RemovedEdges

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

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

func (*DLockMutation) RemovedIDs

func (m *DLockMutation) 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 (*DLockMutation) ResetDeadline

func (m *DLockMutation) ResetDeadline()

ResetDeadline resets all changes to the "deadline" field.

func (*DLockMutation) ResetEdge

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

func (m *DLockMutation) 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 (*DLockMutation) ResetHolder

func (m *DLockMutation) ResetHolder()

ResetHolder resets all changes to the "holder" field.

func (*DLockMutation) SetDeadline

func (m *DLockMutation) SetDeadline(i int64)

SetDeadline sets the "deadline" field.

func (*DLockMutation) SetField

func (m *DLockMutation) 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 (*DLockMutation) SetHolder

func (m *DLockMutation) SetHolder(u uuid.UUID)

SetHolder sets the "holder" field.

func (*DLockMutation) SetID

func (m *DLockMutation) SetID(id string)

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

func (*DLockMutation) SetOp

func (m *DLockMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (DLockMutation) Tx

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

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

func (*DLockMutation) Type

func (m *DLockMutation) Type() string

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

func (*DLockMutation) Where

func (m *DLockMutation) Where(ps ...predicate.DLock)

Where appends a list predicates to the DLockMutation builder.

func (*DLockMutation) WhereP

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

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

type DLockQuery

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

DLockQuery is the builder for querying DLock entities.

func (*DLockQuery) Aggregate

func (dq *DLockQuery) Aggregate(fns ...AggregateFunc) *DLockSelect

Aggregate returns a DLockSelect configured with the given aggregations.

func (*DLockQuery) All

func (dq *DLockQuery) All(ctx context.Context) ([]*DLock, error)

All executes the query and returns a list of DLocks.

func (*DLockQuery) AllX

func (dq *DLockQuery) AllX(ctx context.Context) []*DLock

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

func (*DLockQuery) Clone

func (dq *DLockQuery) Clone() *DLockQuery

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

func (*DLockQuery) Count

func (dq *DLockQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*DLockQuery) CountX

func (dq *DLockQuery) CountX(ctx context.Context) int

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

func (*DLockQuery) Exist

func (dq *DLockQuery) Exist(ctx context.Context) (bool, error)

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

func (*DLockQuery) ExistX

func (dq *DLockQuery) ExistX(ctx context.Context) bool

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

func (*DLockQuery) First

func (dq *DLockQuery) First(ctx context.Context) (*DLock, error)

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

func (*DLockQuery) FirstID

func (dq *DLockQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*DLockQuery) FirstIDX

func (dq *DLockQuery) FirstIDX(ctx context.Context) string

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

func (*DLockQuery) FirstX

func (dq *DLockQuery) FirstX(ctx context.Context) *DLock

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

func (*DLockQuery) GroupBy

func (dq *DLockQuery) GroupBy(field string, fields ...string) *DLockGroupBy

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

client.DLock.Query().
	GroupBy(dlock.FieldHolder).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*DLockQuery) IDs

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

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

func (*DLockQuery) IDsX

func (dq *DLockQuery) IDsX(ctx context.Context) []string

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

func (*DLockQuery) Limit

func (dq *DLockQuery) Limit(limit int) *DLockQuery

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

func (*DLockQuery) Offset

func (dq *DLockQuery) Offset(offset int) *DLockQuery

Offset to start from.

func (*DLockQuery) Only

func (dq *DLockQuery) Only(ctx context.Context) (*DLock, error)

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

func (*DLockQuery) OnlyID

func (dq *DLockQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*DLockQuery) OnlyIDX

func (dq *DLockQuery) OnlyIDX(ctx context.Context) string

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

func (*DLockQuery) OnlyX

func (dq *DLockQuery) OnlyX(ctx context.Context) *DLock

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

func (*DLockQuery) Order

func (dq *DLockQuery) Order(o ...dlock.OrderOption) *DLockQuery

Order specifies how the records should be ordered.

func (*DLockQuery) Select

func (dq *DLockQuery) Select(fields ...string) *DLockSelect

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

client.DLock.Query().
	Select(dlock.FieldHolder).
	Scan(ctx, &v)

func (*DLockQuery) Unique

func (dq *DLockQuery) Unique(unique bool) *DLockQuery

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

func (dq *DLockQuery) Where(ps ...predicate.DLock) *DLockQuery

Where adds a new predicate for the DLockQuery builder.

type DLockSelect

type DLockSelect struct {
	*DLockQuery
	// contains filtered or unexported fields
}

DLockSelect is the builder for selecting fields of DLock entities.

func (*DLockSelect) Aggregate

func (ds *DLockSelect) Aggregate(fns ...AggregateFunc) *DLockSelect

Aggregate adds the given aggregation functions to the selector query.

func (*DLockSelect) Bool

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

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

func (*DLockSelect) BoolX

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

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

func (*DLockSelect) Bools

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

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

func (*DLockSelect) BoolsX

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

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

func (*DLockSelect) Float64

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

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

func (*DLockSelect) Float64X

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

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

func (*DLockSelect) Float64s

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

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

func (*DLockSelect) Float64sX

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

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

func (*DLockSelect) Int

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

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

func (*DLockSelect) IntX

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

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

func (*DLockSelect) Ints

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

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

func (*DLockSelect) IntsX

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

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

func (*DLockSelect) Scan

func (ds *DLockSelect) Scan(ctx context.Context, v any) error

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

func (*DLockSelect) ScanX

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

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

func (*DLockSelect) String

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

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

func (*DLockSelect) StringX

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

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

func (*DLockSelect) Strings

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

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

func (*DLockSelect) StringsX

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

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

type DLockUpdate

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

DLockUpdate is the builder for updating DLock entities.

func (*DLockUpdate) AddDeadline

func (du *DLockUpdate) AddDeadline(i int64) *DLockUpdate

AddDeadline adds i to the "deadline" field.

func (*DLockUpdate) Exec

func (du *DLockUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*DLockUpdate) ExecX

func (du *DLockUpdate) ExecX(ctx context.Context)

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

func (*DLockUpdate) Mutation

func (du *DLockUpdate) Mutation() *DLockMutation

Mutation returns the DLockMutation object of the builder.

func (*DLockUpdate) Save

func (du *DLockUpdate) Save(ctx context.Context) (int, error)

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

func (*DLockUpdate) SaveX

func (du *DLockUpdate) SaveX(ctx context.Context) int

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

func (*DLockUpdate) SetDeadline

func (du *DLockUpdate) SetDeadline(i int64) *DLockUpdate

SetDeadline sets the "deadline" field.

func (*DLockUpdate) SetNillableDeadline

func (du *DLockUpdate) SetNillableDeadline(i *int64) *DLockUpdate

SetNillableDeadline sets the "deadline" field if the given value is not nil.

func (*DLockUpdate) Where

func (du *DLockUpdate) Where(ps ...predicate.DLock) *DLockUpdate

Where appends a list predicates to the DLockUpdate builder.

type DLockUpdateOne

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

DLockUpdateOne is the builder for updating a single DLock entity.

func (*DLockUpdateOne) AddDeadline

func (duo *DLockUpdateOne) AddDeadline(i int64) *DLockUpdateOne

AddDeadline adds i to the "deadline" field.

func (*DLockUpdateOne) Exec

func (duo *DLockUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*DLockUpdateOne) ExecX

func (duo *DLockUpdateOne) ExecX(ctx context.Context)

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

func (*DLockUpdateOne) Mutation

func (duo *DLockUpdateOne) Mutation() *DLockMutation

Mutation returns the DLockMutation object of the builder.

func (*DLockUpdateOne) Save

func (duo *DLockUpdateOne) Save(ctx context.Context) (*DLock, error)

Save executes the query and returns the updated DLock entity.

func (*DLockUpdateOne) SaveX

func (duo *DLockUpdateOne) SaveX(ctx context.Context) *DLock

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

func (*DLockUpdateOne) Select

func (duo *DLockUpdateOne) Select(field string, fields ...string) *DLockUpdateOne

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

func (*DLockUpdateOne) SetDeadline

func (duo *DLockUpdateOne) SetDeadline(i int64) *DLockUpdateOne

SetDeadline sets the "deadline" field.

func (*DLockUpdateOne) SetNillableDeadline

func (duo *DLockUpdateOne) SetNillableDeadline(i *int64) *DLockUpdateOne

SetNillableDeadline sets the "deadline" field if the given value is not nil.

func (*DLockUpdateOne) Where

func (duo *DLockUpdateOne) Where(ps ...predicate.DLock) *DLockUpdateOne

Where appends a list predicates to the DLockUpdate builder.

type DLocks

type DLocks []*DLock

DLocks is a parsable slice of DLock.

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

NotFoundError returns when trying to fetch a specific entity and it was not found in the database.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

NotLoadedError returns when trying to get a node that was not loaded by the query.

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

func Log(fn func(...any)) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

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

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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

type Query

type Query = ent.Query

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

type QueryContext

type QueryContext = ent.QueryContext

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

type RollbackFunc

type RollbackFunc func(context.Context, *Tx) error

The RollbackFunc type is an adapter to allow the use of ordinary function as a Rollbacker. If f is a function with the appropriate signature, RollbackFunc(f) is a Rollbacker that calls f.

func (RollbackFunc) Rollback

func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

RollbackHook defines the "rollback middleware". A function that gets a Rollbacker and returns a Rollbacker. For example:

hook := func(next ent.Rollbacker) ent.Rollbacker {
	return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Rollback(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Rollbacker

type Rollbacker interface {
	Rollback(context.Context, *Tx) error
}

Rollbacker is the interface that wraps the Rollback method.

type TraverseFunc

type TraverseFunc = ent.TraverseFunc

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

type Traverser

type Traverser = ent.Traverser

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

type Tx

type Tx struct {

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