ent

package
v0.0.0-...-af973d3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 21 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.
	TypeLink = "Link"
)

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
	// Link is the client for interacting with the Link builders.
	Link *LinkClient
	// 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().
	Link.
	Query().
	Count(ctx)

func (*Client) Intercept

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

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

func (*Client) Mutate

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

Mutate implements the ent.Mutator interface.

func (*Client) Tx

func (c *Client) Tx(ctx context.Context) (*Tx, error)

Tx returns a new transactional client. The provided context is used until the transaction is committed or rolled back.

func (*Client) Use

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

Use adds the mutation hooks to all the entity clients. In order to add hooks to a specific client, call: `client.Node.Use(...)`.

type CommitFunc

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

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

func (CommitFunc) Commit

func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

CommitHook defines the "commit middleware". A function that gets a Committer and returns a Committer. For example:

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

type Committer

type Committer interface {
	Commit(context.Context, *Tx) error
}

Committer is the interface that wraps the Commit method.

type ConstraintError

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

ConstraintError returns when trying to create/update one or more entities and one or more of their constraints failed. For example, violation of edge or field uniqueness.

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type Link struct {

	// ID of the ent.
	// UUID
	ID uuid.UUID `json:"id,omitempty"`
	// URL
	URL string `json:"url,omitempty"`
	// Hash
	Hash string `json:"hash,omitempty"`
	// Describe
	Describe string `json:"describe,omitempty"`
	// JSON
	JSON v1.Link `json:"json,omitempty"`
	// Created at
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Updated at
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

Link holds the schema definition for the Link entity.

func (*Link) String

func (l *Link) String() string

String implements the fmt.Stringer.

func (*Link) Unwrap

func (l *Link) Unwrap() *Link

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

func (l *Link) Update() *LinkUpdateOne

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

func (*Link) Value

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

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

type LinkClient

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

LinkClient is a client for the Link schema.

func NewLinkClient

func NewLinkClient(c config) *LinkClient

NewLinkClient returns a client for the Link from the given config.

func (*LinkClient) Create

func (c *LinkClient) Create() *LinkCreate

Create returns a builder for creating a Link entity.

func (*LinkClient) CreateBulk

func (c *LinkClient) CreateBulk(builders ...*LinkCreate) *LinkCreateBulk

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

func (*LinkClient) Delete

func (c *LinkClient) Delete() *LinkDelete

Delete returns a delete builder for Link.

func (*LinkClient) DeleteOne

func (c *LinkClient) DeleteOne(l *Link) *LinkDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*LinkClient) DeleteOneID

func (c *LinkClient) DeleteOneID(id uuid.UUID) *LinkDeleteOne

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

func (*LinkClient) Get

func (c *LinkClient) Get(ctx context.Context, id uuid.UUID) (*Link, error)

Get returns a Link entity by its id.

func (*LinkClient) GetX

func (c *LinkClient) GetX(ctx context.Context, id uuid.UUID) *Link

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

func (*LinkClient) Hooks

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

Hooks returns the client hooks.

func (*LinkClient) Intercept

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

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

func (*LinkClient) Interceptors

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

Interceptors returns the client interceptors.

func (*LinkClient) MapCreateBulk

func (c *LinkClient) MapCreateBulk(slice any, setFunc func(*LinkCreate, int)) *LinkCreateBulk

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

func (c *LinkClient) Query() *LinkQuery

Query returns a query builder for Link.

func (*LinkClient) Update

func (c *LinkClient) Update() *LinkUpdate

Update returns an update builder for Link.

func (*LinkClient) UpdateOne

func (c *LinkClient) UpdateOne(l *Link) *LinkUpdateOne

UpdateOne returns an update builder for the given entity.

func (*LinkClient) UpdateOneID

func (c *LinkClient) UpdateOneID(id uuid.UUID) *LinkUpdateOne

UpdateOneID returns an update builder for the given id.

func (*LinkClient) Use

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

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

type LinkCreate

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

LinkCreate is the builder for creating a Link entity.

func (*LinkCreate) Exec

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

Exec executes the query.

func (*LinkCreate) ExecX

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

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

func (*LinkCreate) Mutation

func (lc *LinkCreate) Mutation() *LinkMutation

Mutation returns the LinkMutation object of the builder.

func (*LinkCreate) OnConflict

func (lc *LinkCreate) OnConflict(opts ...sql.ConflictOption) *LinkUpsertOne

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

client.Link.Create().
	SetURL(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.LinkUpsert) {
		SetURL(v+v).
	}).
	Exec(ctx)

func (*LinkCreate) OnConflictColumns

func (lc *LinkCreate) OnConflictColumns(columns ...string) *LinkUpsertOne

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

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

func (*LinkCreate) Save

func (lc *LinkCreate) Save(ctx context.Context) (*Link, error)

Save creates the Link in the database.

func (*LinkCreate) SaveX

func (lc *LinkCreate) SaveX(ctx context.Context) *Link

SaveX calls Save and panics if Save returns an error.

func (*LinkCreate) SetCreatedAt

func (lc *LinkCreate) SetCreatedAt(t time.Time) *LinkCreate

SetCreatedAt sets the "created_at" field.

func (*LinkCreate) SetDescribe

func (lc *LinkCreate) SetDescribe(s string) *LinkCreate

SetDescribe sets the "describe" field.

func (*LinkCreate) SetHash

func (lc *LinkCreate) SetHash(s string) *LinkCreate

SetHash sets the "hash" field.

func (*LinkCreate) SetID

func (lc *LinkCreate) SetID(u uuid.UUID) *LinkCreate

SetID sets the "id" field.

func (*LinkCreate) SetJSON

func (lc *LinkCreate) SetJSON(v v1.Link) *LinkCreate

SetJSON sets the "json" field.

func (*LinkCreate) SetNillableDescribe

func (lc *LinkCreate) SetNillableDescribe(s *string) *LinkCreate

SetNillableDescribe sets the "describe" field if the given value is not nil.

func (*LinkCreate) SetNillableID

func (lc *LinkCreate) SetNillableID(u *uuid.UUID) *LinkCreate

SetNillableID sets the "id" field if the given value is not nil.

func (*LinkCreate) SetURL

func (lc *LinkCreate) SetURL(s string) *LinkCreate

SetURL sets the "url" field.

func (*LinkCreate) SetUpdatedAt

func (lc *LinkCreate) SetUpdatedAt(t time.Time) *LinkCreate

SetUpdatedAt sets the "updated_at" field.

type LinkCreateBulk

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

LinkCreateBulk is the builder for creating many Link entities in bulk.

func (*LinkCreateBulk) Exec

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

Exec executes the query.

func (*LinkCreateBulk) ExecX

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

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

func (*LinkCreateBulk) OnConflict

func (lcb *LinkCreateBulk) OnConflict(opts ...sql.ConflictOption) *LinkUpsertBulk

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

client.Link.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.LinkUpsert) {
		SetURL(v+v).
	}).
	Exec(ctx)

func (*LinkCreateBulk) OnConflictColumns

func (lcb *LinkCreateBulk) OnConflictColumns(columns ...string) *LinkUpsertBulk

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

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

func (*LinkCreateBulk) Save

func (lcb *LinkCreateBulk) Save(ctx context.Context) ([]*Link, error)

Save creates the Link entities in the database.

func (*LinkCreateBulk) SaveX

func (lcb *LinkCreateBulk) SaveX(ctx context.Context) []*Link

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

type LinkDelete

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

LinkDelete is the builder for deleting a Link entity.

func (*LinkDelete) Exec

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

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

func (*LinkDelete) ExecX

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

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

func (*LinkDelete) Where

func (ld *LinkDelete) Where(ps ...predicate.Link) *LinkDelete

Where appends a list predicates to the LinkDelete builder.

type LinkDeleteOne

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

LinkDeleteOne is the builder for deleting a single Link entity.

func (*LinkDeleteOne) Exec

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

Exec executes the deletion query.

func (*LinkDeleteOne) ExecX

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

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

func (*LinkDeleteOne) Where

func (ldo *LinkDeleteOne) Where(ps ...predicate.Link) *LinkDeleteOne

Where appends a list predicates to the LinkDelete builder.

type LinkGroupBy

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

LinkGroupBy is the group-by builder for Link entities.

func (*LinkGroupBy) Aggregate

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

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

func (*LinkGroupBy) Bool

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

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

func (*LinkGroupBy) BoolX

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

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

func (*LinkGroupBy) Bools

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

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

func (*LinkGroupBy) BoolsX

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

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

func (*LinkGroupBy) Float64

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

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

func (*LinkGroupBy) Float64X

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

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

func (*LinkGroupBy) Float64s

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

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

func (*LinkGroupBy) Float64sX

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

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

func (*LinkGroupBy) Int

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

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

func (*LinkGroupBy) IntX

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

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

func (*LinkGroupBy) Ints

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

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

func (*LinkGroupBy) IntsX

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

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

func (*LinkGroupBy) Scan

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

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

func (*LinkGroupBy) ScanX

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

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

func (*LinkGroupBy) String

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

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

func (*LinkGroupBy) StringX

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

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

func (*LinkGroupBy) Strings

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

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

func (*LinkGroupBy) StringsX

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

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

type LinkMutation

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

LinkMutation represents an operation that mutates the Link nodes in the graph.

func (*LinkMutation) AddField

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

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

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

func (*LinkMutation) AddedField

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

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

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

func (*LinkMutation) AddedIDs

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

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

func (*LinkMutation) ClearDescribe

func (m *LinkMutation) ClearDescribe()

ClearDescribe clears the value of the "describe" field.

func (*LinkMutation) ClearEdge

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

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

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

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

func (*LinkMutation) ClearedFields

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

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

func (LinkMutation) Client

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

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

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

func (*LinkMutation) Describe

func (m *LinkMutation) Describe() (r string, exists bool)

Describe returns the value of the "describe" field in the mutation.

func (*LinkMutation) DescribeCleared

func (m *LinkMutation) DescribeCleared() bool

DescribeCleared returns if the "describe" field was cleared in this mutation.

func (*LinkMutation) EdgeCleared

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

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

func (*LinkMutation) Field

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

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

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

func (*LinkMutation) Fields

func (m *LinkMutation) 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 (*LinkMutation) Hash

func (m *LinkMutation) Hash() (r string, exists bool)

Hash returns the value of the "hash" field in the mutation.

func (*LinkMutation) ID

func (m *LinkMutation) ID() (id uuid.UUID, 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 (*LinkMutation) IDs

func (m *LinkMutation) IDs(ctx context.Context) ([]uuid.UUID, 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 (*LinkMutation) JSON

func (m *LinkMutation) JSON() (r v1.Link, exists bool)

JSON returns the value of the "json" field in the mutation.

func (*LinkMutation) OldCreatedAt

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

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

func (m *LinkMutation) OldDescribe(ctx context.Context) (v string, err error)

OldDescribe returns the old "describe" field's value of the Link entity. If the Link 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 (*LinkMutation) OldField

func (m *LinkMutation) 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 (*LinkMutation) OldHash

func (m *LinkMutation) OldHash(ctx context.Context) (v string, err error)

OldHash returns the old "hash" field's value of the Link entity. If the Link 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 (*LinkMutation) OldJSON

func (m *LinkMutation) OldJSON(ctx context.Context) (v v1.Link, err error)

OldJSON returns the old "json" field's value of the Link entity. If the Link 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 (*LinkMutation) OldURL

func (m *LinkMutation) OldURL(ctx context.Context) (v string, err error)

OldURL returns the old "url" field's value of the Link entity. If the Link 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 (*LinkMutation) OldUpdatedAt

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

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

func (m *LinkMutation) Op() Op

Op returns the operation name.

func (*LinkMutation) RemovedEdges

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

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

func (*LinkMutation) RemovedIDs

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

func (m *LinkMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*LinkMutation) ResetDescribe

func (m *LinkMutation) ResetDescribe()

ResetDescribe resets all changes to the "describe" field.

func (*LinkMutation) ResetEdge

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

func (m *LinkMutation) 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 (*LinkMutation) ResetHash

func (m *LinkMutation) ResetHash()

ResetHash resets all changes to the "hash" field.

func (*LinkMutation) ResetJSON

func (m *LinkMutation) ResetJSON()

ResetJSON resets all changes to the "json" field.

func (*LinkMutation) ResetURL

func (m *LinkMutation) ResetURL()

ResetURL resets all changes to the "url" field.

func (*LinkMutation) ResetUpdatedAt

func (m *LinkMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*LinkMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*LinkMutation) SetDescribe

func (m *LinkMutation) SetDescribe(s string)

SetDescribe sets the "describe" field.

func (*LinkMutation) SetField

func (m *LinkMutation) 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 (*LinkMutation) SetHash

func (m *LinkMutation) SetHash(s string)

SetHash sets the "hash" field.

func (*LinkMutation) SetID

func (m *LinkMutation) SetID(id uuid.UUID)

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

func (*LinkMutation) SetJSON

func (m *LinkMutation) SetJSON(v v1.Link)

SetJSON sets the "json" field.

func (*LinkMutation) SetOp

func (m *LinkMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*LinkMutation) SetURL

func (m *LinkMutation) SetURL(s string)

SetURL sets the "url" field.

func (*LinkMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (LinkMutation) Tx

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

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

func (*LinkMutation) Type

func (m *LinkMutation) Type() string

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

func (*LinkMutation) URL

func (m *LinkMutation) URL() (r string, exists bool)

URL returns the value of the "url" field in the mutation.

func (*LinkMutation) UpdatedAt

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

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

func (*LinkMutation) Where

func (m *LinkMutation) Where(ps ...predicate.Link)

Where appends a list predicates to the LinkMutation builder.

func (*LinkMutation) WhereP

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

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

type LinkQuery

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

LinkQuery is the builder for querying Link entities.

func (*LinkQuery) Aggregate

func (lq *LinkQuery) Aggregate(fns ...AggregateFunc) *LinkSelect

Aggregate returns a LinkSelect configured with the given aggregations.

func (*LinkQuery) All

func (lq *LinkQuery) All(ctx context.Context) ([]*Link, error)

All executes the query and returns a list of Links.

func (*LinkQuery) AllX

func (lq *LinkQuery) AllX(ctx context.Context) []*Link

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

func (*LinkQuery) Clone

func (lq *LinkQuery) Clone() *LinkQuery

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

func (*LinkQuery) Count

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

Count returns the count of the given query.

func (*LinkQuery) CountX

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

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

func (*LinkQuery) Exist

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

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

func (*LinkQuery) ExistX

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

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

func (*LinkQuery) First

func (lq *LinkQuery) First(ctx context.Context) (*Link, error)

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

func (*LinkQuery) FirstID

func (lq *LinkQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*LinkQuery) FirstIDX

func (lq *LinkQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*LinkQuery) FirstX

func (lq *LinkQuery) FirstX(ctx context.Context) *Link

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

func (*LinkQuery) GroupBy

func (lq *LinkQuery) GroupBy(field string, fields ...string) *LinkGroupBy

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

client.Link.Query().
	GroupBy(link.FieldURL).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*LinkQuery) IDs

func (lq *LinkQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error)

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

func (*LinkQuery) IDsX

func (lq *LinkQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*LinkQuery) Limit

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

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

func (*LinkQuery) Offset

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

Offset to start from.

func (*LinkQuery) Only

func (lq *LinkQuery) Only(ctx context.Context) (*Link, error)

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

func (*LinkQuery) OnlyID

func (lq *LinkQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*LinkQuery) OnlyIDX

func (lq *LinkQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*LinkQuery) OnlyX

func (lq *LinkQuery) OnlyX(ctx context.Context) *Link

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

func (*LinkQuery) Order

func (lq *LinkQuery) Order(o ...link.OrderOption) *LinkQuery

Order specifies how the records should be ordered.

func (*LinkQuery) Select

func (lq *LinkQuery) Select(fields ...string) *LinkSelect

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

client.Link.Query().
	Select(link.FieldURL).
	Scan(ctx, &v)

func (*LinkQuery) Unique

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

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

func (lq *LinkQuery) Where(ps ...predicate.Link) *LinkQuery

Where adds a new predicate for the LinkQuery builder.

type LinkSelect

type LinkSelect struct {
	*LinkQuery
	// contains filtered or unexported fields
}

LinkSelect is the builder for selecting fields of Link entities.

func (*LinkSelect) Aggregate

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

Aggregate adds the given aggregation functions to the selector query.

func (*LinkSelect) Bool

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

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

func (*LinkSelect) BoolX

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

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

func (*LinkSelect) Bools

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

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

func (*LinkSelect) BoolsX

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

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

func (*LinkSelect) Float64

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

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

func (*LinkSelect) Float64X

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

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

func (*LinkSelect) Float64s

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

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

func (*LinkSelect) Float64sX

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

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

func (*LinkSelect) Int

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

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

func (*LinkSelect) IntX

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

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

func (*LinkSelect) Ints

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

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

func (*LinkSelect) IntsX

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

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

func (*LinkSelect) Scan

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

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

func (*LinkSelect) ScanX

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

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

func (*LinkSelect) String

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

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

func (*LinkSelect) StringX

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

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

func (*LinkSelect) Strings

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

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

func (*LinkSelect) StringsX

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

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

type LinkUpdate

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

LinkUpdate is the builder for updating Link entities.

func (*LinkUpdate) ClearDescribe

func (lu *LinkUpdate) ClearDescribe() *LinkUpdate

ClearDescribe clears the value of the "describe" field.

func (*LinkUpdate) Exec

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

Exec executes the query.

func (*LinkUpdate) ExecX

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

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

func (*LinkUpdate) Mutation

func (lu *LinkUpdate) Mutation() *LinkMutation

Mutation returns the LinkMutation object of the builder.

func (*LinkUpdate) Save

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

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

func (*LinkUpdate) SaveX

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

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

func (*LinkUpdate) SetCreatedAt

func (lu *LinkUpdate) SetCreatedAt(t time.Time) *LinkUpdate

SetCreatedAt sets the "created_at" field.

func (*LinkUpdate) SetDescribe

func (lu *LinkUpdate) SetDescribe(s string) *LinkUpdate

SetDescribe sets the "describe" field.

func (*LinkUpdate) SetHash

func (lu *LinkUpdate) SetHash(s string) *LinkUpdate

SetHash sets the "hash" field.

func (*LinkUpdate) SetJSON

func (lu *LinkUpdate) SetJSON(v v1.Link) *LinkUpdate

SetJSON sets the "json" field.

func (*LinkUpdate) SetNillableDescribe

func (lu *LinkUpdate) SetNillableDescribe(s *string) *LinkUpdate

SetNillableDescribe sets the "describe" field if the given value is not nil.

func (*LinkUpdate) SetURL

func (lu *LinkUpdate) SetURL(s string) *LinkUpdate

SetURL sets the "url" field.

func (*LinkUpdate) SetUpdatedAt

func (lu *LinkUpdate) SetUpdatedAt(t time.Time) *LinkUpdate

SetUpdatedAt sets the "updated_at" field.

func (*LinkUpdate) Where

func (lu *LinkUpdate) Where(ps ...predicate.Link) *LinkUpdate

Where appends a list predicates to the LinkUpdate builder.

type LinkUpdateOne

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

LinkUpdateOne is the builder for updating a single Link entity.

func (*LinkUpdateOne) ClearDescribe

func (luo *LinkUpdateOne) ClearDescribe() *LinkUpdateOne

ClearDescribe clears the value of the "describe" field.

func (*LinkUpdateOne) Exec

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

Exec executes the query on the entity.

func (*LinkUpdateOne) ExecX

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

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

func (*LinkUpdateOne) Mutation

func (luo *LinkUpdateOne) Mutation() *LinkMutation

Mutation returns the LinkMutation object of the builder.

func (*LinkUpdateOne) Save

func (luo *LinkUpdateOne) Save(ctx context.Context) (*Link, error)

Save executes the query and returns the updated Link entity.

func (*LinkUpdateOne) SaveX

func (luo *LinkUpdateOne) SaveX(ctx context.Context) *Link

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

func (*LinkUpdateOne) Select

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

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

func (*LinkUpdateOne) SetCreatedAt

func (luo *LinkUpdateOne) SetCreatedAt(t time.Time) *LinkUpdateOne

SetCreatedAt sets the "created_at" field.

func (*LinkUpdateOne) SetDescribe

func (luo *LinkUpdateOne) SetDescribe(s string) *LinkUpdateOne

SetDescribe sets the "describe" field.

func (*LinkUpdateOne) SetHash

func (luo *LinkUpdateOne) SetHash(s string) *LinkUpdateOne

SetHash sets the "hash" field.

func (*LinkUpdateOne) SetJSON

func (luo *LinkUpdateOne) SetJSON(v v1.Link) *LinkUpdateOne

SetJSON sets the "json" field.

func (*LinkUpdateOne) SetNillableDescribe

func (luo *LinkUpdateOne) SetNillableDescribe(s *string) *LinkUpdateOne

SetNillableDescribe sets the "describe" field if the given value is not nil.

func (*LinkUpdateOne) SetURL

func (luo *LinkUpdateOne) SetURL(s string) *LinkUpdateOne

SetURL sets the "url" field.

func (*LinkUpdateOne) SetUpdatedAt

func (luo *LinkUpdateOne) SetUpdatedAt(t time.Time) *LinkUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*LinkUpdateOne) Where

func (luo *LinkUpdateOne) Where(ps ...predicate.Link) *LinkUpdateOne

Where appends a list predicates to the LinkUpdate builder.

type LinkUpsert

type LinkUpsert struct {
	*sql.UpdateSet
}

LinkUpsert is the "OnConflict" setter.

func (*LinkUpsert) ClearDescribe

func (u *LinkUpsert) ClearDescribe() *LinkUpsert

ClearDescribe clears the value of the "describe" field.

func (*LinkUpsert) SetCreatedAt

func (u *LinkUpsert) SetCreatedAt(v time.Time) *LinkUpsert

SetCreatedAt sets the "created_at" field.

func (*LinkUpsert) SetDescribe

func (u *LinkUpsert) SetDescribe(v string) *LinkUpsert

SetDescribe sets the "describe" field.

func (*LinkUpsert) SetHash

func (u *LinkUpsert) SetHash(v string) *LinkUpsert

SetHash sets the "hash" field.

func (*LinkUpsert) SetJSON

func (u *LinkUpsert) SetJSON(v v1.Link) *LinkUpsert

SetJSON sets the "json" field.

func (*LinkUpsert) SetURL

func (u *LinkUpsert) SetURL(v string) *LinkUpsert

SetURL sets the "url" field.

func (*LinkUpsert) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*LinkUpsert) UpdateCreatedAt

func (u *LinkUpsert) UpdateCreatedAt() *LinkUpsert

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

func (*LinkUpsert) UpdateDescribe

func (u *LinkUpsert) UpdateDescribe() *LinkUpsert

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

func (*LinkUpsert) UpdateHash

func (u *LinkUpsert) UpdateHash() *LinkUpsert

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

func (*LinkUpsert) UpdateJSON

func (u *LinkUpsert) UpdateJSON() *LinkUpsert

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

func (*LinkUpsert) UpdateURL

func (u *LinkUpsert) UpdateURL() *LinkUpsert

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

func (*LinkUpsert) UpdateUpdatedAt

func (u *LinkUpsert) UpdateUpdatedAt() *LinkUpsert

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

type LinkUpsertBulk

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

LinkUpsertBulk is the builder for "upsert"-ing a bulk of Link nodes.

func (*LinkUpsertBulk) ClearDescribe

func (u *LinkUpsertBulk) ClearDescribe() *LinkUpsertBulk

ClearDescribe clears the value of the "describe" field.

func (*LinkUpsertBulk) DoNothing

func (u *LinkUpsertBulk) DoNothing() *LinkUpsertBulk

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

func (*LinkUpsertBulk) Exec

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

Exec executes the query.

func (*LinkUpsertBulk) ExecX

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

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

func (*LinkUpsertBulk) Ignore

func (u *LinkUpsertBulk) Ignore() *LinkUpsertBulk

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

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

func (*LinkUpsertBulk) SetCreatedAt

func (u *LinkUpsertBulk) SetCreatedAt(v time.Time) *LinkUpsertBulk

SetCreatedAt sets the "created_at" field.

func (*LinkUpsertBulk) SetDescribe

func (u *LinkUpsertBulk) SetDescribe(v string) *LinkUpsertBulk

SetDescribe sets the "describe" field.

func (*LinkUpsertBulk) SetHash

func (u *LinkUpsertBulk) SetHash(v string) *LinkUpsertBulk

SetHash sets the "hash" field.

func (*LinkUpsertBulk) SetJSON

func (u *LinkUpsertBulk) SetJSON(v v1.Link) *LinkUpsertBulk

SetJSON sets the "json" field.

func (*LinkUpsertBulk) SetURL

func (u *LinkUpsertBulk) SetURL(v string) *LinkUpsertBulk

SetURL sets the "url" field.

func (*LinkUpsertBulk) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*LinkUpsertBulk) Update

func (u *LinkUpsertBulk) Update(set func(*LinkUpsert)) *LinkUpsertBulk

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

func (*LinkUpsertBulk) UpdateCreatedAt

func (u *LinkUpsertBulk) UpdateCreatedAt() *LinkUpsertBulk

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

func (*LinkUpsertBulk) UpdateDescribe

func (u *LinkUpsertBulk) UpdateDescribe() *LinkUpsertBulk

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

func (*LinkUpsertBulk) UpdateHash

func (u *LinkUpsertBulk) UpdateHash() *LinkUpsertBulk

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

func (*LinkUpsertBulk) UpdateJSON

func (u *LinkUpsertBulk) UpdateJSON() *LinkUpsertBulk

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

func (*LinkUpsertBulk) UpdateNewValues

func (u *LinkUpsertBulk) UpdateNewValues() *LinkUpsertBulk

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

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

func (*LinkUpsertBulk) UpdateURL

func (u *LinkUpsertBulk) UpdateURL() *LinkUpsertBulk

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

func (*LinkUpsertBulk) UpdateUpdatedAt

func (u *LinkUpsertBulk) UpdateUpdatedAt() *LinkUpsertBulk

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

type LinkUpsertOne

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

LinkUpsertOne is the builder for "upsert"-ing

one Link node.

func (*LinkUpsertOne) ClearDescribe

func (u *LinkUpsertOne) ClearDescribe() *LinkUpsertOne

ClearDescribe clears the value of the "describe" field.

func (*LinkUpsertOne) DoNothing

func (u *LinkUpsertOne) DoNothing() *LinkUpsertOne

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

func (*LinkUpsertOne) Exec

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

Exec executes the query.

func (*LinkUpsertOne) ExecX

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

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

func (*LinkUpsertOne) ID

func (u *LinkUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error)

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

func (*LinkUpsertOne) IDX

func (u *LinkUpsertOne) IDX(ctx context.Context) uuid.UUID

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

func (*LinkUpsertOne) Ignore

func (u *LinkUpsertOne) Ignore() *LinkUpsertOne

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

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

func (*LinkUpsertOne) SetCreatedAt

func (u *LinkUpsertOne) SetCreatedAt(v time.Time) *LinkUpsertOne

SetCreatedAt sets the "created_at" field.

func (*LinkUpsertOne) SetDescribe

func (u *LinkUpsertOne) SetDescribe(v string) *LinkUpsertOne

SetDescribe sets the "describe" field.

func (*LinkUpsertOne) SetHash

func (u *LinkUpsertOne) SetHash(v string) *LinkUpsertOne

SetHash sets the "hash" field.

func (*LinkUpsertOne) SetJSON

func (u *LinkUpsertOne) SetJSON(v v1.Link) *LinkUpsertOne

SetJSON sets the "json" field.

func (*LinkUpsertOne) SetURL

func (u *LinkUpsertOne) SetURL(v string) *LinkUpsertOne

SetURL sets the "url" field.

func (*LinkUpsertOne) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*LinkUpsertOne) Update

func (u *LinkUpsertOne) Update(set func(*LinkUpsert)) *LinkUpsertOne

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

func (*LinkUpsertOne) UpdateCreatedAt

func (u *LinkUpsertOne) UpdateCreatedAt() *LinkUpsertOne

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

func (*LinkUpsertOne) UpdateDescribe

func (u *LinkUpsertOne) UpdateDescribe() *LinkUpsertOne

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

func (*LinkUpsertOne) UpdateHash

func (u *LinkUpsertOne) UpdateHash() *LinkUpsertOne

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

func (*LinkUpsertOne) UpdateJSON

func (u *LinkUpsertOne) UpdateJSON() *LinkUpsertOne

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

func (*LinkUpsertOne) UpdateNewValues

func (u *LinkUpsertOne) UpdateNewValues() *LinkUpsertOne

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

func (*LinkUpsertOne) UpdateURL

func (u *LinkUpsertOne) UpdateURL() *LinkUpsertOne

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

func (*LinkUpsertOne) UpdateUpdatedAt

func (u *LinkUpsertOne) UpdateUpdatedAt() *LinkUpsertOne

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

type Links []*Link

Links is a parsable slice of Link.

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 {

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