ent

package
v0.0.0-...-b8a6b6b Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeDocument = "Document"
	TypeTerm     = "Term"
)

Variables

This section is empty.

Functions

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
	// Document is the client for interacting with the Document builders.
	Document *DocumentClient
	// Term is the client for interacting with the Term builders.
	Term *TermClient
	// 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().
	Document.
	Query().
	Count(ctx)

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 Document

type Document struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Content holds the value of the "content" field.
	Content string `json:"content,omitempty"`
	// TokenizedContent holds the value of the "tokenized_content" field.
	TokenizedContent string `json:"tokenized_content,omitempty"`
	// contains filtered or unexported fields
}

Document is the model entity for the Document schema.

func (*Document) String

func (d *Document) String() string

String implements the fmt.Stringer.

func (*Document) Unwrap

func (d *Document) Unwrap() *Document

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

func (d *Document) Update() *DocumentUpdateOne

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

type DocumentClient

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

DocumentClient is a client for the Document schema.

func NewDocumentClient

func NewDocumentClient(c config) *DocumentClient

NewDocumentClient returns a client for the Document from the given config.

func (*DocumentClient) Create

func (c *DocumentClient) Create() *DocumentCreate

Create returns a create builder for Document.

func (*DocumentClient) CreateBulk

func (c *DocumentClient) CreateBulk(builders ...*DocumentCreate) *DocumentCreateBulk

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

func (*DocumentClient) Delete

func (c *DocumentClient) Delete() *DocumentDelete

Delete returns a delete builder for Document.

func (*DocumentClient) DeleteOne

func (c *DocumentClient) DeleteOne(d *Document) *DocumentDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*DocumentClient) DeleteOneID

func (c *DocumentClient) DeleteOneID(id int) *DocumentDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*DocumentClient) Get

func (c *DocumentClient) Get(ctx context.Context, id int) (*Document, error)

Get returns a Document entity by its id.

func (*DocumentClient) GetX

func (c *DocumentClient) GetX(ctx context.Context, id int) *Document

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

func (*DocumentClient) Hooks

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

Hooks returns the client hooks.

func (*DocumentClient) Query

func (c *DocumentClient) Query() *DocumentQuery

Query returns a query builder for Document.

func (*DocumentClient) Update

func (c *DocumentClient) Update() *DocumentUpdate

Update returns an update builder for Document.

func (*DocumentClient) UpdateOne

func (c *DocumentClient) UpdateOne(d *Document) *DocumentUpdateOne

UpdateOne returns an update builder for the given entity.

func (*DocumentClient) UpdateOneID

func (c *DocumentClient) UpdateOneID(id int) *DocumentUpdateOne

UpdateOneID returns an update builder for the given id.

func (*DocumentClient) Use

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

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

type DocumentCreate

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

DocumentCreate is the builder for creating a Document entity.

func (*DocumentCreate) Exec

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

Exec executes the query.

func (*DocumentCreate) ExecX

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

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

func (*DocumentCreate) Mutation

func (dc *DocumentCreate) Mutation() *DocumentMutation

Mutation returns the DocumentMutation object of the builder.

func (*DocumentCreate) OnConflict

func (dc *DocumentCreate) OnConflict(opts ...sql.ConflictOption) *DocumentUpsertOne

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

client.Document.Create().
	SetCreatedAt(v).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.DocumentUpsert) {
		SetCreatedAt(v+v).
	}).
	Exec(ctx)

func (*DocumentCreate) OnConflictColumns

func (dc *DocumentCreate) OnConflictColumns(columns ...string) *DocumentUpsertOne

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

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

func (*DocumentCreate) Save

func (dc *DocumentCreate) Save(ctx context.Context) (*Document, error)

Save creates the Document in the database.

func (*DocumentCreate) SaveX

func (dc *DocumentCreate) SaveX(ctx context.Context) *Document

SaveX calls Save and panics if Save returns an error.

func (*DocumentCreate) SetContent

func (dc *DocumentCreate) SetContent(s string) *DocumentCreate

SetContent sets the "content" field.

func (*DocumentCreate) SetCreatedAt

func (dc *DocumentCreate) SetCreatedAt(t time.Time) *DocumentCreate

SetCreatedAt sets the "created_at" field.

func (*DocumentCreate) SetNillableCreatedAt

func (dc *DocumentCreate) SetNillableCreatedAt(t *time.Time) *DocumentCreate

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

func (*DocumentCreate) SetNillableUpdatedAt

func (dc *DocumentCreate) SetNillableUpdatedAt(t *time.Time) *DocumentCreate

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

func (*DocumentCreate) SetTokenizedContent

func (dc *DocumentCreate) SetTokenizedContent(s string) *DocumentCreate

SetTokenizedContent sets the "tokenized_content" field.

func (*DocumentCreate) SetUpdatedAt

func (dc *DocumentCreate) SetUpdatedAt(t time.Time) *DocumentCreate

SetUpdatedAt sets the "updated_at" field.

type DocumentCreateBulk

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

DocumentCreateBulk is the builder for creating many Document entities in bulk.

func (*DocumentCreateBulk) Exec

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

Exec executes the query.

func (*DocumentCreateBulk) ExecX

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

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

func (*DocumentCreateBulk) OnConflict

func (dcb *DocumentCreateBulk) OnConflict(opts ...sql.ConflictOption) *DocumentUpsertBulk

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

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

func (*DocumentCreateBulk) OnConflictColumns

func (dcb *DocumentCreateBulk) OnConflictColumns(columns ...string) *DocumentUpsertBulk

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

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

func (*DocumentCreateBulk) Save

func (dcb *DocumentCreateBulk) Save(ctx context.Context) ([]*Document, error)

Save creates the Document entities in the database.

func (*DocumentCreateBulk) SaveX

func (dcb *DocumentCreateBulk) SaveX(ctx context.Context) []*Document

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

type DocumentDelete

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

DocumentDelete is the builder for deleting a Document entity.

func (*DocumentDelete) Exec

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

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

func (*DocumentDelete) ExecX

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

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

func (*DocumentDelete) Where

func (dd *DocumentDelete) Where(ps ...predicate.Document) *DocumentDelete

Where appends a list predicates to the DocumentDelete builder.

type DocumentDeleteOne

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

DocumentDeleteOne is the builder for deleting a single Document entity.

func (*DocumentDeleteOne) Exec

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

Exec executes the deletion query.

func (*DocumentDeleteOne) ExecX

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

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

type DocumentGroupBy

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

DocumentGroupBy is the group-by builder for Document entities.

func (*DocumentGroupBy) Aggregate

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

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

func (*DocumentGroupBy) Bool

func (dgb *DocumentGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) BoolX

func (dgb *DocumentGroupBy) BoolX(ctx context.Context) bool

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

func (*DocumentGroupBy) Bools

func (dgb *DocumentGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) BoolsX

func (dgb *DocumentGroupBy) BoolsX(ctx context.Context) []bool

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

func (*DocumentGroupBy) Float64

func (dgb *DocumentGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) Float64X

func (dgb *DocumentGroupBy) Float64X(ctx context.Context) float64

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

func (*DocumentGroupBy) Float64s

func (dgb *DocumentGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) Float64sX

func (dgb *DocumentGroupBy) Float64sX(ctx context.Context) []float64

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

func (*DocumentGroupBy) Int

func (dgb *DocumentGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) IntX

func (dgb *DocumentGroupBy) IntX(ctx context.Context) int

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

func (*DocumentGroupBy) Ints

func (dgb *DocumentGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) IntsX

func (dgb *DocumentGroupBy) IntsX(ctx context.Context) []int

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

func (*DocumentGroupBy) Scan

func (dgb *DocumentGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (*DocumentGroupBy) ScanX

func (dgb *DocumentGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*DocumentGroupBy) String

func (dgb *DocumentGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) StringX

func (dgb *DocumentGroupBy) StringX(ctx context.Context) string

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

func (*DocumentGroupBy) Strings

func (dgb *DocumentGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (*DocumentGroupBy) StringsX

func (dgb *DocumentGroupBy) StringsX(ctx context.Context) []string

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

type DocumentMutation

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

DocumentMutation represents an operation that mutates the Document nodes in the graph.

func (*DocumentMutation) AddField

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

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

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

func (*DocumentMutation) AddedField

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

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

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

func (*DocumentMutation) AddedIDs

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

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

func (*DocumentMutation) ClearEdge

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

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

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

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

func (*DocumentMutation) ClearedFields

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

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

func (DocumentMutation) Client

func (m DocumentMutation) 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 (*DocumentMutation) Content

func (m *DocumentMutation) Content() (r string, exists bool)

Content returns the value of the "content" field in the mutation.

func (*DocumentMutation) CreatedAt

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

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

func (*DocumentMutation) EdgeCleared

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

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

func (*DocumentMutation) Field

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

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

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

func (*DocumentMutation) Fields

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

func (m *DocumentMutation) ID() (id int, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.

func (*DocumentMutation) IDs

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

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

func (*DocumentMutation) OldContent

func (m *DocumentMutation) OldContent(ctx context.Context) (v string, err error)

OldContent returns the old "content" field's value of the Document entity. If the Document 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 (*DocumentMutation) OldCreatedAt

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

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

func (m *DocumentMutation) 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 (*DocumentMutation) OldTokenizedContent

func (m *DocumentMutation) OldTokenizedContent(ctx context.Context) (v string, err error)

OldTokenizedContent returns the old "tokenized_content" field's value of the Document entity. If the Document 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 (*DocumentMutation) OldUpdatedAt

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

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

func (m *DocumentMutation) Op() Op

Op returns the operation name.

func (*DocumentMutation) RemovedEdges

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

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

func (*DocumentMutation) RemovedIDs

func (m *DocumentMutation) 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 (*DocumentMutation) ResetContent

func (m *DocumentMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*DocumentMutation) ResetCreatedAt

func (m *DocumentMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*DocumentMutation) ResetEdge

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

func (m *DocumentMutation) 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 (*DocumentMutation) ResetTokenizedContent

func (m *DocumentMutation) ResetTokenizedContent()

ResetTokenizedContent resets all changes to the "tokenized_content" field.

func (*DocumentMutation) ResetUpdatedAt

func (m *DocumentMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*DocumentMutation) SetContent

func (m *DocumentMutation) SetContent(s string)

SetContent sets the "content" field.

func (*DocumentMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*DocumentMutation) SetField

func (m *DocumentMutation) 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 (*DocumentMutation) SetTokenizedContent

func (m *DocumentMutation) SetTokenizedContent(s string)

SetTokenizedContent sets the "tokenized_content" field.

func (*DocumentMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*DocumentMutation) TokenizedContent

func (m *DocumentMutation) TokenizedContent() (r string, exists bool)

TokenizedContent returns the value of the "tokenized_content" field in the mutation.

func (DocumentMutation) Tx

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

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

func (*DocumentMutation) Type

func (m *DocumentMutation) Type() string

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

func (*DocumentMutation) UpdatedAt

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

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

func (*DocumentMutation) Where

func (m *DocumentMutation) Where(ps ...predicate.Document)

Where appends a list predicates to the DocumentMutation builder.

type DocumentQuery

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

DocumentQuery is the builder for querying Document entities.

func (*DocumentQuery) All

func (dq *DocumentQuery) All(ctx context.Context) ([]*Document, error)

All executes the query and returns a list of Documents.

func (*DocumentQuery) AllX

func (dq *DocumentQuery) AllX(ctx context.Context) []*Document

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

func (*DocumentQuery) Clone

func (dq *DocumentQuery) Clone() *DocumentQuery

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

func (*DocumentQuery) Count

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

Count returns the count of the given query.

func (*DocumentQuery) CountX

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

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

func (*DocumentQuery) Exist

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

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

func (*DocumentQuery) ExistX

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

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

func (*DocumentQuery) First

func (dq *DocumentQuery) First(ctx context.Context) (*Document, error)

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

func (*DocumentQuery) FirstID

func (dq *DocumentQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*DocumentQuery) FirstIDX

func (dq *DocumentQuery) FirstIDX(ctx context.Context) int

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

func (*DocumentQuery) FirstX

func (dq *DocumentQuery) FirstX(ctx context.Context) *Document

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

func (*DocumentQuery) GroupBy

func (dq *DocumentQuery) GroupBy(field string, fields ...string) *DocumentGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Document.Query().
	GroupBy(document.FieldCreatedAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*DocumentQuery) IDs

func (dq *DocumentQuery) IDs(ctx context.Context) ([]int, error)

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

func (*DocumentQuery) IDsX

func (dq *DocumentQuery) IDsX(ctx context.Context) []int

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

func (*DocumentQuery) Limit

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

Limit adds a limit step to the query.

func (*DocumentQuery) Offset

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

Offset adds an offset step to the query.

func (*DocumentQuery) Only

func (dq *DocumentQuery) Only(ctx context.Context) (*Document, error)

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

func (*DocumentQuery) OnlyID

func (dq *DocumentQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*DocumentQuery) OnlyIDX

func (dq *DocumentQuery) OnlyIDX(ctx context.Context) int

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

func (*DocumentQuery) OnlyX

func (dq *DocumentQuery) OnlyX(ctx context.Context) *Document

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

func (*DocumentQuery) Order

func (dq *DocumentQuery) Order(o ...OrderFunc) *DocumentQuery

Order adds an order step to the query.

func (*DocumentQuery) Select

func (dq *DocumentQuery) Select(fields ...string) *DocumentSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
}

client.Document.Query().
	Select(document.FieldCreatedAt).
	Scan(ctx, &v)

func (*DocumentQuery) Unique

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

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

func (dq *DocumentQuery) Where(ps ...predicate.Document) *DocumentQuery

Where adds a new predicate for the DocumentQuery builder.

type DocumentSelect

type DocumentSelect struct {
	*DocumentQuery
	// contains filtered or unexported fields
}

DocumentSelect is the builder for selecting fields of Document entities.

func (*DocumentSelect) Bool

func (ds *DocumentSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*DocumentSelect) BoolX

func (ds *DocumentSelect) BoolX(ctx context.Context) bool

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

func (*DocumentSelect) Bools

func (ds *DocumentSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*DocumentSelect) BoolsX

func (ds *DocumentSelect) BoolsX(ctx context.Context) []bool

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

func (*DocumentSelect) Float64

func (ds *DocumentSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*DocumentSelect) Float64X

func (ds *DocumentSelect) Float64X(ctx context.Context) float64

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

func (*DocumentSelect) Float64s

func (ds *DocumentSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*DocumentSelect) Float64sX

func (ds *DocumentSelect) Float64sX(ctx context.Context) []float64

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

func (*DocumentSelect) Int

func (ds *DocumentSelect) Int(ctx context.Context) (_ int, err error)

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

func (*DocumentSelect) IntX

func (ds *DocumentSelect) IntX(ctx context.Context) int

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

func (*DocumentSelect) Ints

func (ds *DocumentSelect) Ints(ctx context.Context) ([]int, error)

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

func (*DocumentSelect) IntsX

func (ds *DocumentSelect) IntsX(ctx context.Context) []int

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

func (*DocumentSelect) Scan

func (ds *DocumentSelect) Scan(ctx context.Context, v interface{}) error

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

func (*DocumentSelect) ScanX

func (ds *DocumentSelect) ScanX(ctx context.Context, v interface{})

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

func (*DocumentSelect) String

func (ds *DocumentSelect) String(ctx context.Context) (_ string, err error)

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

func (*DocumentSelect) StringX

func (ds *DocumentSelect) StringX(ctx context.Context) string

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

func (*DocumentSelect) Strings

func (ds *DocumentSelect) Strings(ctx context.Context) ([]string, error)

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

func (*DocumentSelect) StringsX

func (ds *DocumentSelect) StringsX(ctx context.Context) []string

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

type DocumentUpdate

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

DocumentUpdate is the builder for updating Document entities.

func (*DocumentUpdate) Exec

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

Exec executes the query.

func (*DocumentUpdate) ExecX

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

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

func (*DocumentUpdate) Mutation

func (du *DocumentUpdate) Mutation() *DocumentMutation

Mutation returns the DocumentMutation object of the builder.

func (*DocumentUpdate) Save

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

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

func (*DocumentUpdate) SaveX

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

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

func (*DocumentUpdate) SetContent

func (du *DocumentUpdate) SetContent(s string) *DocumentUpdate

SetContent sets the "content" field.

func (*DocumentUpdate) SetTokenizedContent

func (du *DocumentUpdate) SetTokenizedContent(s string) *DocumentUpdate

SetTokenizedContent sets the "tokenized_content" field.

func (*DocumentUpdate) SetUpdatedAt

func (du *DocumentUpdate) SetUpdatedAt(t time.Time) *DocumentUpdate

SetUpdatedAt sets the "updated_at" field.

func (*DocumentUpdate) Where

func (du *DocumentUpdate) Where(ps ...predicate.Document) *DocumentUpdate

Where appends a list predicates to the DocumentUpdate builder.

type DocumentUpdateOne

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

DocumentUpdateOne is the builder for updating a single Document entity.

func (*DocumentUpdateOne) Exec

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

Exec executes the query on the entity.

func (*DocumentUpdateOne) ExecX

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

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

func (*DocumentUpdateOne) Mutation

func (duo *DocumentUpdateOne) Mutation() *DocumentMutation

Mutation returns the DocumentMutation object of the builder.

func (*DocumentUpdateOne) Save

func (duo *DocumentUpdateOne) Save(ctx context.Context) (*Document, error)

Save executes the query and returns the updated Document entity.

func (*DocumentUpdateOne) SaveX

func (duo *DocumentUpdateOne) SaveX(ctx context.Context) *Document

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

func (*DocumentUpdateOne) Select

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

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

func (*DocumentUpdateOne) SetContent

func (duo *DocumentUpdateOne) SetContent(s string) *DocumentUpdateOne

SetContent sets the "content" field.

func (*DocumentUpdateOne) SetTokenizedContent

func (duo *DocumentUpdateOne) SetTokenizedContent(s string) *DocumentUpdateOne

SetTokenizedContent sets the "tokenized_content" field.

func (*DocumentUpdateOne) SetUpdatedAt

func (duo *DocumentUpdateOne) SetUpdatedAt(t time.Time) *DocumentUpdateOne

SetUpdatedAt sets the "updated_at" field.

type DocumentUpsert

type DocumentUpsert struct {
	*sql.UpdateSet
}

DocumentUpsert is the "OnConflict" setter.

func (*DocumentUpsert) SetContent

func (u *DocumentUpsert) SetContent(v string) *DocumentUpsert

SetContent sets the "content" field.

func (*DocumentUpsert) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*DocumentUpsert) SetTokenizedContent

func (u *DocumentUpsert) SetTokenizedContent(v string) *DocumentUpsert

SetTokenizedContent sets the "tokenized_content" field.

func (*DocumentUpsert) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*DocumentUpsert) UpdateContent

func (u *DocumentUpsert) UpdateContent() *DocumentUpsert

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

func (*DocumentUpsert) UpdateCreatedAt

func (u *DocumentUpsert) UpdateCreatedAt() *DocumentUpsert

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

func (*DocumentUpsert) UpdateTokenizedContent

func (u *DocumentUpsert) UpdateTokenizedContent() *DocumentUpsert

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

func (*DocumentUpsert) UpdateUpdatedAt

func (u *DocumentUpsert) UpdateUpdatedAt() *DocumentUpsert

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

type DocumentUpsertBulk

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

DocumentUpsertBulk is the builder for "upsert"-ing a bulk of Document nodes.

func (*DocumentUpsertBulk) DoNothing

func (u *DocumentUpsertBulk) DoNothing() *DocumentUpsertBulk

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

func (*DocumentUpsertBulk) Exec

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

Exec executes the query.

func (*DocumentUpsertBulk) ExecX

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

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

func (*DocumentUpsertBulk) Ignore

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

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

func (*DocumentUpsertBulk) SetContent

func (u *DocumentUpsertBulk) SetContent(v string) *DocumentUpsertBulk

SetContent sets the "content" field.

func (*DocumentUpsertBulk) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*DocumentUpsertBulk) SetTokenizedContent

func (u *DocumentUpsertBulk) SetTokenizedContent(v string) *DocumentUpsertBulk

SetTokenizedContent sets the "tokenized_content" field.

func (*DocumentUpsertBulk) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*DocumentUpsertBulk) Update

func (u *DocumentUpsertBulk) Update(set func(*DocumentUpsert)) *DocumentUpsertBulk

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

func (*DocumentUpsertBulk) UpdateContent

func (u *DocumentUpsertBulk) UpdateContent() *DocumentUpsertBulk

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

func (*DocumentUpsertBulk) UpdateCreatedAt

func (u *DocumentUpsertBulk) UpdateCreatedAt() *DocumentUpsertBulk

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

func (*DocumentUpsertBulk) UpdateNewValues

func (u *DocumentUpsertBulk) UpdateNewValues() *DocumentUpsertBulk

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

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

func (*DocumentUpsertBulk) UpdateTokenizedContent

func (u *DocumentUpsertBulk) UpdateTokenizedContent() *DocumentUpsertBulk

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

func (*DocumentUpsertBulk) UpdateUpdatedAt

func (u *DocumentUpsertBulk) UpdateUpdatedAt() *DocumentUpsertBulk

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

type DocumentUpsertOne

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

DocumentUpsertOne is the builder for "upsert"-ing

one Document node.

func (*DocumentUpsertOne) DoNothing

func (u *DocumentUpsertOne) DoNothing() *DocumentUpsertOne

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

func (*DocumentUpsertOne) Exec

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

Exec executes the query.

func (*DocumentUpsertOne) ExecX

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

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

func (*DocumentUpsertOne) ID

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

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

func (*DocumentUpsertOne) IDX

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

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

func (*DocumentUpsertOne) Ignore

func (u *DocumentUpsertOne) Ignore() *DocumentUpsertOne

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

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

func (*DocumentUpsertOne) SetContent

func (u *DocumentUpsertOne) SetContent(v string) *DocumentUpsertOne

SetContent sets the "content" field.

func (*DocumentUpsertOne) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*DocumentUpsertOne) SetTokenizedContent

func (u *DocumentUpsertOne) SetTokenizedContent(v string) *DocumentUpsertOne

SetTokenizedContent sets the "tokenized_content" field.

func (*DocumentUpsertOne) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*DocumentUpsertOne) Update

func (u *DocumentUpsertOne) Update(set func(*DocumentUpsert)) *DocumentUpsertOne

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

func (*DocumentUpsertOne) UpdateContent

func (u *DocumentUpsertOne) UpdateContent() *DocumentUpsertOne

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

func (*DocumentUpsertOne) UpdateCreatedAt

func (u *DocumentUpsertOne) UpdateCreatedAt() *DocumentUpsertOne

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

func (*DocumentUpsertOne) UpdateNewValues

func (u *DocumentUpsertOne) UpdateNewValues() *DocumentUpsertOne

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

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

func (*DocumentUpsertOne) UpdateTokenizedContent

func (u *DocumentUpsertOne) UpdateTokenizedContent() *DocumentUpsertOne

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

func (*DocumentUpsertOne) UpdateUpdatedAt

func (u *DocumentUpsertOne) UpdateUpdatedAt() *DocumentUpsertOne

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

type Documents

type Documents []*Document

Documents is a parsable slice of Document.

type Hook

type Hook = ent.Hook

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(...interface{})) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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

type Term struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Word holds the value of the "word" field.
	Word string `json:"word,omitempty"`
	// PostingListCompressed holds the value of the "posting_list_compressed" field.
	PostingListCompressed []byte `json:"posting_list_compressed,omitempty"`
	// contains filtered or unexported fields
}

Term is the model entity for the Term schema.

func (*Term) String

func (t *Term) String() string

String implements the fmt.Stringer.

func (*Term) Unwrap

func (t *Term) Unwrap() *Term

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

func (t *Term) Update() *TermUpdateOne

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

type TermClient

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

TermClient is a client for the Term schema.

func NewTermClient

func NewTermClient(c config) *TermClient

NewTermClient returns a client for the Term from the given config.

func (*TermClient) Create

func (c *TermClient) Create() *TermCreate

Create returns a create builder for Term.

func (*TermClient) CreateBulk

func (c *TermClient) CreateBulk(builders ...*TermCreate) *TermCreateBulk

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

func (*TermClient) Delete

func (c *TermClient) Delete() *TermDelete

Delete returns a delete builder for Term.

func (*TermClient) DeleteOne

func (c *TermClient) DeleteOne(t *Term) *TermDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*TermClient) DeleteOneID

func (c *TermClient) DeleteOneID(id uuid.UUID) *TermDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*TermClient) Get

func (c *TermClient) Get(ctx context.Context, id uuid.UUID) (*Term, error)

Get returns a Term entity by its id.

func (*TermClient) GetX

func (c *TermClient) GetX(ctx context.Context, id uuid.UUID) *Term

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

func (*TermClient) Hooks

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

Hooks returns the client hooks.

func (*TermClient) Query

func (c *TermClient) Query() *TermQuery

Query returns a query builder for Term.

func (*TermClient) Update

func (c *TermClient) Update() *TermUpdate

Update returns an update builder for Term.

func (*TermClient) UpdateOne

func (c *TermClient) UpdateOne(t *Term) *TermUpdateOne

UpdateOne returns an update builder for the given entity.

func (*TermClient) UpdateOneID

func (c *TermClient) UpdateOneID(id uuid.UUID) *TermUpdateOne

UpdateOneID returns an update builder for the given id.

func (*TermClient) Use

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

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

type TermCreate

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

TermCreate is the builder for creating a Term entity.

func (*TermCreate) Exec

func (tc *TermCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*TermCreate) ExecX

func (tc *TermCreate) ExecX(ctx context.Context)

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

func (*TermCreate) Mutation

func (tc *TermCreate) Mutation() *TermMutation

Mutation returns the TermMutation object of the builder.

func (*TermCreate) OnConflict

func (tc *TermCreate) OnConflict(opts ...sql.ConflictOption) *TermUpsertOne

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

client.Term.Create().
	SetCreatedAt(v).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.TermUpsert) {
		SetCreatedAt(v+v).
	}).
	Exec(ctx)

func (*TermCreate) OnConflictColumns

func (tc *TermCreate) OnConflictColumns(columns ...string) *TermUpsertOne

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

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

func (*TermCreate) Save

func (tc *TermCreate) Save(ctx context.Context) (*Term, error)

Save creates the Term in the database.

func (*TermCreate) SaveX

func (tc *TermCreate) SaveX(ctx context.Context) *Term

SaveX calls Save and panics if Save returns an error.

func (*TermCreate) SetCreatedAt

func (tc *TermCreate) SetCreatedAt(t time.Time) *TermCreate

SetCreatedAt sets the "created_at" field.

func (*TermCreate) SetID

func (tc *TermCreate) SetID(u uuid.UUID) *TermCreate

SetID sets the "id" field.

func (*TermCreate) SetNillableCreatedAt

func (tc *TermCreate) SetNillableCreatedAt(t *time.Time) *TermCreate

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

func (*TermCreate) SetNillableID

func (tc *TermCreate) SetNillableID(u *uuid.UUID) *TermCreate

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

func (*TermCreate) SetNillableUpdatedAt

func (tc *TermCreate) SetNillableUpdatedAt(t *time.Time) *TermCreate

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

func (*TermCreate) SetPostingListCompressed

func (tc *TermCreate) SetPostingListCompressed(b []byte) *TermCreate

SetPostingListCompressed sets the "posting_list_compressed" field.

func (*TermCreate) SetUpdatedAt

func (tc *TermCreate) SetUpdatedAt(t time.Time) *TermCreate

SetUpdatedAt sets the "updated_at" field.

func (*TermCreate) SetWord

func (tc *TermCreate) SetWord(s string) *TermCreate

SetWord sets the "word" field.

type TermCreateBulk

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

TermCreateBulk is the builder for creating many Term entities in bulk.

func (*TermCreateBulk) Exec

func (tcb *TermCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*TermCreateBulk) ExecX

func (tcb *TermCreateBulk) ExecX(ctx context.Context)

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

func (*TermCreateBulk) OnConflict

func (tcb *TermCreateBulk) OnConflict(opts ...sql.ConflictOption) *TermUpsertBulk

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

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

func (*TermCreateBulk) OnConflictColumns

func (tcb *TermCreateBulk) OnConflictColumns(columns ...string) *TermUpsertBulk

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

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

func (*TermCreateBulk) Save

func (tcb *TermCreateBulk) Save(ctx context.Context) ([]*Term, error)

Save creates the Term entities in the database.

func (*TermCreateBulk) SaveX

func (tcb *TermCreateBulk) SaveX(ctx context.Context) []*Term

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

type TermDelete

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

TermDelete is the builder for deleting a Term entity.

func (*TermDelete) Exec

func (td *TermDelete) Exec(ctx context.Context) (int, error)

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

func (*TermDelete) ExecX

func (td *TermDelete) ExecX(ctx context.Context) int

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

func (*TermDelete) Where

func (td *TermDelete) Where(ps ...predicate.Term) *TermDelete

Where appends a list predicates to the TermDelete builder.

type TermDeleteOne

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

TermDeleteOne is the builder for deleting a single Term entity.

func (*TermDeleteOne) Exec

func (tdo *TermDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*TermDeleteOne) ExecX

func (tdo *TermDeleteOne) ExecX(ctx context.Context)

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

type TermGroupBy

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

TermGroupBy is the group-by builder for Term entities.

func (*TermGroupBy) Aggregate

func (tgb *TermGroupBy) Aggregate(fns ...AggregateFunc) *TermGroupBy

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

func (*TermGroupBy) Bool

func (tgb *TermGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) BoolX

func (tgb *TermGroupBy) BoolX(ctx context.Context) bool

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

func (*TermGroupBy) Bools

func (tgb *TermGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) BoolsX

func (tgb *TermGroupBy) BoolsX(ctx context.Context) []bool

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

func (*TermGroupBy) Float64

func (tgb *TermGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) Float64X

func (tgb *TermGroupBy) Float64X(ctx context.Context) float64

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

func (*TermGroupBy) Float64s

func (tgb *TermGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) Float64sX

func (tgb *TermGroupBy) Float64sX(ctx context.Context) []float64

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

func (*TermGroupBy) Int

func (tgb *TermGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) IntX

func (tgb *TermGroupBy) IntX(ctx context.Context) int

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

func (*TermGroupBy) Ints

func (tgb *TermGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) IntsX

func (tgb *TermGroupBy) IntsX(ctx context.Context) []int

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

func (*TermGroupBy) Scan

func (tgb *TermGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (*TermGroupBy) ScanX

func (tgb *TermGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*TermGroupBy) String

func (tgb *TermGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) StringX

func (tgb *TermGroupBy) StringX(ctx context.Context) string

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

func (*TermGroupBy) Strings

func (tgb *TermGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (*TermGroupBy) StringsX

func (tgb *TermGroupBy) StringsX(ctx context.Context) []string

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

type TermMutation

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

TermMutation represents an operation that mutates the Term nodes in the graph.

func (*TermMutation) AddField

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

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

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

func (*TermMutation) AddedField

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

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

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

func (*TermMutation) AddedIDs

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

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

func (*TermMutation) ClearEdge

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

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

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

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

func (*TermMutation) ClearedFields

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

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

func (TermMutation) Client

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

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

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

func (*TermMutation) EdgeCleared

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

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

func (*TermMutation) Field

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

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

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

func (*TermMutation) Fields

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

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

func (m *TermMutation) 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 (*TermMutation) OldCreatedAt

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

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

func (m *TermMutation) 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 (*TermMutation) OldPostingListCompressed

func (m *TermMutation) OldPostingListCompressed(ctx context.Context) (v []byte, err error)

OldPostingListCompressed returns the old "posting_list_compressed" field's value of the Term entity. If the Term 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 (*TermMutation) OldUpdatedAt

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

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

func (m *TermMutation) OldWord(ctx context.Context) (v string, err error)

OldWord returns the old "word" field's value of the Term entity. If the Term 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 (*TermMutation) Op

func (m *TermMutation) Op() Op

Op returns the operation name.

func (*TermMutation) PostingListCompressed

func (m *TermMutation) PostingListCompressed() (r []byte, exists bool)

PostingListCompressed returns the value of the "posting_list_compressed" field in the mutation.

func (*TermMutation) RemovedEdges

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

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

func (*TermMutation) RemovedIDs

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

func (m *TermMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*TermMutation) ResetEdge

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

func (m *TermMutation) 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 (*TermMutation) ResetPostingListCompressed

func (m *TermMutation) ResetPostingListCompressed()

ResetPostingListCompressed resets all changes to the "posting_list_compressed" field.

func (*TermMutation) ResetUpdatedAt

func (m *TermMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*TermMutation) ResetWord

func (m *TermMutation) ResetWord()

ResetWord resets all changes to the "word" field.

func (*TermMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*TermMutation) SetField

func (m *TermMutation) 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 (*TermMutation) SetID

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

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

func (*TermMutation) SetPostingListCompressed

func (m *TermMutation) SetPostingListCompressed(b []byte)

SetPostingListCompressed sets the "posting_list_compressed" field.

func (*TermMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*TermMutation) SetWord

func (m *TermMutation) SetWord(s string)

SetWord sets the "word" field.

func (TermMutation) Tx

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

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

func (*TermMutation) Type

func (m *TermMutation) Type() string

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

func (*TermMutation) UpdatedAt

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

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

func (*TermMutation) Where

func (m *TermMutation) Where(ps ...predicate.Term)

Where appends a list predicates to the TermMutation builder.

func (*TermMutation) Word

func (m *TermMutation) Word() (r string, exists bool)

Word returns the value of the "word" field in the mutation.

type TermQuery

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

TermQuery is the builder for querying Term entities.

func (*TermQuery) All

func (tq *TermQuery) All(ctx context.Context) ([]*Term, error)

All executes the query and returns a list of Terms.

func (*TermQuery) AllX

func (tq *TermQuery) AllX(ctx context.Context) []*Term

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

func (*TermQuery) Clone

func (tq *TermQuery) Clone() *TermQuery

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

func (*TermQuery) Count

func (tq *TermQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*TermQuery) CountX

func (tq *TermQuery) CountX(ctx context.Context) int

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

func (*TermQuery) Exist

func (tq *TermQuery) Exist(ctx context.Context) (bool, error)

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

func (*TermQuery) ExistX

func (tq *TermQuery) ExistX(ctx context.Context) bool

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

func (*TermQuery) First

func (tq *TermQuery) First(ctx context.Context) (*Term, error)

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

func (*TermQuery) FirstID

func (tq *TermQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*TermQuery) FirstIDX

func (tq *TermQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*TermQuery) FirstX

func (tq *TermQuery) FirstX(ctx context.Context) *Term

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

func (*TermQuery) GroupBy

func (tq *TermQuery) GroupBy(field string, fields ...string) *TermGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Term.Query().
	GroupBy(term.FieldCreatedAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*TermQuery) IDs

func (tq *TermQuery) IDs(ctx context.Context) ([]uuid.UUID, error)

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

func (*TermQuery) IDsX

func (tq *TermQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*TermQuery) Limit

func (tq *TermQuery) Limit(limit int) *TermQuery

Limit adds a limit step to the query.

func (*TermQuery) Offset

func (tq *TermQuery) Offset(offset int) *TermQuery

Offset adds an offset step to the query.

func (*TermQuery) Only

func (tq *TermQuery) Only(ctx context.Context) (*Term, error)

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

func (*TermQuery) OnlyID

func (tq *TermQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*TermQuery) OnlyIDX

func (tq *TermQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*TermQuery) OnlyX

func (tq *TermQuery) OnlyX(ctx context.Context) *Term

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

func (*TermQuery) Order

func (tq *TermQuery) Order(o ...OrderFunc) *TermQuery

Order adds an order step to the query.

func (*TermQuery) Select

func (tq *TermQuery) Select(fields ...string) *TermSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
}

client.Term.Query().
	Select(term.FieldCreatedAt).
	Scan(ctx, &v)

func (*TermQuery) Unique

func (tq *TermQuery) Unique(unique bool) *TermQuery

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

func (tq *TermQuery) Where(ps ...predicate.Term) *TermQuery

Where adds a new predicate for the TermQuery builder.

type TermSelect

type TermSelect struct {
	*TermQuery
	// contains filtered or unexported fields
}

TermSelect is the builder for selecting fields of Term entities.

func (*TermSelect) Bool

func (ts *TermSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*TermSelect) BoolX

func (ts *TermSelect) BoolX(ctx context.Context) bool

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

func (*TermSelect) Bools

func (ts *TermSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*TermSelect) BoolsX

func (ts *TermSelect) BoolsX(ctx context.Context) []bool

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

func (*TermSelect) Float64

func (ts *TermSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*TermSelect) Float64X

func (ts *TermSelect) Float64X(ctx context.Context) float64

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

func (*TermSelect) Float64s

func (ts *TermSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*TermSelect) Float64sX

func (ts *TermSelect) Float64sX(ctx context.Context) []float64

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

func (*TermSelect) Int

func (ts *TermSelect) Int(ctx context.Context) (_ int, err error)

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

func (*TermSelect) IntX

func (ts *TermSelect) IntX(ctx context.Context) int

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

func (*TermSelect) Ints

func (ts *TermSelect) Ints(ctx context.Context) ([]int, error)

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

func (*TermSelect) IntsX

func (ts *TermSelect) IntsX(ctx context.Context) []int

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

func (*TermSelect) Scan

func (ts *TermSelect) Scan(ctx context.Context, v interface{}) error

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

func (*TermSelect) ScanX

func (ts *TermSelect) ScanX(ctx context.Context, v interface{})

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

func (*TermSelect) String

func (ts *TermSelect) String(ctx context.Context) (_ string, err error)

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

func (*TermSelect) StringX

func (ts *TermSelect) StringX(ctx context.Context) string

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

func (*TermSelect) Strings

func (ts *TermSelect) Strings(ctx context.Context) ([]string, error)

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

func (*TermSelect) StringsX

func (ts *TermSelect) StringsX(ctx context.Context) []string

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

type TermUpdate

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

TermUpdate is the builder for updating Term entities.

func (*TermUpdate) Exec

func (tu *TermUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*TermUpdate) ExecX

func (tu *TermUpdate) ExecX(ctx context.Context)

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

func (*TermUpdate) Mutation

func (tu *TermUpdate) Mutation() *TermMutation

Mutation returns the TermMutation object of the builder.

func (*TermUpdate) Save

func (tu *TermUpdate) Save(ctx context.Context) (int, error)

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

func (*TermUpdate) SaveX

func (tu *TermUpdate) SaveX(ctx context.Context) int

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

func (*TermUpdate) SetPostingListCompressed

func (tu *TermUpdate) SetPostingListCompressed(b []byte) *TermUpdate

SetPostingListCompressed sets the "posting_list_compressed" field.

func (*TermUpdate) SetUpdatedAt

func (tu *TermUpdate) SetUpdatedAt(t time.Time) *TermUpdate

SetUpdatedAt sets the "updated_at" field.

func (*TermUpdate) SetWord

func (tu *TermUpdate) SetWord(s string) *TermUpdate

SetWord sets the "word" field.

func (*TermUpdate) Where

func (tu *TermUpdate) Where(ps ...predicate.Term) *TermUpdate

Where appends a list predicates to the TermUpdate builder.

type TermUpdateOne

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

TermUpdateOne is the builder for updating a single Term entity.

func (*TermUpdateOne) Exec

func (tuo *TermUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*TermUpdateOne) ExecX

func (tuo *TermUpdateOne) ExecX(ctx context.Context)

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

func (*TermUpdateOne) Mutation

func (tuo *TermUpdateOne) Mutation() *TermMutation

Mutation returns the TermMutation object of the builder.

func (*TermUpdateOne) Save

func (tuo *TermUpdateOne) Save(ctx context.Context) (*Term, error)

Save executes the query and returns the updated Term entity.

func (*TermUpdateOne) SaveX

func (tuo *TermUpdateOne) SaveX(ctx context.Context) *Term

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

func (*TermUpdateOne) Select

func (tuo *TermUpdateOne) Select(field string, fields ...string) *TermUpdateOne

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

func (*TermUpdateOne) SetPostingListCompressed

func (tuo *TermUpdateOne) SetPostingListCompressed(b []byte) *TermUpdateOne

SetPostingListCompressed sets the "posting_list_compressed" field.

func (*TermUpdateOne) SetUpdatedAt

func (tuo *TermUpdateOne) SetUpdatedAt(t time.Time) *TermUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*TermUpdateOne) SetWord

func (tuo *TermUpdateOne) SetWord(s string) *TermUpdateOne

SetWord sets the "word" field.

type TermUpsert

type TermUpsert struct {
	*sql.UpdateSet
}

TermUpsert is the "OnConflict" setter.

func (*TermUpsert) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*TermUpsert) SetPostingListCompressed

func (u *TermUpsert) SetPostingListCompressed(v []byte) *TermUpsert

SetPostingListCompressed sets the "posting_list_compressed" field.

func (*TermUpsert) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*TermUpsert) SetWord

func (u *TermUpsert) SetWord(v string) *TermUpsert

SetWord sets the "word" field.

func (*TermUpsert) UpdateCreatedAt

func (u *TermUpsert) UpdateCreatedAt() *TermUpsert

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

func (*TermUpsert) UpdatePostingListCompressed

func (u *TermUpsert) UpdatePostingListCompressed() *TermUpsert

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

func (*TermUpsert) UpdateUpdatedAt

func (u *TermUpsert) UpdateUpdatedAt() *TermUpsert

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

func (*TermUpsert) UpdateWord

func (u *TermUpsert) UpdateWord() *TermUpsert

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

type TermUpsertBulk

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

TermUpsertBulk is the builder for "upsert"-ing a bulk of Term nodes.

func (*TermUpsertBulk) DoNothing

func (u *TermUpsertBulk) DoNothing() *TermUpsertBulk

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

func (*TermUpsertBulk) Exec

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

Exec executes the query.

func (*TermUpsertBulk) ExecX

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

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

func (*TermUpsertBulk) Ignore

func (u *TermUpsertBulk) Ignore() *TermUpsertBulk

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

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

func (*TermUpsertBulk) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*TermUpsertBulk) SetPostingListCompressed

func (u *TermUpsertBulk) SetPostingListCompressed(v []byte) *TermUpsertBulk

SetPostingListCompressed sets the "posting_list_compressed" field.

func (*TermUpsertBulk) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*TermUpsertBulk) SetWord

func (u *TermUpsertBulk) SetWord(v string) *TermUpsertBulk

SetWord sets the "word" field.

func (*TermUpsertBulk) Update

func (u *TermUpsertBulk) Update(set func(*TermUpsert)) *TermUpsertBulk

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

func (*TermUpsertBulk) UpdateCreatedAt

func (u *TermUpsertBulk) UpdateCreatedAt() *TermUpsertBulk

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

func (*TermUpsertBulk) UpdateNewValues

func (u *TermUpsertBulk) UpdateNewValues() *TermUpsertBulk

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

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

func (*TermUpsertBulk) UpdatePostingListCompressed

func (u *TermUpsertBulk) UpdatePostingListCompressed() *TermUpsertBulk

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

func (*TermUpsertBulk) UpdateUpdatedAt

func (u *TermUpsertBulk) UpdateUpdatedAt() *TermUpsertBulk

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

func (*TermUpsertBulk) UpdateWord

func (u *TermUpsertBulk) UpdateWord() *TermUpsertBulk

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

type TermUpsertOne

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

TermUpsertOne is the builder for "upsert"-ing

one Term node.

func (*TermUpsertOne) DoNothing

func (u *TermUpsertOne) DoNothing() *TermUpsertOne

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

func (*TermUpsertOne) Exec

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

Exec executes the query.

func (*TermUpsertOne) ExecX

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

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

func (*TermUpsertOne) ID

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

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

func (*TermUpsertOne) IDX

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

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

func (*TermUpsertOne) Ignore

func (u *TermUpsertOne) Ignore() *TermUpsertOne

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

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

func (*TermUpsertOne) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*TermUpsertOne) SetPostingListCompressed

func (u *TermUpsertOne) SetPostingListCompressed(v []byte) *TermUpsertOne

SetPostingListCompressed sets the "posting_list_compressed" field.

func (*TermUpsertOne) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*TermUpsertOne) SetWord

func (u *TermUpsertOne) SetWord(v string) *TermUpsertOne

SetWord sets the "word" field.

func (*TermUpsertOne) Update

func (u *TermUpsertOne) Update(set func(*TermUpsert)) *TermUpsertOne

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

func (*TermUpsertOne) UpdateCreatedAt

func (u *TermUpsertOne) UpdateCreatedAt() *TermUpsertOne

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

func (*TermUpsertOne) UpdateNewValues

func (u *TermUpsertOne) UpdateNewValues() *TermUpsertOne

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

func (*TermUpsertOne) UpdatePostingListCompressed

func (u *TermUpsertOne) UpdatePostingListCompressed() *TermUpsertOne

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

func (*TermUpsertOne) UpdateUpdatedAt

func (u *TermUpsertOne) UpdateUpdatedAt() *TermUpsertOne

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

func (*TermUpsertOne) UpdateWord

func (u *TermUpsertOne) UpdateWord() *TermUpsertOne

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

type Terms

type Terms []*Term

Terms is a parsable slice of Term.

type Tx

type Tx struct {

	// Document is the client for interacting with the Document builders.
	Document *DocumentClient
	// Term is the client for interacting with the Term builders.
	Term *TermClient
	// 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