ent

package
v0.0.0-...-6d66e07 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeContent = "Content"
	TypeIndex   = "Index"
)

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
	// Content is the client for interacting with the Content builders.
	Content *ContentClient
	// Index is the client for interacting with the Index builders.
	Index *IndexClient
	// 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().
	Content.
	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(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 Committer 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 Content

type Content struct {

	// ID of the ent.
	ID int32 `json:"id,omitempty"`
	// Content holds the value of the "content" field.
	Content string `json:"content,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"`
	// contains filtered or unexported fields
}

Content is the model entity for the Content schema.

func (*Content) String

func (c *Content) String() string

String implements the fmt.Stringer.

func (*Content) Unwrap

func (c *Content) Unwrap() *Content

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

func (c *Content) Update() *ContentUpdateOne

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

type ContentClient

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

ContentClient is a client for the Content schema.

func NewContentClient

func NewContentClient(c config) *ContentClient

NewContentClient returns a client for the Content from the given config.

func (*ContentClient) Create

func (c *ContentClient) Create() *ContentCreate

Create returns a create builder for Content.

func (*ContentClient) CreateBulk

func (c *ContentClient) CreateBulk(builders ...*ContentCreate) *ContentCreateBulk

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

func (*ContentClient) Delete

func (c *ContentClient) Delete() *ContentDelete

Delete returns a delete builder for Content.

func (*ContentClient) DeleteOne

func (c *ContentClient) DeleteOne(co *Content) *ContentDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*ContentClient) DeleteOneID

func (c *ContentClient) DeleteOneID(id int32) *ContentDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*ContentClient) Get

func (c *ContentClient) Get(ctx context.Context, id int32) (*Content, error)

Get returns a Content entity by its id.

func (*ContentClient) GetX

func (c *ContentClient) GetX(ctx context.Context, id int32) *Content

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

func (*ContentClient) Hooks

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

Hooks returns the client hooks.

func (*ContentClient) Query

func (c *ContentClient) Query() *ContentQuery

Query returns a query builder for Content.

func (*ContentClient) Update

func (c *ContentClient) Update() *ContentUpdate

Update returns an update builder for Content.

func (*ContentClient) UpdateOne

func (c *ContentClient) UpdateOne(co *Content) *ContentUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ContentClient) UpdateOneID

func (c *ContentClient) UpdateOneID(id int32) *ContentUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ContentClient) Use

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

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

type ContentCreate

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

ContentCreate is the builder for creating a Content entity.

func (*ContentCreate) Exec

func (cc *ContentCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*ContentCreate) ExecX

func (cc *ContentCreate) ExecX(ctx context.Context)

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

func (*ContentCreate) Mutation

func (cc *ContentCreate) Mutation() *ContentMutation

Mutation returns the ContentMutation object of the builder.

func (*ContentCreate) Save

func (cc *ContentCreate) Save(ctx context.Context) (*Content, error)

Save creates the Content in the database.

func (*ContentCreate) SaveX

func (cc *ContentCreate) SaveX(ctx context.Context) *Content

SaveX calls Save and panics if Save returns an error.

func (*ContentCreate) SetContent

func (cc *ContentCreate) SetContent(s string) *ContentCreate

SetContent sets the "content" field.

func (*ContentCreate) SetCreatedAt

func (cc *ContentCreate) SetCreatedAt(t time.Time) *ContentCreate

SetCreatedAt sets the "created_at" field.

func (*ContentCreate) SetID

func (cc *ContentCreate) SetID(i int32) *ContentCreate

SetID sets the "id" field.

func (*ContentCreate) SetNillableCreatedAt

func (cc *ContentCreate) SetNillableCreatedAt(t *time.Time) *ContentCreate

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

func (*ContentCreate) SetNillableUpdatedAt

func (cc *ContentCreate) SetNillableUpdatedAt(t *time.Time) *ContentCreate

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

func (*ContentCreate) SetUpdatedAt

func (cc *ContentCreate) SetUpdatedAt(t time.Time) *ContentCreate

SetUpdatedAt sets the "updated_at" field.

type ContentCreateBulk

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

ContentCreateBulk is the builder for creating many Content entities in bulk.

func (*ContentCreateBulk) Exec

func (ccb *ContentCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*ContentCreateBulk) ExecX

func (ccb *ContentCreateBulk) ExecX(ctx context.Context)

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

func (*ContentCreateBulk) Save

func (ccb *ContentCreateBulk) Save(ctx context.Context) ([]*Content, error)

Save creates the Content entities in the database.

func (*ContentCreateBulk) SaveX

func (ccb *ContentCreateBulk) SaveX(ctx context.Context) []*Content

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

type ContentDelete

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

ContentDelete is the builder for deleting a Content entity.

func (*ContentDelete) Exec

func (cd *ContentDelete) Exec(ctx context.Context) (int, error)

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

func (*ContentDelete) ExecX

func (cd *ContentDelete) ExecX(ctx context.Context) int

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

func (*ContentDelete) Where

func (cd *ContentDelete) Where(ps ...predicate.Content) *ContentDelete

Where appends a list predicates to the ContentDelete builder.

type ContentDeleteOne

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

ContentDeleteOne is the builder for deleting a single Content entity.

func (*ContentDeleteOne) Exec

func (cdo *ContentDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*ContentDeleteOne) ExecX

func (cdo *ContentDeleteOne) ExecX(ctx context.Context)

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

type ContentGroupBy

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

ContentGroupBy is the group-by builder for Content entities.

func (*ContentGroupBy) Aggregate

func (cgb *ContentGroupBy) Aggregate(fns ...AggregateFunc) *ContentGroupBy

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

func (*ContentGroupBy) Bool

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) BoolX

func (cgb *ContentGroupBy) BoolX(ctx context.Context) bool

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

func (*ContentGroupBy) Bools

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) BoolsX

func (cgb *ContentGroupBy) BoolsX(ctx context.Context) []bool

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

func (*ContentGroupBy) Float64

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) Float64X

func (cgb *ContentGroupBy) Float64X(ctx context.Context) float64

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

func (*ContentGroupBy) Float64s

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) Float64sX

func (cgb *ContentGroupBy) Float64sX(ctx context.Context) []float64

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

func (*ContentGroupBy) Int

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) IntX

func (cgb *ContentGroupBy) IntX(ctx context.Context) int

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

func (*ContentGroupBy) Ints

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) IntsX

func (cgb *ContentGroupBy) IntsX(ctx context.Context) []int

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

func (*ContentGroupBy) Scan

func (cgb *ContentGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*ContentGroupBy) ScanX

func (cgb *ContentGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*ContentGroupBy) String

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) StringX

func (cgb *ContentGroupBy) StringX(ctx context.Context) string

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

func (*ContentGroupBy) Strings

func (cgb *ContentGroupBy) 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 (*ContentGroupBy) StringsX

func (cgb *ContentGroupBy) StringsX(ctx context.Context) []string

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

type ContentMutation

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

ContentMutation represents an operation that mutates the Content nodes in the graph.

func (*ContentMutation) AddField

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

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

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

func (*ContentMutation) AddedField

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

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

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

func (*ContentMutation) AddedIDs

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

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

func (*ContentMutation) ClearEdge

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

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

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

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

func (*ContentMutation) ClearedFields

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

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

func (ContentMutation) Client

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

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

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

func (*ContentMutation) CreatedAt

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

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

func (*ContentMutation) EdgeCleared

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

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

func (*ContentMutation) Field

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

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

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

func (*ContentMutation) Fields

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

func (m *ContentMutation) ID() (id int32, 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 (*ContentMutation) OldContent

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

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

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

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

func (m *ContentMutation) 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 (*ContentMutation) OldUpdatedAt

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

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

func (m *ContentMutation) Op() Op

Op returns the operation name.

func (*ContentMutation) RemovedEdges

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

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

func (*ContentMutation) RemovedIDs

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

func (m *ContentMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*ContentMutation) ResetCreatedAt

func (m *ContentMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*ContentMutation) ResetEdge

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

func (m *ContentMutation) 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 (*ContentMutation) ResetUpdatedAt

func (m *ContentMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*ContentMutation) SetContent

func (m *ContentMutation) SetContent(s string)

SetContent sets the "content" field.

func (*ContentMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*ContentMutation) SetField

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

func (m *ContentMutation) SetID(id int32)

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

func (*ContentMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (ContentMutation) Tx

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

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

func (*ContentMutation) Type

func (m *ContentMutation) Type() string

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

func (*ContentMutation) UpdatedAt

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

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

func (*ContentMutation) Where

func (m *ContentMutation) Where(ps ...predicate.Content)

Where appends a list predicates to the ContentMutation builder.

type ContentQuery

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

ContentQuery is the builder for querying Content entities.

func (*ContentQuery) All

func (cq *ContentQuery) All(ctx context.Context) ([]*Content, error)

All executes the query and returns a list of Contents.

func (*ContentQuery) AllX

func (cq *ContentQuery) AllX(ctx context.Context) []*Content

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

func (*ContentQuery) Clone

func (cq *ContentQuery) Clone() *ContentQuery

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

func (*ContentQuery) Count

func (cq *ContentQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*ContentQuery) CountX

func (cq *ContentQuery) CountX(ctx context.Context) int

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

func (*ContentQuery) Exist

func (cq *ContentQuery) Exist(ctx context.Context) (bool, error)

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

func (*ContentQuery) ExistX

func (cq *ContentQuery) ExistX(ctx context.Context) bool

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

func (*ContentQuery) First

func (cq *ContentQuery) First(ctx context.Context) (*Content, error)

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

func (*ContentQuery) FirstID

func (cq *ContentQuery) FirstID(ctx context.Context) (id int32, err error)

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

func (*ContentQuery) FirstIDX

func (cq *ContentQuery) FirstIDX(ctx context.Context) int32

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

func (*ContentQuery) FirstX

func (cq *ContentQuery) FirstX(ctx context.Context) *Content

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

func (*ContentQuery) GroupBy

func (cq *ContentQuery) GroupBy(field string, fields ...string) *ContentGroupBy

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

client.Content.Query().
	GroupBy(content.FieldContent).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ContentQuery) IDs

func (cq *ContentQuery) IDs(ctx context.Context) ([]int32, error)

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

func (*ContentQuery) IDsX

func (cq *ContentQuery) IDsX(ctx context.Context) []int32

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

func (*ContentQuery) Limit

func (cq *ContentQuery) Limit(limit int) *ContentQuery

Limit adds a limit step to the query.

func (*ContentQuery) Offset

func (cq *ContentQuery) Offset(offset int) *ContentQuery

Offset adds an offset step to the query.

func (*ContentQuery) Only

func (cq *ContentQuery) Only(ctx context.Context) (*Content, error)

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

func (*ContentQuery) OnlyID

func (cq *ContentQuery) OnlyID(ctx context.Context) (id int32, err error)

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

func (*ContentQuery) OnlyIDX

func (cq *ContentQuery) OnlyIDX(ctx context.Context) int32

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

func (*ContentQuery) OnlyX

func (cq *ContentQuery) OnlyX(ctx context.Context) *Content

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

func (*ContentQuery) Order

func (cq *ContentQuery) Order(o ...OrderFunc) *ContentQuery

Order adds an order step to the query.

func (*ContentQuery) Select

func (cq *ContentQuery) Select(fields ...string) *ContentSelect

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

client.Content.Query().
	Select(content.FieldContent).
	Scan(ctx, &v)

func (*ContentQuery) Unique

func (cq *ContentQuery) Unique(unique bool) *ContentQuery

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

func (cq *ContentQuery) Where(ps ...predicate.Content) *ContentQuery

Where adds a new predicate for the ContentQuery builder.

type ContentSelect

type ContentSelect struct {
	*ContentQuery
	// contains filtered or unexported fields
}

ContentSelect is the builder for selecting fields of Content entities.

func (*ContentSelect) Bool

func (cs *ContentSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*ContentSelect) BoolX

func (cs *ContentSelect) BoolX(ctx context.Context) bool

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

func (*ContentSelect) Bools

func (cs *ContentSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*ContentSelect) BoolsX

func (cs *ContentSelect) BoolsX(ctx context.Context) []bool

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

func (*ContentSelect) Float64

func (cs *ContentSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*ContentSelect) Float64X

func (cs *ContentSelect) Float64X(ctx context.Context) float64

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

func (*ContentSelect) Float64s

func (cs *ContentSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*ContentSelect) Float64sX

func (cs *ContentSelect) Float64sX(ctx context.Context) []float64

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

func (*ContentSelect) Int

func (cs *ContentSelect) Int(ctx context.Context) (_ int, err error)

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

func (*ContentSelect) IntX

func (cs *ContentSelect) IntX(ctx context.Context) int

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

func (*ContentSelect) Ints

func (cs *ContentSelect) Ints(ctx context.Context) ([]int, error)

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

func (*ContentSelect) IntsX

func (cs *ContentSelect) IntsX(ctx context.Context) []int

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

func (*ContentSelect) Scan

func (cs *ContentSelect) Scan(ctx context.Context, v interface{}) error

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

func (*ContentSelect) ScanX

func (cs *ContentSelect) ScanX(ctx context.Context, v interface{})

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

func (*ContentSelect) String

func (cs *ContentSelect) String(ctx context.Context) (_ string, err error)

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

func (*ContentSelect) StringX

func (cs *ContentSelect) StringX(ctx context.Context) string

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

func (*ContentSelect) Strings

func (cs *ContentSelect) Strings(ctx context.Context) ([]string, error)

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

func (*ContentSelect) StringsX

func (cs *ContentSelect) StringsX(ctx context.Context) []string

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

type ContentUpdate

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

ContentUpdate is the builder for updating Content entities.

func (*ContentUpdate) Exec

func (cu *ContentUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*ContentUpdate) ExecX

func (cu *ContentUpdate) ExecX(ctx context.Context)

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

func (*ContentUpdate) Mutation

func (cu *ContentUpdate) Mutation() *ContentMutation

Mutation returns the ContentMutation object of the builder.

func (*ContentUpdate) Save

func (cu *ContentUpdate) Save(ctx context.Context) (int, error)

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

func (*ContentUpdate) SaveX

func (cu *ContentUpdate) SaveX(ctx context.Context) int

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

func (*ContentUpdate) SetContent

func (cu *ContentUpdate) SetContent(s string) *ContentUpdate

SetContent sets the "content" field.

func (*ContentUpdate) SetCreatedAt

func (cu *ContentUpdate) SetCreatedAt(t time.Time) *ContentUpdate

SetCreatedAt sets the "created_at" field.

func (*ContentUpdate) SetNillableCreatedAt

func (cu *ContentUpdate) SetNillableCreatedAt(t *time.Time) *ContentUpdate

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

func (*ContentUpdate) SetNillableUpdatedAt

func (cu *ContentUpdate) SetNillableUpdatedAt(t *time.Time) *ContentUpdate

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

func (*ContentUpdate) SetUpdatedAt

func (cu *ContentUpdate) SetUpdatedAt(t time.Time) *ContentUpdate

SetUpdatedAt sets the "updated_at" field.

func (*ContentUpdate) Where

func (cu *ContentUpdate) Where(ps ...predicate.Content) *ContentUpdate

Where appends a list predicates to the ContentUpdate builder.

type ContentUpdateOne

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

ContentUpdateOne is the builder for updating a single Content entity.

func (*ContentUpdateOne) Exec

func (cuo *ContentUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*ContentUpdateOne) ExecX

func (cuo *ContentUpdateOne) ExecX(ctx context.Context)

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

func (*ContentUpdateOne) Mutation

func (cuo *ContentUpdateOne) Mutation() *ContentMutation

Mutation returns the ContentMutation object of the builder.

func (*ContentUpdateOne) Save

func (cuo *ContentUpdateOne) Save(ctx context.Context) (*Content, error)

Save executes the query and returns the updated Content entity.

func (*ContentUpdateOne) SaveX

func (cuo *ContentUpdateOne) SaveX(ctx context.Context) *Content

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

func (*ContentUpdateOne) Select

func (cuo *ContentUpdateOne) Select(field string, fields ...string) *ContentUpdateOne

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

func (*ContentUpdateOne) SetContent

func (cuo *ContentUpdateOne) SetContent(s string) *ContentUpdateOne

SetContent sets the "content" field.

func (*ContentUpdateOne) SetCreatedAt

func (cuo *ContentUpdateOne) SetCreatedAt(t time.Time) *ContentUpdateOne

SetCreatedAt sets the "created_at" field.

func (*ContentUpdateOne) SetNillableCreatedAt

func (cuo *ContentUpdateOne) SetNillableCreatedAt(t *time.Time) *ContentUpdateOne

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

func (*ContentUpdateOne) SetNillableUpdatedAt

func (cuo *ContentUpdateOne) SetNillableUpdatedAt(t *time.Time) *ContentUpdateOne

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

func (*ContentUpdateOne) SetUpdatedAt

func (cuo *ContentUpdateOne) SetUpdatedAt(t time.Time) *ContentUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Contents

type Contents []*Content

Contents is a parsable slice of Content.

type Hook

type Hook = ent.Hook

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

type Index

type Index struct {

	// ID of the ent.
	ID int32 `json:"id,omitempty"`
	// ContentID holds the value of the "content_id" field.
	ContentID int32 `json:"content_id,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Desc holds the value of the "desc" field.
	Desc string `json:"desc,omitempty"`
	// Attr holds the value of the "attr" field.
	Attr int32 `json:"attr,omitempty"`
	// View holds the value of the "view" field.
	View int32 `json:"view,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"`
	// State holds the value of the "state" field.
	State int8 `json:"state,omitempty"`
	// contains filtered or unexported fields
}

Index is the model entity for the Index schema.

func (*Index) String

func (i *Index) String() string

String implements the fmt.Stringer.

func (*Index) Unwrap

func (i *Index) Unwrap() *Index

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

func (i *Index) Update() *IndexUpdateOne

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

type IndexClient

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

IndexClient is a client for the Index schema.

func NewIndexClient

func NewIndexClient(c config) *IndexClient

NewIndexClient returns a client for the Index from the given config.

func (*IndexClient) Create

func (c *IndexClient) Create() *IndexCreate

Create returns a create builder for Index.

func (*IndexClient) CreateBulk

func (c *IndexClient) CreateBulk(builders ...*IndexCreate) *IndexCreateBulk

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

func (*IndexClient) Delete

func (c *IndexClient) Delete() *IndexDelete

Delete returns a delete builder for Index.

func (*IndexClient) DeleteOne

func (c *IndexClient) DeleteOne(i *Index) *IndexDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*IndexClient) DeleteOneID

func (c *IndexClient) DeleteOneID(id int32) *IndexDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*IndexClient) Get

func (c *IndexClient) Get(ctx context.Context, id int32) (*Index, error)

Get returns a Index entity by its id.

func (*IndexClient) GetX

func (c *IndexClient) GetX(ctx context.Context, id int32) *Index

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

func (*IndexClient) Hooks

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

Hooks returns the client hooks.

func (*IndexClient) Query

func (c *IndexClient) Query() *IndexQuery

Query returns a query builder for Index.

func (*IndexClient) Update

func (c *IndexClient) Update() *IndexUpdate

Update returns an update builder for Index.

func (*IndexClient) UpdateOne

func (c *IndexClient) UpdateOne(i *Index) *IndexUpdateOne

UpdateOne returns an update builder for the given entity.

func (*IndexClient) UpdateOneID

func (c *IndexClient) UpdateOneID(id int32) *IndexUpdateOne

UpdateOneID returns an update builder for the given id.

func (*IndexClient) Use

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

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

type IndexCreate

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

IndexCreate is the builder for creating a Index entity.

func (*IndexCreate) Exec

func (ic *IndexCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*IndexCreate) ExecX

func (ic *IndexCreate) ExecX(ctx context.Context)

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

func (*IndexCreate) Mutation

func (ic *IndexCreate) Mutation() *IndexMutation

Mutation returns the IndexMutation object of the builder.

func (*IndexCreate) Save

func (ic *IndexCreate) Save(ctx context.Context) (*Index, error)

Save creates the Index in the database.

func (*IndexCreate) SaveX

func (ic *IndexCreate) SaveX(ctx context.Context) *Index

SaveX calls Save and panics if Save returns an error.

func (*IndexCreate) SetAttr

func (ic *IndexCreate) SetAttr(i int32) *IndexCreate

SetAttr sets the "attr" field.

func (*IndexCreate) SetContentID

func (ic *IndexCreate) SetContentID(i int32) *IndexCreate

SetContentID sets the "content_id" field.

func (*IndexCreate) SetCreatedAt

func (ic *IndexCreate) SetCreatedAt(t time.Time) *IndexCreate

SetCreatedAt sets the "created_at" field.

func (*IndexCreate) SetDesc

func (ic *IndexCreate) SetDesc(s string) *IndexCreate

SetDesc sets the "desc" field.

func (*IndexCreate) SetID

func (ic *IndexCreate) SetID(i int32) *IndexCreate

SetID sets the "id" field.

func (*IndexCreate) SetNillableAttr

func (ic *IndexCreate) SetNillableAttr(i *int32) *IndexCreate

SetNillableAttr sets the "attr" field if the given value is not nil.

func (*IndexCreate) SetNillableCreatedAt

func (ic *IndexCreate) SetNillableCreatedAt(t *time.Time) *IndexCreate

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

func (*IndexCreate) SetNillableState

func (ic *IndexCreate) SetNillableState(i *int8) *IndexCreate

SetNillableState sets the "state" field if the given value is not nil.

func (*IndexCreate) SetNillableUpdatedAt

func (ic *IndexCreate) SetNillableUpdatedAt(t *time.Time) *IndexCreate

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

func (*IndexCreate) SetNillableView

func (ic *IndexCreate) SetNillableView(i *int32) *IndexCreate

SetNillableView sets the "view" field if the given value is not nil.

func (*IndexCreate) SetState

func (ic *IndexCreate) SetState(i int8) *IndexCreate

SetState sets the "state" field.

func (*IndexCreate) SetTitle

func (ic *IndexCreate) SetTitle(s string) *IndexCreate

SetTitle sets the "title" field.

func (*IndexCreate) SetUpdatedAt

func (ic *IndexCreate) SetUpdatedAt(t time.Time) *IndexCreate

SetUpdatedAt sets the "updated_at" field.

func (*IndexCreate) SetView

func (ic *IndexCreate) SetView(i int32) *IndexCreate

SetView sets the "view" field.

type IndexCreateBulk

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

IndexCreateBulk is the builder for creating many Index entities in bulk.

func (*IndexCreateBulk) Exec

func (icb *IndexCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*IndexCreateBulk) ExecX

func (icb *IndexCreateBulk) ExecX(ctx context.Context)

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

func (*IndexCreateBulk) Save

func (icb *IndexCreateBulk) Save(ctx context.Context) ([]*Index, error)

Save creates the Index entities in the database.

func (*IndexCreateBulk) SaveX

func (icb *IndexCreateBulk) SaveX(ctx context.Context) []*Index

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

type IndexDelete

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

IndexDelete is the builder for deleting a Index entity.

func (*IndexDelete) Exec

func (id *IndexDelete) Exec(ctx context.Context) (int, error)

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

func (*IndexDelete) ExecX

func (id *IndexDelete) ExecX(ctx context.Context) int

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

func (*IndexDelete) Where

func (id *IndexDelete) Where(ps ...predicate.Index) *IndexDelete

Where appends a list predicates to the IndexDelete builder.

type IndexDeleteOne

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

IndexDeleteOne is the builder for deleting a single Index entity.

func (*IndexDeleteOne) Exec

func (ido *IndexDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*IndexDeleteOne) ExecX

func (ido *IndexDeleteOne) ExecX(ctx context.Context)

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

type IndexGroupBy

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

IndexGroupBy is the group-by builder for Index entities.

func (*IndexGroupBy) Aggregate

func (igb *IndexGroupBy) Aggregate(fns ...AggregateFunc) *IndexGroupBy

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

func (*IndexGroupBy) Bool

func (igb *IndexGroupBy) 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 (*IndexGroupBy) BoolX

func (igb *IndexGroupBy) BoolX(ctx context.Context) bool

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

func (*IndexGroupBy) Bools

func (igb *IndexGroupBy) 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 (*IndexGroupBy) BoolsX

func (igb *IndexGroupBy) BoolsX(ctx context.Context) []bool

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

func (*IndexGroupBy) Float64

func (igb *IndexGroupBy) 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 (*IndexGroupBy) Float64X

func (igb *IndexGroupBy) Float64X(ctx context.Context) float64

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

func (*IndexGroupBy) Float64s

func (igb *IndexGroupBy) 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 (*IndexGroupBy) Float64sX

func (igb *IndexGroupBy) Float64sX(ctx context.Context) []float64

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

func (*IndexGroupBy) Int

func (igb *IndexGroupBy) 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 (*IndexGroupBy) IntX

func (igb *IndexGroupBy) IntX(ctx context.Context) int

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

func (*IndexGroupBy) Ints

func (igb *IndexGroupBy) 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 (*IndexGroupBy) IntsX

func (igb *IndexGroupBy) IntsX(ctx context.Context) []int

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

func (*IndexGroupBy) Scan

func (igb *IndexGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*IndexGroupBy) ScanX

func (igb *IndexGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*IndexGroupBy) String

func (igb *IndexGroupBy) 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 (*IndexGroupBy) StringX

func (igb *IndexGroupBy) StringX(ctx context.Context) string

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

func (*IndexGroupBy) Strings

func (igb *IndexGroupBy) 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 (*IndexGroupBy) StringsX

func (igb *IndexGroupBy) StringsX(ctx context.Context) []string

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

type IndexMutation

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

IndexMutation represents an operation that mutates the Index nodes in the graph.

func (*IndexMutation) AddAttr

func (m *IndexMutation) AddAttr(i int32)

AddAttr adds i to the "attr" field.

func (*IndexMutation) AddContentID

func (m *IndexMutation) AddContentID(i int32)

AddContentID adds i to the "content_id" field.

func (*IndexMutation) AddField

func (m *IndexMutation) 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 (*IndexMutation) AddState

func (m *IndexMutation) AddState(i int8)

AddState adds i to the "state" field.

func (*IndexMutation) AddView

func (m *IndexMutation) AddView(i int32)

AddView adds i to the "view" field.

func (*IndexMutation) AddedAttr

func (m *IndexMutation) AddedAttr() (r int32, exists bool)

AddedAttr returns the value that was added to the "attr" field in this mutation.

func (*IndexMutation) AddedContentID

func (m *IndexMutation) AddedContentID() (r int32, exists bool)

AddedContentID returns the value that was added to the "content_id" field in this mutation.

func (*IndexMutation) AddedEdges

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

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

func (*IndexMutation) AddedField

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

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

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

func (*IndexMutation) AddedIDs

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

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

func (*IndexMutation) AddedState

func (m *IndexMutation) AddedState() (r int8, exists bool)

AddedState returns the value that was added to the "state" field in this mutation.

func (*IndexMutation) AddedView

func (m *IndexMutation) AddedView() (r int32, exists bool)

AddedView returns the value that was added to the "view" field in this mutation.

func (*IndexMutation) Attr

func (m *IndexMutation) Attr() (r int32, exists bool)

Attr returns the value of the "attr" field in the mutation.

func (*IndexMutation) ClearEdge

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

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

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

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

func (*IndexMutation) ClearedFields

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

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

func (IndexMutation) Client

func (m IndexMutation) 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 (*IndexMutation) ContentID

func (m *IndexMutation) ContentID() (r int32, exists bool)

ContentID returns the value of the "content_id" field in the mutation.

func (*IndexMutation) CreatedAt

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

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

func (*IndexMutation) Desc

func (m *IndexMutation) Desc() (r string, exists bool)

Desc returns the value of the "desc" field in the mutation.

func (*IndexMutation) EdgeCleared

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

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

func (*IndexMutation) Field

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

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

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

func (*IndexMutation) Fields

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

func (m *IndexMutation) ID() (id int32, 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 (*IndexMutation) OldAttr

func (m *IndexMutation) OldAttr(ctx context.Context) (v int32, err error)

OldAttr returns the old "attr" field's value of the Index entity. If the Index 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 (*IndexMutation) OldContentID

func (m *IndexMutation) OldContentID(ctx context.Context) (v int32, err error)

OldContentID returns the old "content_id" field's value of the Index entity. If the Index 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 (*IndexMutation) OldCreatedAt

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

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

func (m *IndexMutation) OldDesc(ctx context.Context) (v string, err error)

OldDesc returns the old "desc" field's value of the Index entity. If the Index 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 (*IndexMutation) OldField

func (m *IndexMutation) 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 (*IndexMutation) OldState

func (m *IndexMutation) OldState(ctx context.Context) (v int8, err error)

OldState returns the old "state" field's value of the Index entity. If the Index 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 (*IndexMutation) OldTitle

func (m *IndexMutation) OldTitle(ctx context.Context) (v string, err error)

OldTitle returns the old "title" field's value of the Index entity. If the Index 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 (*IndexMutation) OldUpdatedAt

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

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

func (m *IndexMutation) OldView(ctx context.Context) (v int32, err error)

OldView returns the old "view" field's value of the Index entity. If the Index 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 (*IndexMutation) Op

func (m *IndexMutation) Op() Op

Op returns the operation name.

func (*IndexMutation) RemovedEdges

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

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

func (*IndexMutation) RemovedIDs

func (m *IndexMutation) 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 (*IndexMutation) ResetAttr

func (m *IndexMutation) ResetAttr()

ResetAttr resets all changes to the "attr" field.

func (*IndexMutation) ResetContentID

func (m *IndexMutation) ResetContentID()

ResetContentID resets all changes to the "content_id" field.

func (*IndexMutation) ResetCreatedAt

func (m *IndexMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*IndexMutation) ResetDesc

func (m *IndexMutation) ResetDesc()

ResetDesc resets all changes to the "desc" field.

func (*IndexMutation) ResetEdge

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

func (m *IndexMutation) 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 (*IndexMutation) ResetState

func (m *IndexMutation) ResetState()

ResetState resets all changes to the "state" field.

func (*IndexMutation) ResetTitle

func (m *IndexMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*IndexMutation) ResetUpdatedAt

func (m *IndexMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*IndexMutation) ResetView

func (m *IndexMutation) ResetView()

ResetView resets all changes to the "view" field.

func (*IndexMutation) SetAttr

func (m *IndexMutation) SetAttr(i int32)

SetAttr sets the "attr" field.

func (*IndexMutation) SetContentID

func (m *IndexMutation) SetContentID(i int32)

SetContentID sets the "content_id" field.

func (*IndexMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*IndexMutation) SetDesc

func (m *IndexMutation) SetDesc(s string)

SetDesc sets the "desc" field.

func (*IndexMutation) SetField

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

func (m *IndexMutation) SetID(id int32)

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

func (*IndexMutation) SetState

func (m *IndexMutation) SetState(i int8)

SetState sets the "state" field.

func (*IndexMutation) SetTitle

func (m *IndexMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*IndexMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*IndexMutation) SetView

func (m *IndexMutation) SetView(i int32)

SetView sets the "view" field.

func (*IndexMutation) State

func (m *IndexMutation) State() (r int8, exists bool)

State returns the value of the "state" field in the mutation.

func (*IndexMutation) Title

func (m *IndexMutation) Title() (r string, exists bool)

Title returns the value of the "title" field in the mutation.

func (IndexMutation) Tx

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

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

func (*IndexMutation) Type

func (m *IndexMutation) Type() string

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

func (*IndexMutation) UpdatedAt

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

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

func (*IndexMutation) View

func (m *IndexMutation) View() (r int32, exists bool)

View returns the value of the "view" field in the mutation.

func (*IndexMutation) Where

func (m *IndexMutation) Where(ps ...predicate.Index)

Where appends a list predicates to the IndexMutation builder.

type IndexQuery

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

IndexQuery is the builder for querying Index entities.

func (*IndexQuery) All

func (iq *IndexQuery) All(ctx context.Context) ([]*Index, error)

All executes the query and returns a list of Indexes.

func (*IndexQuery) AllX

func (iq *IndexQuery) AllX(ctx context.Context) []*Index

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

func (*IndexQuery) Clone

func (iq *IndexQuery) Clone() *IndexQuery

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

func (*IndexQuery) Count

func (iq *IndexQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*IndexQuery) CountX

func (iq *IndexQuery) CountX(ctx context.Context) int

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

func (*IndexQuery) Exist

func (iq *IndexQuery) Exist(ctx context.Context) (bool, error)

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

func (*IndexQuery) ExistX

func (iq *IndexQuery) ExistX(ctx context.Context) bool

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

func (*IndexQuery) First

func (iq *IndexQuery) First(ctx context.Context) (*Index, error)

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

func (*IndexQuery) FirstID

func (iq *IndexQuery) FirstID(ctx context.Context) (id int32, err error)

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

func (*IndexQuery) FirstIDX

func (iq *IndexQuery) FirstIDX(ctx context.Context) int32

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

func (*IndexQuery) FirstX

func (iq *IndexQuery) FirstX(ctx context.Context) *Index

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

func (*IndexQuery) GroupBy

func (iq *IndexQuery) GroupBy(field string, fields ...string) *IndexGroupBy

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 {
	ContentID int32 `json:"content_id,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Index.Query().
	GroupBy(index.FieldContentID).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*IndexQuery) IDs

func (iq *IndexQuery) IDs(ctx context.Context) ([]int32, error)

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

func (*IndexQuery) IDsX

func (iq *IndexQuery) IDsX(ctx context.Context) []int32

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

func (*IndexQuery) Limit

func (iq *IndexQuery) Limit(limit int) *IndexQuery

Limit adds a limit step to the query.

func (*IndexQuery) Offset

func (iq *IndexQuery) Offset(offset int) *IndexQuery

Offset adds an offset step to the query.

func (*IndexQuery) Only

func (iq *IndexQuery) Only(ctx context.Context) (*Index, error)

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

func (*IndexQuery) OnlyID

func (iq *IndexQuery) OnlyID(ctx context.Context) (id int32, err error)

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

func (*IndexQuery) OnlyIDX

func (iq *IndexQuery) OnlyIDX(ctx context.Context) int32

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

func (*IndexQuery) OnlyX

func (iq *IndexQuery) OnlyX(ctx context.Context) *Index

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

func (*IndexQuery) Order

func (iq *IndexQuery) Order(o ...OrderFunc) *IndexQuery

Order adds an order step to the query.

func (*IndexQuery) Select

func (iq *IndexQuery) Select(fields ...string) *IndexSelect

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 {
	ContentID int32 `json:"content_id,omitempty"`
}

client.Index.Query().
	Select(index.FieldContentID).
	Scan(ctx, &v)

func (*IndexQuery) Unique

func (iq *IndexQuery) Unique(unique bool) *IndexQuery

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

func (iq *IndexQuery) Where(ps ...predicate.Index) *IndexQuery

Where adds a new predicate for the IndexQuery builder.

type IndexSelect

type IndexSelect struct {
	*IndexQuery
	// contains filtered or unexported fields
}

IndexSelect is the builder for selecting fields of Index entities.

func (*IndexSelect) Bool

func (is *IndexSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*IndexSelect) BoolX

func (is *IndexSelect) BoolX(ctx context.Context) bool

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

func (*IndexSelect) Bools

func (is *IndexSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*IndexSelect) BoolsX

func (is *IndexSelect) BoolsX(ctx context.Context) []bool

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

func (*IndexSelect) Float64

func (is *IndexSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*IndexSelect) Float64X

func (is *IndexSelect) Float64X(ctx context.Context) float64

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

func (*IndexSelect) Float64s

func (is *IndexSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*IndexSelect) Float64sX

func (is *IndexSelect) Float64sX(ctx context.Context) []float64

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

func (*IndexSelect) Int

func (is *IndexSelect) Int(ctx context.Context) (_ int, err error)

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

func (*IndexSelect) IntX

func (is *IndexSelect) IntX(ctx context.Context) int

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

func (*IndexSelect) Ints

func (is *IndexSelect) Ints(ctx context.Context) ([]int, error)

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

func (*IndexSelect) IntsX

func (is *IndexSelect) IntsX(ctx context.Context) []int

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

func (*IndexSelect) Scan

func (is *IndexSelect) Scan(ctx context.Context, v interface{}) error

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

func (*IndexSelect) ScanX

func (is *IndexSelect) ScanX(ctx context.Context, v interface{})

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

func (*IndexSelect) String

func (is *IndexSelect) String(ctx context.Context) (_ string, err error)

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

func (*IndexSelect) StringX

func (is *IndexSelect) StringX(ctx context.Context) string

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

func (*IndexSelect) Strings

func (is *IndexSelect) Strings(ctx context.Context) ([]string, error)

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

func (*IndexSelect) StringsX

func (is *IndexSelect) StringsX(ctx context.Context) []string

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

type IndexUpdate

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

IndexUpdate is the builder for updating Index entities.

func (*IndexUpdate) AddAttr

func (iu *IndexUpdate) AddAttr(i int32) *IndexUpdate

AddAttr adds i to the "attr" field.

func (*IndexUpdate) AddContentID

func (iu *IndexUpdate) AddContentID(i int32) *IndexUpdate

AddContentID adds i to the "content_id" field.

func (*IndexUpdate) AddState

func (iu *IndexUpdate) AddState(i int8) *IndexUpdate

AddState adds i to the "state" field.

func (*IndexUpdate) AddView

func (iu *IndexUpdate) AddView(i int32) *IndexUpdate

AddView adds i to the "view" field.

func (*IndexUpdate) Exec

func (iu *IndexUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*IndexUpdate) ExecX

func (iu *IndexUpdate) ExecX(ctx context.Context)

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

func (*IndexUpdate) Mutation

func (iu *IndexUpdate) Mutation() *IndexMutation

Mutation returns the IndexMutation object of the builder.

func (*IndexUpdate) Save

func (iu *IndexUpdate) Save(ctx context.Context) (int, error)

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

func (*IndexUpdate) SaveX

func (iu *IndexUpdate) SaveX(ctx context.Context) int

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

func (*IndexUpdate) SetAttr

func (iu *IndexUpdate) SetAttr(i int32) *IndexUpdate

SetAttr sets the "attr" field.

func (*IndexUpdate) SetContentID

func (iu *IndexUpdate) SetContentID(i int32) *IndexUpdate

SetContentID sets the "content_id" field.

func (*IndexUpdate) SetDesc

func (iu *IndexUpdate) SetDesc(s string) *IndexUpdate

SetDesc sets the "desc" field.

func (*IndexUpdate) SetNillableAttr

func (iu *IndexUpdate) SetNillableAttr(i *int32) *IndexUpdate

SetNillableAttr sets the "attr" field if the given value is not nil.

func (*IndexUpdate) SetNillableState

func (iu *IndexUpdate) SetNillableState(i *int8) *IndexUpdate

SetNillableState sets the "state" field if the given value is not nil.

func (*IndexUpdate) SetNillableUpdatedAt

func (iu *IndexUpdate) SetNillableUpdatedAt(t *time.Time) *IndexUpdate

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

func (*IndexUpdate) SetNillableView

func (iu *IndexUpdate) SetNillableView(i *int32) *IndexUpdate

SetNillableView sets the "view" field if the given value is not nil.

func (*IndexUpdate) SetState

func (iu *IndexUpdate) SetState(i int8) *IndexUpdate

SetState sets the "state" field.

func (*IndexUpdate) SetTitle

func (iu *IndexUpdate) SetTitle(s string) *IndexUpdate

SetTitle sets the "title" field.

func (*IndexUpdate) SetUpdatedAt

func (iu *IndexUpdate) SetUpdatedAt(t time.Time) *IndexUpdate

SetUpdatedAt sets the "updated_at" field.

func (*IndexUpdate) SetView

func (iu *IndexUpdate) SetView(i int32) *IndexUpdate

SetView sets the "view" field.

func (*IndexUpdate) Where

func (iu *IndexUpdate) Where(ps ...predicate.Index) *IndexUpdate

Where appends a list predicates to the IndexUpdate builder.

type IndexUpdateOne

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

IndexUpdateOne is the builder for updating a single Index entity.

func (*IndexUpdateOne) AddAttr

func (iuo *IndexUpdateOne) AddAttr(i int32) *IndexUpdateOne

AddAttr adds i to the "attr" field.

func (*IndexUpdateOne) AddContentID

func (iuo *IndexUpdateOne) AddContentID(i int32) *IndexUpdateOne

AddContentID adds i to the "content_id" field.

func (*IndexUpdateOne) AddState

func (iuo *IndexUpdateOne) AddState(i int8) *IndexUpdateOne

AddState adds i to the "state" field.

func (*IndexUpdateOne) AddView

func (iuo *IndexUpdateOne) AddView(i int32) *IndexUpdateOne

AddView adds i to the "view" field.

func (*IndexUpdateOne) Exec

func (iuo *IndexUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*IndexUpdateOne) ExecX

func (iuo *IndexUpdateOne) ExecX(ctx context.Context)

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

func (*IndexUpdateOne) Mutation

func (iuo *IndexUpdateOne) Mutation() *IndexMutation

Mutation returns the IndexMutation object of the builder.

func (*IndexUpdateOne) Save

func (iuo *IndexUpdateOne) Save(ctx context.Context) (*Index, error)

Save executes the query and returns the updated Index entity.

func (*IndexUpdateOne) SaveX

func (iuo *IndexUpdateOne) SaveX(ctx context.Context) *Index

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

func (*IndexUpdateOne) Select

func (iuo *IndexUpdateOne) Select(field string, fields ...string) *IndexUpdateOne

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

func (*IndexUpdateOne) SetAttr

func (iuo *IndexUpdateOne) SetAttr(i int32) *IndexUpdateOne

SetAttr sets the "attr" field.

func (*IndexUpdateOne) SetContentID

func (iuo *IndexUpdateOne) SetContentID(i int32) *IndexUpdateOne

SetContentID sets the "content_id" field.

func (*IndexUpdateOne) SetDesc

func (iuo *IndexUpdateOne) SetDesc(s string) *IndexUpdateOne

SetDesc sets the "desc" field.

func (*IndexUpdateOne) SetNillableAttr

func (iuo *IndexUpdateOne) SetNillableAttr(i *int32) *IndexUpdateOne

SetNillableAttr sets the "attr" field if the given value is not nil.

func (*IndexUpdateOne) SetNillableState

func (iuo *IndexUpdateOne) SetNillableState(i *int8) *IndexUpdateOne

SetNillableState sets the "state" field if the given value is not nil.

func (*IndexUpdateOne) SetNillableUpdatedAt

func (iuo *IndexUpdateOne) SetNillableUpdatedAt(t *time.Time) *IndexUpdateOne

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

func (*IndexUpdateOne) SetNillableView

func (iuo *IndexUpdateOne) SetNillableView(i *int32) *IndexUpdateOne

SetNillableView sets the "view" field if the given value is not nil.

func (*IndexUpdateOne) SetState

func (iuo *IndexUpdateOne) SetState(i int8) *IndexUpdateOne

SetState sets the "state" field.

func (*IndexUpdateOne) SetTitle

func (iuo *IndexUpdateOne) SetTitle(s string) *IndexUpdateOne

SetTitle sets the "title" field.

func (*IndexUpdateOne) SetUpdatedAt

func (iuo *IndexUpdateOne) SetUpdatedAt(t time.Time) *IndexUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*IndexUpdateOne) SetView

func (iuo *IndexUpdateOne) SetView(i int32) *IndexUpdateOne

SetView sets the "view" field.

type Indexes

type Indexes []*Index

Indexes is a parsable slice of Index.

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(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 Rollbacker method.

type Tx

type Tx struct {

	// Content is the client for interacting with the Content builders.
	Content *ContentClient
	// Index is the client for interacting with the Index builders.
	Index *IndexClient
	// 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 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