ent

package
v0.0.0-...-fc33bc3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: GPL-3.0 Imports: 22 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.
	TypeSentence = "Sentence"
	TypeStory    = "Story"
	TypeUser     = "User"
)

Variables

This section is empty.

Functions

func Asc

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

Asc applies the given fields in ASC order.

func Desc

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

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

GroupBy(field1, field2).
Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
Scan(ctx, &v)

func Count

func Count() AggregateFunc

Count applies the "count" aggregation function on each group.

func Max

func Max(field string) AggregateFunc

Max applies the "max" aggregation function on the given field of each group.

func Mean

func Mean(field string) AggregateFunc

Mean applies the "mean" aggregation function on the given field of each group.

func Min

func Min(field string) AggregateFunc

Min applies the "min" aggregation function on the given field of each group.

func Sum

func Sum(field string) AggregateFunc

Sum applies the "sum" aggregation function on the given field of each group.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Sentence is the client for interacting with the Sentence builders.
	Sentence *SentenceClient
	// Story is the client for interacting with the Story builders.
	Story *StoryClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// 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().
	Sentence.
	Query().
	Count(ctx)

func (*Client) Intercept

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

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

func (*Client) Mutate

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

Mutate implements the ent.Mutator interface.

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

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

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

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

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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

type Query

type Query = ent.Query

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

type QueryContext

type QueryContext = ent.QueryContext

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

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

Rollbacker is the interface that wraps the Rollback method.

type Sentence

type Sentence struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// Text holds the value of the "text" field.
	Text string `json:"text,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Order holds the value of the "order" field.
	Order int `json:"order,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the SentenceQuery when eager-loading is set.
	Edges SentenceEdges `json:"edges"`
	// contains filtered or unexported fields
}

Sentence is the model entity for the Sentence schema.

func (*Sentence) QueryAuthor

func (s *Sentence) QueryAuthor() *UserQuery

QueryAuthor queries the "author" edge of the Sentence entity.

func (*Sentence) QueryStory

func (s *Sentence) QueryStory() *StoryQuery

QueryStory queries the "story" edge of the Sentence entity.

func (*Sentence) String

func (s *Sentence) String() string

String implements the fmt.Stringer.

func (*Sentence) Unwrap

func (s *Sentence) Unwrap() *Sentence

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

func (s *Sentence) Update() *SentenceUpdateOne

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

func (*Sentence) Value

func (s *Sentence) Value(name string) (ent.Value, error)

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

type SentenceClient

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

SentenceClient is a client for the Sentence schema.

func NewSentenceClient

func NewSentenceClient(c config) *SentenceClient

NewSentenceClient returns a client for the Sentence from the given config.

func (*SentenceClient) Create

func (c *SentenceClient) Create() *SentenceCreate

Create returns a builder for creating a Sentence entity.

func (*SentenceClient) CreateBulk

func (c *SentenceClient) CreateBulk(builders ...*SentenceCreate) *SentenceCreateBulk

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

func (*SentenceClient) Delete

func (c *SentenceClient) Delete() *SentenceDelete

Delete returns a delete builder for Sentence.

func (*SentenceClient) DeleteOne

func (c *SentenceClient) DeleteOne(s *Sentence) *SentenceDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*SentenceClient) DeleteOneID

func (c *SentenceClient) DeleteOneID(id uuid.UUID) *SentenceDeleteOne

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

func (*SentenceClient) Get

func (c *SentenceClient) Get(ctx context.Context, id uuid.UUID) (*Sentence, error)

Get returns a Sentence entity by its id.

func (*SentenceClient) GetX

func (c *SentenceClient) GetX(ctx context.Context, id uuid.UUID) *Sentence

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

func (*SentenceClient) Hooks

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

Hooks returns the client hooks.

func (*SentenceClient) Intercept

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

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

func (*SentenceClient) Interceptors

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

Interceptors returns the client interceptors.

func (*SentenceClient) Query

func (c *SentenceClient) Query() *SentenceQuery

Query returns a query builder for Sentence.

func (*SentenceClient) QueryAuthor

func (c *SentenceClient) QueryAuthor(s *Sentence) *UserQuery

QueryAuthor queries the author edge of a Sentence.

func (*SentenceClient) QueryStory

func (c *SentenceClient) QueryStory(s *Sentence) *StoryQuery

QueryStory queries the story edge of a Sentence.

func (*SentenceClient) Update

func (c *SentenceClient) Update() *SentenceUpdate

Update returns an update builder for Sentence.

func (*SentenceClient) UpdateOne

func (c *SentenceClient) UpdateOne(s *Sentence) *SentenceUpdateOne

UpdateOne returns an update builder for the given entity.

func (*SentenceClient) UpdateOneID

func (c *SentenceClient) UpdateOneID(id uuid.UUID) *SentenceUpdateOne

UpdateOneID returns an update builder for the given id.

func (*SentenceClient) Use

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

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

type SentenceCreate

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

SentenceCreate is the builder for creating a Sentence entity.

func (*SentenceCreate) AddAuthor

func (sc *SentenceCreate) AddAuthor(u ...*User) *SentenceCreate

AddAuthor adds the "author" edges to the User entity.

func (*SentenceCreate) AddAuthorIDs

func (sc *SentenceCreate) AddAuthorIDs(ids ...uuid.UUID) *SentenceCreate

AddAuthorIDs adds the "author" edge to the User entity by IDs.

func (*SentenceCreate) Exec

func (sc *SentenceCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*SentenceCreate) ExecX

func (sc *SentenceCreate) ExecX(ctx context.Context)

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

func (*SentenceCreate) Mutation

func (sc *SentenceCreate) Mutation() *SentenceMutation

Mutation returns the SentenceMutation object of the builder.

func (*SentenceCreate) Save

func (sc *SentenceCreate) Save(ctx context.Context) (*Sentence, error)

Save creates the Sentence in the database.

func (*SentenceCreate) SaveX

func (sc *SentenceCreate) SaveX(ctx context.Context) *Sentence

SaveX calls Save and panics if Save returns an error.

func (*SentenceCreate) SetCreatedAt

func (sc *SentenceCreate) SetCreatedAt(t time.Time) *SentenceCreate

SetCreatedAt sets the "created_at" field.

func (*SentenceCreate) SetID

func (sc *SentenceCreate) SetID(u uuid.UUID) *SentenceCreate

SetID sets the "id" field.

func (*SentenceCreate) SetNillableCreatedAt

func (sc *SentenceCreate) SetNillableCreatedAt(t *time.Time) *SentenceCreate

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

func (*SentenceCreate) SetNillableID

func (sc *SentenceCreate) SetNillableID(u *uuid.UUID) *SentenceCreate

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

func (*SentenceCreate) SetOrder

func (sc *SentenceCreate) SetOrder(i int) *SentenceCreate

SetOrder sets the "order" field.

func (*SentenceCreate) SetStory

func (sc *SentenceCreate) SetStory(s *Story) *SentenceCreate

SetStory sets the "story" edge to the Story entity.

func (*SentenceCreate) SetStoryID

func (sc *SentenceCreate) SetStoryID(id uuid.UUID) *SentenceCreate

SetStoryID sets the "story" edge to the Story entity by ID.

func (*SentenceCreate) SetText

func (sc *SentenceCreate) SetText(s string) *SentenceCreate

SetText sets the "text" field.

type SentenceCreateBulk

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

SentenceCreateBulk is the builder for creating many Sentence entities in bulk.

func (*SentenceCreateBulk) Exec

func (scb *SentenceCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*SentenceCreateBulk) ExecX

func (scb *SentenceCreateBulk) ExecX(ctx context.Context)

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

func (*SentenceCreateBulk) Save

func (scb *SentenceCreateBulk) Save(ctx context.Context) ([]*Sentence, error)

Save creates the Sentence entities in the database.

func (*SentenceCreateBulk) SaveX

func (scb *SentenceCreateBulk) SaveX(ctx context.Context) []*Sentence

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

type SentenceDelete

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

SentenceDelete is the builder for deleting a Sentence entity.

func (*SentenceDelete) Exec

func (sd *SentenceDelete) Exec(ctx context.Context) (int, error)

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

func (*SentenceDelete) ExecX

func (sd *SentenceDelete) ExecX(ctx context.Context) int

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

func (*SentenceDelete) Where

func (sd *SentenceDelete) Where(ps ...predicate.Sentence) *SentenceDelete

Where appends a list predicates to the SentenceDelete builder.

type SentenceDeleteOne

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

SentenceDeleteOne is the builder for deleting a single Sentence entity.

func (*SentenceDeleteOne) Exec

func (sdo *SentenceDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*SentenceDeleteOne) ExecX

func (sdo *SentenceDeleteOne) ExecX(ctx context.Context)

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

func (*SentenceDeleteOne) Where

Where appends a list predicates to the SentenceDelete builder.

type SentenceEdges

type SentenceEdges struct {
	// Story holds the value of the story edge.
	Story *Story `json:"story,omitempty"`
	// Author holds the value of the author edge.
	Author []*User `json:"author,omitempty"`
	// contains filtered or unexported fields
}

SentenceEdges holds the relations/edges for other nodes in the graph.

func (SentenceEdges) AuthorOrErr

func (e SentenceEdges) AuthorOrErr() ([]*User, error)

AuthorOrErr returns the Author value or an error if the edge was not loaded in eager-loading.

func (SentenceEdges) StoryOrErr

func (e SentenceEdges) StoryOrErr() (*Story, error)

StoryOrErr returns the Story value or an error if the edge was not loaded in eager-loading, or loaded but was not found.

type SentenceGroupBy

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

SentenceGroupBy is the group-by builder for Sentence entities.

func (*SentenceGroupBy) Aggregate

func (sgb *SentenceGroupBy) Aggregate(fns ...AggregateFunc) *SentenceGroupBy

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

func (*SentenceGroupBy) Bool

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

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

func (*SentenceGroupBy) BoolX

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

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

func (*SentenceGroupBy) Bools

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

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

func (*SentenceGroupBy) BoolsX

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

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

func (*SentenceGroupBy) Float64

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

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

func (*SentenceGroupBy) Float64X

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

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

func (*SentenceGroupBy) Float64s

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

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

func (*SentenceGroupBy) Float64sX

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

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

func (*SentenceGroupBy) Int

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

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

func (*SentenceGroupBy) IntX

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

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

func (*SentenceGroupBy) Ints

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

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

func (*SentenceGroupBy) IntsX

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

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

func (*SentenceGroupBy) Scan

func (sgb *SentenceGroupBy) Scan(ctx context.Context, v any) error

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

func (*SentenceGroupBy) ScanX

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

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

func (*SentenceGroupBy) String

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

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

func (*SentenceGroupBy) StringX

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

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

func (*SentenceGroupBy) Strings

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

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

func (*SentenceGroupBy) StringsX

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

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

type SentenceMutation

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

SentenceMutation represents an operation that mutates the Sentence nodes in the graph.

func (*SentenceMutation) AddAuthorIDs

func (m *SentenceMutation) AddAuthorIDs(ids ...uuid.UUID)

AddAuthorIDs adds the "author" edge to the User entity by ids.

func (*SentenceMutation) AddField

func (m *SentenceMutation) 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 (*SentenceMutation) AddOrder

func (m *SentenceMutation) AddOrder(i int)

AddOrder adds i to the "order" field.

func (*SentenceMutation) AddedEdges

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

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

func (*SentenceMutation) AddedField

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

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

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

func (*SentenceMutation) AddedIDs

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

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

func (*SentenceMutation) AddedOrder

func (m *SentenceMutation) AddedOrder() (r int, exists bool)

AddedOrder returns the value that was added to the "order" field in this mutation.

func (*SentenceMutation) AuthorCleared

func (m *SentenceMutation) AuthorCleared() bool

AuthorCleared reports if the "author" edge to the User entity was cleared.

func (*SentenceMutation) AuthorIDs

func (m *SentenceMutation) AuthorIDs() (ids []uuid.UUID)

AuthorIDs returns the "author" edge IDs in the mutation.

func (*SentenceMutation) ClearAuthor

func (m *SentenceMutation) ClearAuthor()

ClearAuthor clears the "author" edge to the User entity.

func (*SentenceMutation) ClearEdge

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

func (m *SentenceMutation) 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 (*SentenceMutation) ClearStory

func (m *SentenceMutation) ClearStory()

ClearStory clears the "story" edge to the Story entity.

func (*SentenceMutation) ClearedEdges

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

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

func (*SentenceMutation) ClearedFields

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

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

func (SentenceMutation) Client

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

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

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

func (*SentenceMutation) EdgeCleared

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

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

func (*SentenceMutation) Field

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

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

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

func (*SentenceMutation) Fields

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

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

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

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

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

func (m *SentenceMutation) 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 (*SentenceMutation) OldOrder

func (m *SentenceMutation) OldOrder(ctx context.Context) (v int, err error)

OldOrder returns the old "order" field's value of the Sentence entity. If the Sentence 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 (*SentenceMutation) OldText

func (m *SentenceMutation) OldText(ctx context.Context) (v string, err error)

OldText returns the old "text" field's value of the Sentence entity. If the Sentence 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 (*SentenceMutation) Op

func (m *SentenceMutation) Op() Op

Op returns the operation name.

func (*SentenceMutation) Order

func (m *SentenceMutation) Order() (r int, exists bool)

Order returns the value of the "order" field in the mutation.

func (*SentenceMutation) RemoveAuthorIDs

func (m *SentenceMutation) RemoveAuthorIDs(ids ...uuid.UUID)

RemoveAuthorIDs removes the "author" edge to the User entity by IDs.

func (*SentenceMutation) RemovedAuthorIDs

func (m *SentenceMutation) RemovedAuthorIDs() (ids []uuid.UUID)

RemovedAuthor returns the removed IDs of the "author" edge to the User entity.

func (*SentenceMutation) RemovedEdges

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

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

func (*SentenceMutation) RemovedIDs

func (m *SentenceMutation) 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 (*SentenceMutation) ResetAuthor

func (m *SentenceMutation) ResetAuthor()

ResetAuthor resets all changes to the "author" edge.

func (*SentenceMutation) ResetCreatedAt

func (m *SentenceMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*SentenceMutation) ResetEdge

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

func (m *SentenceMutation) 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 (*SentenceMutation) ResetOrder

func (m *SentenceMutation) ResetOrder()

ResetOrder resets all changes to the "order" field.

func (*SentenceMutation) ResetStory

func (m *SentenceMutation) ResetStory()

ResetStory resets all changes to the "story" edge.

func (*SentenceMutation) ResetText

func (m *SentenceMutation) ResetText()

ResetText resets all changes to the "text" field.

func (*SentenceMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*SentenceMutation) SetField

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

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

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

func (*SentenceMutation) SetOp

func (m *SentenceMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*SentenceMutation) SetOrder

func (m *SentenceMutation) SetOrder(i int)

SetOrder sets the "order" field.

func (*SentenceMutation) SetStoryID

func (m *SentenceMutation) SetStoryID(id uuid.UUID)

SetStoryID sets the "story" edge to the Story entity by id.

func (*SentenceMutation) SetText

func (m *SentenceMutation) SetText(s string)

SetText sets the "text" field.

func (*SentenceMutation) StoryCleared

func (m *SentenceMutation) StoryCleared() bool

StoryCleared reports if the "story" edge to the Story entity was cleared.

func (*SentenceMutation) StoryID

func (m *SentenceMutation) StoryID() (id uuid.UUID, exists bool)

StoryID returns the "story" edge ID in the mutation.

func (*SentenceMutation) StoryIDs

func (m *SentenceMutation) StoryIDs() (ids []uuid.UUID)

StoryIDs returns the "story" edge IDs in the mutation. Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use StoryID instead. It exists only for internal usage by the builders.

func (*SentenceMutation) Text

func (m *SentenceMutation) Text() (r string, exists bool)

Text returns the value of the "text" field in the mutation.

func (SentenceMutation) Tx

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

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

func (*SentenceMutation) Type

func (m *SentenceMutation) Type() string

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

func (*SentenceMutation) Where

func (m *SentenceMutation) Where(ps ...predicate.Sentence)

Where appends a list predicates to the SentenceMutation builder.

func (*SentenceMutation) WhereP

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

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

type SentenceQuery

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

SentenceQuery is the builder for querying Sentence entities.

func (*SentenceQuery) Aggregate

func (sq *SentenceQuery) Aggregate(fns ...AggregateFunc) *SentenceSelect

Aggregate returns a SentenceSelect configured with the given aggregations.

func (*SentenceQuery) All

func (sq *SentenceQuery) All(ctx context.Context) ([]*Sentence, error)

All executes the query and returns a list of Sentences.

func (*SentenceQuery) AllX

func (sq *SentenceQuery) AllX(ctx context.Context) []*Sentence

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

func (*SentenceQuery) Clone

func (sq *SentenceQuery) Clone() *SentenceQuery

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

func (*SentenceQuery) Count

func (sq *SentenceQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*SentenceQuery) CountX

func (sq *SentenceQuery) CountX(ctx context.Context) int

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

func (*SentenceQuery) Exist

func (sq *SentenceQuery) Exist(ctx context.Context) (bool, error)

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

func (*SentenceQuery) ExistX

func (sq *SentenceQuery) ExistX(ctx context.Context) bool

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

func (*SentenceQuery) First

func (sq *SentenceQuery) First(ctx context.Context) (*Sentence, error)

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

func (*SentenceQuery) FirstID

func (sq *SentenceQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*SentenceQuery) FirstIDX

func (sq *SentenceQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*SentenceQuery) FirstX

func (sq *SentenceQuery) FirstX(ctx context.Context) *Sentence

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

func (*SentenceQuery) GroupBy

func (sq *SentenceQuery) GroupBy(field string, fields ...string) *SentenceGroupBy

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

client.Sentence.Query().
	GroupBy(sentence.FieldText).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*SentenceQuery) IDs

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

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

func (*SentenceQuery) IDsX

func (sq *SentenceQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*SentenceQuery) Limit

func (sq *SentenceQuery) Limit(limit int) *SentenceQuery

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

func (*SentenceQuery) Offset

func (sq *SentenceQuery) Offset(offset int) *SentenceQuery

Offset to start from.

func (*SentenceQuery) Only

func (sq *SentenceQuery) Only(ctx context.Context) (*Sentence, error)

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

func (*SentenceQuery) OnlyID

func (sq *SentenceQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*SentenceQuery) OnlyIDX

func (sq *SentenceQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*SentenceQuery) OnlyX

func (sq *SentenceQuery) OnlyX(ctx context.Context) *Sentence

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

func (*SentenceQuery) Order

Order specifies how the records should be ordered.

func (*SentenceQuery) QueryAuthor

func (sq *SentenceQuery) QueryAuthor() *UserQuery

QueryAuthor chains the current query on the "author" edge.

func (*SentenceQuery) QueryStory

func (sq *SentenceQuery) QueryStory() *StoryQuery

QueryStory chains the current query on the "story" edge.

func (*SentenceQuery) Select

func (sq *SentenceQuery) Select(fields ...string) *SentenceSelect

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

client.Sentence.Query().
	Select(sentence.FieldText).
	Scan(ctx, &v)

func (*SentenceQuery) Unique

func (sq *SentenceQuery) Unique(unique bool) *SentenceQuery

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

func (sq *SentenceQuery) Where(ps ...predicate.Sentence) *SentenceQuery

Where adds a new predicate for the SentenceQuery builder.

func (*SentenceQuery) WithAuthor

func (sq *SentenceQuery) WithAuthor(opts ...func(*UserQuery)) *SentenceQuery

WithAuthor tells the query-builder to eager-load the nodes that are connected to the "author" edge. The optional arguments are used to configure the query builder of the edge.

func (*SentenceQuery) WithStory

func (sq *SentenceQuery) WithStory(opts ...func(*StoryQuery)) *SentenceQuery

WithStory tells the query-builder to eager-load the nodes that are connected to the "story" edge. The optional arguments are used to configure the query builder of the edge.

type SentenceSelect

type SentenceSelect struct {
	*SentenceQuery
	// contains filtered or unexported fields
}

SentenceSelect is the builder for selecting fields of Sentence entities.

func (*SentenceSelect) Aggregate

func (ss *SentenceSelect) Aggregate(fns ...AggregateFunc) *SentenceSelect

Aggregate adds the given aggregation functions to the selector query.

func (*SentenceSelect) Bool

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

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

func (*SentenceSelect) BoolX

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

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

func (*SentenceSelect) Bools

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

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

func (*SentenceSelect) BoolsX

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

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

func (*SentenceSelect) Float64

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

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

func (*SentenceSelect) Float64X

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

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

func (*SentenceSelect) Float64s

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

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

func (*SentenceSelect) Float64sX

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

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

func (*SentenceSelect) Int

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

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

func (*SentenceSelect) IntX

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

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

func (*SentenceSelect) Ints

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

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

func (*SentenceSelect) IntsX

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

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

func (*SentenceSelect) Scan

func (ss *SentenceSelect) Scan(ctx context.Context, v any) error

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

func (*SentenceSelect) ScanX

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

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

func (*SentenceSelect) String

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

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

func (*SentenceSelect) StringX

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

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

func (*SentenceSelect) Strings

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

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

func (*SentenceSelect) StringsX

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

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

type SentenceUpdate

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

SentenceUpdate is the builder for updating Sentence entities.

func (*SentenceUpdate) AddAuthor

func (su *SentenceUpdate) AddAuthor(u ...*User) *SentenceUpdate

AddAuthor adds the "author" edges to the User entity.

func (*SentenceUpdate) AddAuthorIDs

func (su *SentenceUpdate) AddAuthorIDs(ids ...uuid.UUID) *SentenceUpdate

AddAuthorIDs adds the "author" edge to the User entity by IDs.

func (*SentenceUpdate) AddOrder

func (su *SentenceUpdate) AddOrder(i int) *SentenceUpdate

AddOrder adds i to the "order" field.

func (*SentenceUpdate) ClearAuthor

func (su *SentenceUpdate) ClearAuthor() *SentenceUpdate

ClearAuthor clears all "author" edges to the User entity.

func (*SentenceUpdate) ClearStory

func (su *SentenceUpdate) ClearStory() *SentenceUpdate

ClearStory clears the "story" edge to the Story entity.

func (*SentenceUpdate) Exec

func (su *SentenceUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*SentenceUpdate) ExecX

func (su *SentenceUpdate) ExecX(ctx context.Context)

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

func (*SentenceUpdate) Mutation

func (su *SentenceUpdate) Mutation() *SentenceMutation

Mutation returns the SentenceMutation object of the builder.

func (*SentenceUpdate) RemoveAuthor

func (su *SentenceUpdate) RemoveAuthor(u ...*User) *SentenceUpdate

RemoveAuthor removes "author" edges to User entities.

func (*SentenceUpdate) RemoveAuthorIDs

func (su *SentenceUpdate) RemoveAuthorIDs(ids ...uuid.UUID) *SentenceUpdate

RemoveAuthorIDs removes the "author" edge to User entities by IDs.

func (*SentenceUpdate) Save

func (su *SentenceUpdate) Save(ctx context.Context) (int, error)

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

func (*SentenceUpdate) SaveX

func (su *SentenceUpdate) SaveX(ctx context.Context) int

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

func (*SentenceUpdate) SetCreatedAt

func (su *SentenceUpdate) SetCreatedAt(t time.Time) *SentenceUpdate

SetCreatedAt sets the "created_at" field.

func (*SentenceUpdate) SetNillableCreatedAt

func (su *SentenceUpdate) SetNillableCreatedAt(t *time.Time) *SentenceUpdate

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

func (*SentenceUpdate) SetOrder

func (su *SentenceUpdate) SetOrder(i int) *SentenceUpdate

SetOrder sets the "order" field.

func (*SentenceUpdate) SetStory

func (su *SentenceUpdate) SetStory(s *Story) *SentenceUpdate

SetStory sets the "story" edge to the Story entity.

func (*SentenceUpdate) SetStoryID

func (su *SentenceUpdate) SetStoryID(id uuid.UUID) *SentenceUpdate

SetStoryID sets the "story" edge to the Story entity by ID.

func (*SentenceUpdate) SetText

func (su *SentenceUpdate) SetText(s string) *SentenceUpdate

SetText sets the "text" field.

func (*SentenceUpdate) Where

func (su *SentenceUpdate) Where(ps ...predicate.Sentence) *SentenceUpdate

Where appends a list predicates to the SentenceUpdate builder.

type SentenceUpdateOne

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

SentenceUpdateOne is the builder for updating a single Sentence entity.

func (*SentenceUpdateOne) AddAuthor

func (suo *SentenceUpdateOne) AddAuthor(u ...*User) *SentenceUpdateOne

AddAuthor adds the "author" edges to the User entity.

func (*SentenceUpdateOne) AddAuthorIDs

func (suo *SentenceUpdateOne) AddAuthorIDs(ids ...uuid.UUID) *SentenceUpdateOne

AddAuthorIDs adds the "author" edge to the User entity by IDs.

func (*SentenceUpdateOne) AddOrder

func (suo *SentenceUpdateOne) AddOrder(i int) *SentenceUpdateOne

AddOrder adds i to the "order" field.

func (*SentenceUpdateOne) ClearAuthor

func (suo *SentenceUpdateOne) ClearAuthor() *SentenceUpdateOne

ClearAuthor clears all "author" edges to the User entity.

func (*SentenceUpdateOne) ClearStory

func (suo *SentenceUpdateOne) ClearStory() *SentenceUpdateOne

ClearStory clears the "story" edge to the Story entity.

func (*SentenceUpdateOne) Exec

func (suo *SentenceUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*SentenceUpdateOne) ExecX

func (suo *SentenceUpdateOne) ExecX(ctx context.Context)

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

func (*SentenceUpdateOne) Mutation

func (suo *SentenceUpdateOne) Mutation() *SentenceMutation

Mutation returns the SentenceMutation object of the builder.

func (*SentenceUpdateOne) RemoveAuthor

func (suo *SentenceUpdateOne) RemoveAuthor(u ...*User) *SentenceUpdateOne

RemoveAuthor removes "author" edges to User entities.

func (*SentenceUpdateOne) RemoveAuthorIDs

func (suo *SentenceUpdateOne) RemoveAuthorIDs(ids ...uuid.UUID) *SentenceUpdateOne

RemoveAuthorIDs removes the "author" edge to User entities by IDs.

func (*SentenceUpdateOne) Save

func (suo *SentenceUpdateOne) Save(ctx context.Context) (*Sentence, error)

Save executes the query and returns the updated Sentence entity.

func (*SentenceUpdateOne) SaveX

func (suo *SentenceUpdateOne) SaveX(ctx context.Context) *Sentence

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

func (*SentenceUpdateOne) Select

func (suo *SentenceUpdateOne) Select(field string, fields ...string) *SentenceUpdateOne

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

func (*SentenceUpdateOne) SetCreatedAt

func (suo *SentenceUpdateOne) SetCreatedAt(t time.Time) *SentenceUpdateOne

SetCreatedAt sets the "created_at" field.

func (*SentenceUpdateOne) SetNillableCreatedAt

func (suo *SentenceUpdateOne) SetNillableCreatedAt(t *time.Time) *SentenceUpdateOne

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

func (*SentenceUpdateOne) SetOrder

func (suo *SentenceUpdateOne) SetOrder(i int) *SentenceUpdateOne

SetOrder sets the "order" field.

func (*SentenceUpdateOne) SetStory

func (suo *SentenceUpdateOne) SetStory(s *Story) *SentenceUpdateOne

SetStory sets the "story" edge to the Story entity.

func (*SentenceUpdateOne) SetStoryID

func (suo *SentenceUpdateOne) SetStoryID(id uuid.UUID) *SentenceUpdateOne

SetStoryID sets the "story" edge to the Story entity by ID.

func (*SentenceUpdateOne) SetText

func (suo *SentenceUpdateOne) SetText(s string) *SentenceUpdateOne

SetText sets the "text" field.

func (*SentenceUpdateOne) Where

Where appends a list predicates to the SentenceUpdate builder.

type Sentences

type Sentences []*Sentence

Sentences is a parsable slice of Sentence.

type Stories

type Stories []*Story

Stories is a parsable slice of Story.

type Story

type Story struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// Status holds the value of the "status" field.
	Status story.Status `json:"status,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"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the StoryQuery when eager-loading is set.
	Edges StoryEdges `json:"edges"`
	// contains filtered or unexported fields
}

Story is the model entity for the Story schema.

func (*Story) QuerySentences

func (s *Story) QuerySentences() *SentenceQuery

QuerySentences queries the "sentences" edge of the Story entity.

func (*Story) String

func (s *Story) String() string

String implements the fmt.Stringer.

func (*Story) Unwrap

func (s *Story) Unwrap() *Story

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

func (s *Story) Update() *StoryUpdateOne

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

func (*Story) Value

func (s *Story) Value(name string) (ent.Value, error)

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

type StoryClient

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

StoryClient is a client for the Story schema.

func NewStoryClient

func NewStoryClient(c config) *StoryClient

NewStoryClient returns a client for the Story from the given config.

func (*StoryClient) Create

func (c *StoryClient) Create() *StoryCreate

Create returns a builder for creating a Story entity.

func (*StoryClient) CreateBulk

func (c *StoryClient) CreateBulk(builders ...*StoryCreate) *StoryCreateBulk

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

func (*StoryClient) Delete

func (c *StoryClient) Delete() *StoryDelete

Delete returns a delete builder for Story.

func (*StoryClient) DeleteOne

func (c *StoryClient) DeleteOne(s *Story) *StoryDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*StoryClient) DeleteOneID

func (c *StoryClient) DeleteOneID(id uuid.UUID) *StoryDeleteOne

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

func (*StoryClient) Get

func (c *StoryClient) Get(ctx context.Context, id uuid.UUID) (*Story, error)

Get returns a Story entity by its id.

func (*StoryClient) GetX

func (c *StoryClient) GetX(ctx context.Context, id uuid.UUID) *Story

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

func (*StoryClient) Hooks

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

Hooks returns the client hooks.

func (*StoryClient) Intercept

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

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

func (*StoryClient) Interceptors

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

Interceptors returns the client interceptors.

func (*StoryClient) Query

func (c *StoryClient) Query() *StoryQuery

Query returns a query builder for Story.

func (*StoryClient) QuerySentences

func (c *StoryClient) QuerySentences(s *Story) *SentenceQuery

QuerySentences queries the sentences edge of a Story.

func (*StoryClient) Update

func (c *StoryClient) Update() *StoryUpdate

Update returns an update builder for Story.

func (*StoryClient) UpdateOne

func (c *StoryClient) UpdateOne(s *Story) *StoryUpdateOne

UpdateOne returns an update builder for the given entity.

func (*StoryClient) UpdateOneID

func (c *StoryClient) UpdateOneID(id uuid.UUID) *StoryUpdateOne

UpdateOneID returns an update builder for the given id.

func (*StoryClient) Use

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

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

type StoryCreate

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

StoryCreate is the builder for creating a Story entity.

func (*StoryCreate) AddSentenceIDs

func (sc *StoryCreate) AddSentenceIDs(ids ...uuid.UUID) *StoryCreate

AddSentenceIDs adds the "sentences" edge to the Sentence entity by IDs.

func (*StoryCreate) AddSentences

func (sc *StoryCreate) AddSentences(s ...*Sentence) *StoryCreate

AddSentences adds the "sentences" edges to the Sentence entity.

func (*StoryCreate) Exec

func (sc *StoryCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*StoryCreate) ExecX

func (sc *StoryCreate) ExecX(ctx context.Context)

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

func (*StoryCreate) Mutation

func (sc *StoryCreate) Mutation() *StoryMutation

Mutation returns the StoryMutation object of the builder.

func (*StoryCreate) Save

func (sc *StoryCreate) Save(ctx context.Context) (*Story, error)

Save creates the Story in the database.

func (*StoryCreate) SaveX

func (sc *StoryCreate) SaveX(ctx context.Context) *Story

SaveX calls Save and panics if Save returns an error.

func (*StoryCreate) SetCreatedAt

func (sc *StoryCreate) SetCreatedAt(t time.Time) *StoryCreate

SetCreatedAt sets the "created_at" field.

func (*StoryCreate) SetID

func (sc *StoryCreate) SetID(u uuid.UUID) *StoryCreate

SetID sets the "id" field.

func (*StoryCreate) SetNillableCreatedAt

func (sc *StoryCreate) SetNillableCreatedAt(t *time.Time) *StoryCreate

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

func (*StoryCreate) SetNillableID

func (sc *StoryCreate) SetNillableID(u *uuid.UUID) *StoryCreate

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

func (*StoryCreate) SetNillableStatus

func (sc *StoryCreate) SetNillableStatus(s *story.Status) *StoryCreate

SetNillableStatus sets the "status" field if the given value is not nil.

func (*StoryCreate) SetStatus

func (sc *StoryCreate) SetStatus(s story.Status) *StoryCreate

SetStatus sets the "status" field.

func (*StoryCreate) SetUpdatedAt

func (sc *StoryCreate) SetUpdatedAt(t time.Time) *StoryCreate

SetUpdatedAt sets the "updated_at" field.

type StoryCreateBulk

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

StoryCreateBulk is the builder for creating many Story entities in bulk.

func (*StoryCreateBulk) Exec

func (scb *StoryCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*StoryCreateBulk) ExecX

func (scb *StoryCreateBulk) ExecX(ctx context.Context)

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

func (*StoryCreateBulk) Save

func (scb *StoryCreateBulk) Save(ctx context.Context) ([]*Story, error)

Save creates the Story entities in the database.

func (*StoryCreateBulk) SaveX

func (scb *StoryCreateBulk) SaveX(ctx context.Context) []*Story

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

type StoryDelete

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

StoryDelete is the builder for deleting a Story entity.

func (*StoryDelete) Exec

func (sd *StoryDelete) Exec(ctx context.Context) (int, error)

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

func (*StoryDelete) ExecX

func (sd *StoryDelete) ExecX(ctx context.Context) int

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

func (*StoryDelete) Where

func (sd *StoryDelete) Where(ps ...predicate.Story) *StoryDelete

Where appends a list predicates to the StoryDelete builder.

type StoryDeleteOne

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

StoryDeleteOne is the builder for deleting a single Story entity.

func (*StoryDeleteOne) Exec

func (sdo *StoryDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*StoryDeleteOne) ExecX

func (sdo *StoryDeleteOne) ExecX(ctx context.Context)

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

func (*StoryDeleteOne) Where

func (sdo *StoryDeleteOne) Where(ps ...predicate.Story) *StoryDeleteOne

Where appends a list predicates to the StoryDelete builder.

type StoryEdges

type StoryEdges struct {
	// Sentences holds the value of the sentences edge.
	Sentences []*Sentence `json:"sentences,omitempty"`
	// contains filtered or unexported fields
}

StoryEdges holds the relations/edges for other nodes in the graph.

func (StoryEdges) SentencesOrErr

func (e StoryEdges) SentencesOrErr() ([]*Sentence, error)

SentencesOrErr returns the Sentences value or an error if the edge was not loaded in eager-loading.

type StoryGroupBy

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

StoryGroupBy is the group-by builder for Story entities.

func (*StoryGroupBy) Aggregate

func (sgb *StoryGroupBy) Aggregate(fns ...AggregateFunc) *StoryGroupBy

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

func (*StoryGroupBy) Bool

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

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

func (*StoryGroupBy) BoolX

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

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

func (*StoryGroupBy) Bools

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

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

func (*StoryGroupBy) BoolsX

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

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

func (*StoryGroupBy) Float64

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

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

func (*StoryGroupBy) Float64X

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

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

func (*StoryGroupBy) Float64s

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

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

func (*StoryGroupBy) Float64sX

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

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

func (*StoryGroupBy) Int

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

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

func (*StoryGroupBy) IntX

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

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

func (*StoryGroupBy) Ints

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

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

func (*StoryGroupBy) IntsX

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

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

func (*StoryGroupBy) Scan

func (sgb *StoryGroupBy) Scan(ctx context.Context, v any) error

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

func (*StoryGroupBy) ScanX

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

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

func (*StoryGroupBy) String

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

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

func (*StoryGroupBy) StringX

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

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

func (*StoryGroupBy) Strings

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

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

func (*StoryGroupBy) StringsX

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

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

type StoryMutation

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

StoryMutation represents an operation that mutates the Story nodes in the graph.

func (*StoryMutation) AddField

func (m *StoryMutation) 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 (*StoryMutation) AddSentenceIDs

func (m *StoryMutation) AddSentenceIDs(ids ...uuid.UUID)

AddSentenceIDs adds the "sentences" edge to the Sentence entity by ids.

func (*StoryMutation) AddedEdges

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

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

func (*StoryMutation) AddedField

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

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

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

func (*StoryMutation) AddedIDs

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

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

func (*StoryMutation) ClearEdge

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

func (m *StoryMutation) 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 (*StoryMutation) ClearSentences

func (m *StoryMutation) ClearSentences()

ClearSentences clears the "sentences" edge to the Sentence entity.

func (*StoryMutation) ClearedEdges

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

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

func (*StoryMutation) ClearedFields

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

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

func (StoryMutation) Client

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

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

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

func (*StoryMutation) EdgeCleared

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

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

func (*StoryMutation) Field

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

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

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

func (*StoryMutation) Fields

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

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

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

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

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

func (m *StoryMutation) 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 (*StoryMutation) OldStatus

func (m *StoryMutation) OldStatus(ctx context.Context) (v story.Status, err error)

OldStatus returns the old "status" field's value of the Story entity. If the Story 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 (*StoryMutation) OldUpdatedAt

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

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

func (m *StoryMutation) Op() Op

Op returns the operation name.

func (*StoryMutation) RemoveSentenceIDs

func (m *StoryMutation) RemoveSentenceIDs(ids ...uuid.UUID)

RemoveSentenceIDs removes the "sentences" edge to the Sentence entity by IDs.

func (*StoryMutation) RemovedEdges

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

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

func (*StoryMutation) RemovedIDs

func (m *StoryMutation) 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 (*StoryMutation) RemovedSentencesIDs

func (m *StoryMutation) RemovedSentencesIDs() (ids []uuid.UUID)

RemovedSentences returns the removed IDs of the "sentences" edge to the Sentence entity.

func (*StoryMutation) ResetCreatedAt

func (m *StoryMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*StoryMutation) ResetEdge

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

func (m *StoryMutation) 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 (*StoryMutation) ResetSentences

func (m *StoryMutation) ResetSentences()

ResetSentences resets all changes to the "sentences" edge.

func (*StoryMutation) ResetStatus

func (m *StoryMutation) ResetStatus()

ResetStatus resets all changes to the "status" field.

func (*StoryMutation) ResetUpdatedAt

func (m *StoryMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*StoryMutation) SentencesCleared

func (m *StoryMutation) SentencesCleared() bool

SentencesCleared reports if the "sentences" edge to the Sentence entity was cleared.

func (*StoryMutation) SentencesIDs

func (m *StoryMutation) SentencesIDs() (ids []uuid.UUID)

SentencesIDs returns the "sentences" edge IDs in the mutation.

func (*StoryMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*StoryMutation) SetField

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

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

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

func (*StoryMutation) SetOp

func (m *StoryMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*StoryMutation) SetStatus

func (m *StoryMutation) SetStatus(s story.Status)

SetStatus sets the "status" field.

func (*StoryMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*StoryMutation) Status

func (m *StoryMutation) Status() (r story.Status, exists bool)

Status returns the value of the "status" field in the mutation.

func (StoryMutation) Tx

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

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

func (*StoryMutation) Type

func (m *StoryMutation) Type() string

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

func (*StoryMutation) UpdatedAt

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

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

func (*StoryMutation) Where

func (m *StoryMutation) Where(ps ...predicate.Story)

Where appends a list predicates to the StoryMutation builder.

func (*StoryMutation) WhereP

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

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

type StoryQuery

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

StoryQuery is the builder for querying Story entities.

func (*StoryQuery) Aggregate

func (sq *StoryQuery) Aggregate(fns ...AggregateFunc) *StorySelect

Aggregate returns a StorySelect configured with the given aggregations.

func (*StoryQuery) All

func (sq *StoryQuery) All(ctx context.Context) ([]*Story, error)

All executes the query and returns a list of Stories.

func (*StoryQuery) AllX

func (sq *StoryQuery) AllX(ctx context.Context) []*Story

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

func (*StoryQuery) Clone

func (sq *StoryQuery) Clone() *StoryQuery

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

func (*StoryQuery) Count

func (sq *StoryQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*StoryQuery) CountX

func (sq *StoryQuery) CountX(ctx context.Context) int

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

func (*StoryQuery) Exist

func (sq *StoryQuery) Exist(ctx context.Context) (bool, error)

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

func (*StoryQuery) ExistX

func (sq *StoryQuery) ExistX(ctx context.Context) bool

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

func (*StoryQuery) First

func (sq *StoryQuery) First(ctx context.Context) (*Story, error)

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

func (*StoryQuery) FirstID

func (sq *StoryQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*StoryQuery) FirstIDX

func (sq *StoryQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*StoryQuery) FirstX

func (sq *StoryQuery) FirstX(ctx context.Context) *Story

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

func (*StoryQuery) GroupBy

func (sq *StoryQuery) GroupBy(field string, fields ...string) *StoryGroupBy

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 {
	Status story.Status `json:"status,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Story.Query().
	GroupBy(story.FieldStatus).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*StoryQuery) IDs

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

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

func (*StoryQuery) IDsX

func (sq *StoryQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*StoryQuery) Limit

func (sq *StoryQuery) Limit(limit int) *StoryQuery

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

func (*StoryQuery) Offset

func (sq *StoryQuery) Offset(offset int) *StoryQuery

Offset to start from.

func (*StoryQuery) Only

func (sq *StoryQuery) Only(ctx context.Context) (*Story, error)

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

func (*StoryQuery) OnlyID

func (sq *StoryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*StoryQuery) OnlyIDX

func (sq *StoryQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*StoryQuery) OnlyX

func (sq *StoryQuery) OnlyX(ctx context.Context) *Story

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

func (*StoryQuery) Order

func (sq *StoryQuery) Order(o ...story.OrderOption) *StoryQuery

Order specifies how the records should be ordered.

func (*StoryQuery) QuerySentences

func (sq *StoryQuery) QuerySentences() *SentenceQuery

QuerySentences chains the current query on the "sentences" edge.

func (*StoryQuery) Select

func (sq *StoryQuery) Select(fields ...string) *StorySelect

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 {
	Status story.Status `json:"status,omitempty"`
}

client.Story.Query().
	Select(story.FieldStatus).
	Scan(ctx, &v)

func (*StoryQuery) Unique

func (sq *StoryQuery) Unique(unique bool) *StoryQuery

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

func (sq *StoryQuery) Where(ps ...predicate.Story) *StoryQuery

Where adds a new predicate for the StoryQuery builder.

func (*StoryQuery) WithSentences

func (sq *StoryQuery) WithSentences(opts ...func(*SentenceQuery)) *StoryQuery

WithSentences tells the query-builder to eager-load the nodes that are connected to the "sentences" edge. The optional arguments are used to configure the query builder of the edge.

type StorySelect

type StorySelect struct {
	*StoryQuery
	// contains filtered or unexported fields
}

StorySelect is the builder for selecting fields of Story entities.

func (*StorySelect) Aggregate

func (ss *StorySelect) Aggregate(fns ...AggregateFunc) *StorySelect

Aggregate adds the given aggregation functions to the selector query.

func (*StorySelect) Bool

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

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

func (*StorySelect) BoolX

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

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

func (*StorySelect) Bools

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

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

func (*StorySelect) BoolsX

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

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

func (*StorySelect) Float64

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

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

func (*StorySelect) Float64X

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

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

func (*StorySelect) Float64s

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

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

func (*StorySelect) Float64sX

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

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

func (*StorySelect) Int

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

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

func (*StorySelect) IntX

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

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

func (*StorySelect) Ints

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

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

func (*StorySelect) IntsX

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

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

func (*StorySelect) Scan

func (ss *StorySelect) Scan(ctx context.Context, v any) error

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

func (*StorySelect) ScanX

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

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

func (*StorySelect) String

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

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

func (*StorySelect) StringX

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

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

func (*StorySelect) Strings

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

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

func (*StorySelect) StringsX

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

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

type StoryUpdate

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

StoryUpdate is the builder for updating Story entities.

func (*StoryUpdate) AddSentenceIDs

func (su *StoryUpdate) AddSentenceIDs(ids ...uuid.UUID) *StoryUpdate

AddSentenceIDs adds the "sentences" edge to the Sentence entity by IDs.

func (*StoryUpdate) AddSentences

func (su *StoryUpdate) AddSentences(s ...*Sentence) *StoryUpdate

AddSentences adds the "sentences" edges to the Sentence entity.

func (*StoryUpdate) ClearSentences

func (su *StoryUpdate) ClearSentences() *StoryUpdate

ClearSentences clears all "sentences" edges to the Sentence entity.

func (*StoryUpdate) Exec

func (su *StoryUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*StoryUpdate) ExecX

func (su *StoryUpdate) ExecX(ctx context.Context)

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

func (*StoryUpdate) Mutation

func (su *StoryUpdate) Mutation() *StoryMutation

Mutation returns the StoryMutation object of the builder.

func (*StoryUpdate) RemoveSentenceIDs

func (su *StoryUpdate) RemoveSentenceIDs(ids ...uuid.UUID) *StoryUpdate

RemoveSentenceIDs removes the "sentences" edge to Sentence entities by IDs.

func (*StoryUpdate) RemoveSentences

func (su *StoryUpdate) RemoveSentences(s ...*Sentence) *StoryUpdate

RemoveSentences removes "sentences" edges to Sentence entities.

func (*StoryUpdate) Save

func (su *StoryUpdate) Save(ctx context.Context) (int, error)

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

func (*StoryUpdate) SaveX

func (su *StoryUpdate) SaveX(ctx context.Context) int

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

func (*StoryUpdate) SetCreatedAt

func (su *StoryUpdate) SetCreatedAt(t time.Time) *StoryUpdate

SetCreatedAt sets the "created_at" field.

func (*StoryUpdate) SetNillableCreatedAt

func (su *StoryUpdate) SetNillableCreatedAt(t *time.Time) *StoryUpdate

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

func (*StoryUpdate) SetNillableStatus

func (su *StoryUpdate) SetNillableStatus(s *story.Status) *StoryUpdate

SetNillableStatus sets the "status" field if the given value is not nil.

func (*StoryUpdate) SetStatus

func (su *StoryUpdate) SetStatus(s story.Status) *StoryUpdate

SetStatus sets the "status" field.

func (*StoryUpdate) SetUpdatedAt

func (su *StoryUpdate) SetUpdatedAt(t time.Time) *StoryUpdate

SetUpdatedAt sets the "updated_at" field.

func (*StoryUpdate) Where

func (su *StoryUpdate) Where(ps ...predicate.Story) *StoryUpdate

Where appends a list predicates to the StoryUpdate builder.

type StoryUpdateOne

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

StoryUpdateOne is the builder for updating a single Story entity.

func (*StoryUpdateOne) AddSentenceIDs

func (suo *StoryUpdateOne) AddSentenceIDs(ids ...uuid.UUID) *StoryUpdateOne

AddSentenceIDs adds the "sentences" edge to the Sentence entity by IDs.

func (*StoryUpdateOne) AddSentences

func (suo *StoryUpdateOne) AddSentences(s ...*Sentence) *StoryUpdateOne

AddSentences adds the "sentences" edges to the Sentence entity.

func (*StoryUpdateOne) ClearSentences

func (suo *StoryUpdateOne) ClearSentences() *StoryUpdateOne

ClearSentences clears all "sentences" edges to the Sentence entity.

func (*StoryUpdateOne) Exec

func (suo *StoryUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*StoryUpdateOne) ExecX

func (suo *StoryUpdateOne) ExecX(ctx context.Context)

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

func (*StoryUpdateOne) Mutation

func (suo *StoryUpdateOne) Mutation() *StoryMutation

Mutation returns the StoryMutation object of the builder.

func (*StoryUpdateOne) RemoveSentenceIDs

func (suo *StoryUpdateOne) RemoveSentenceIDs(ids ...uuid.UUID) *StoryUpdateOne

RemoveSentenceIDs removes the "sentences" edge to Sentence entities by IDs.

func (*StoryUpdateOne) RemoveSentences

func (suo *StoryUpdateOne) RemoveSentences(s ...*Sentence) *StoryUpdateOne

RemoveSentences removes "sentences" edges to Sentence entities.

func (*StoryUpdateOne) Save

func (suo *StoryUpdateOne) Save(ctx context.Context) (*Story, error)

Save executes the query and returns the updated Story entity.

func (*StoryUpdateOne) SaveX

func (suo *StoryUpdateOne) SaveX(ctx context.Context) *Story

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

func (*StoryUpdateOne) Select

func (suo *StoryUpdateOne) Select(field string, fields ...string) *StoryUpdateOne

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

func (*StoryUpdateOne) SetCreatedAt

func (suo *StoryUpdateOne) SetCreatedAt(t time.Time) *StoryUpdateOne

SetCreatedAt sets the "created_at" field.

func (*StoryUpdateOne) SetNillableCreatedAt

func (suo *StoryUpdateOne) SetNillableCreatedAt(t *time.Time) *StoryUpdateOne

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

func (*StoryUpdateOne) SetNillableStatus

func (suo *StoryUpdateOne) SetNillableStatus(s *story.Status) *StoryUpdateOne

SetNillableStatus sets the "status" field if the given value is not nil.

func (*StoryUpdateOne) SetStatus

func (suo *StoryUpdateOne) SetStatus(s story.Status) *StoryUpdateOne

SetStatus sets the "status" field.

func (*StoryUpdateOne) SetUpdatedAt

func (suo *StoryUpdateOne) SetUpdatedAt(t time.Time) *StoryUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*StoryUpdateOne) Where

func (suo *StoryUpdateOne) Where(ps ...predicate.Story) *StoryUpdateOne

Where appends a list predicates to the StoryUpdate builder.

type TraverseFunc

type TraverseFunc = ent.TraverseFunc

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

type Traverser

type Traverser = ent.Traverser

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

type Tx

type Tx struct {

	// Sentence is the client for interacting with the Sentence builders.
	Sentence *SentenceClient
	// Story is the client for interacting with the Story builders.
	Story *StoryClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// 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 User

type User struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// IPAddress holds the value of the "ip_address" field.
	IPAddress string `json:"ip_address,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the UserQuery when eager-loading is set.
	Edges UserEdges `json:"edges"`
	// contains filtered or unexported fields
}

User is the model entity for the User schema.

func (*User) QuerySentences

func (u *User) QuerySentences() *SentenceQuery

QuerySentences queries the "sentences" edge of the User entity.

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (u *User) Unwrap() *User

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

func (u *User) Update() *UserUpdateOne

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

func (*User) Value

func (u *User) Value(name string) (ent.Value, error)

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

NewUserClient returns a client for the User from the given config.

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a builder for creating a User entity.

func (*UserClient) CreateBulk

func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk

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

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

func (c *UserClient) DeleteOne(u *User) *UserDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*UserClient) DeleteOneID

func (c *UserClient) DeleteOneID(id uuid.UUID) *UserDeleteOne

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

func (*UserClient) Get

func (c *UserClient) Get(ctx context.Context, id uuid.UUID) (*User, error)

Get returns a User entity by its id.

func (*UserClient) GetX

func (c *UserClient) GetX(ctx context.Context, id uuid.UUID) *User

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

func (*UserClient) Hooks

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

Hooks returns the client hooks.

func (*UserClient) Intercept

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

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

func (*UserClient) Interceptors

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

Interceptors returns the client interceptors.

func (*UserClient) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QuerySentences

func (c *UserClient) QuerySentences(u *User) *SentenceQuery

QuerySentences queries the sentences edge of a User.

func (*UserClient) Update

func (c *UserClient) Update() *UserUpdate

Update returns an update builder for User.

func (*UserClient) UpdateOne

func (c *UserClient) UpdateOne(u *User) *UserUpdateOne

UpdateOne returns an update builder for the given entity.

func (*UserClient) UpdateOneID

func (c *UserClient) UpdateOneID(id uuid.UUID) *UserUpdateOne

UpdateOneID returns an update builder for the given id.

func (*UserClient) Use

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

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

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddSentenceIDs

func (uc *UserCreate) AddSentenceIDs(ids ...uuid.UUID) *UserCreate

AddSentenceIDs adds the "sentences" edge to the Sentence entity by IDs.

func (*UserCreate) AddSentences

func (uc *UserCreate) AddSentences(s ...*Sentence) *UserCreate

AddSentences adds the "sentences" edges to the Sentence entity.

func (*UserCreate) Exec

func (uc *UserCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreate) ExecX

func (uc *UserCreate) ExecX(ctx context.Context)

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

func (*UserCreate) Mutation

func (uc *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) Save

func (uc *UserCreate) Save(ctx context.Context) (*User, error)

Save creates the User in the database.

func (*UserCreate) SaveX

func (uc *UserCreate) SaveX(ctx context.Context) *User

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetID

func (uc *UserCreate) SetID(u uuid.UUID) *UserCreate

SetID sets the "id" field.

func (*UserCreate) SetIPAddress

func (uc *UserCreate) SetIPAddress(s string) *UserCreate

SetIPAddress sets the "ip_address" field.

func (*UserCreate) SetNillableID

func (uc *UserCreate) SetNillableID(u *uuid.UUID) *UserCreate

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

type UserCreateBulk

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

UserCreateBulk is the builder for creating many User entities in bulk.

func (*UserCreateBulk) Exec

func (ucb *UserCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreateBulk) ExecX

func (ucb *UserCreateBulk) ExecX(ctx context.Context)

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

func (*UserCreateBulk) Save

func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error)

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

func (ud *UserDelete) Exec(ctx context.Context) (int, error)

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

func (*UserDelete) ExecX

func (ud *UserDelete) ExecX(ctx context.Context) int

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

func (*UserDelete) Where

func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

func (udo *UserDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

func (udo *UserDeleteOne) ExecX(ctx context.Context)

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

func (*UserDeleteOne) Where

func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne

Where appends a list predicates to the UserDelete builder.

type UserEdges

type UserEdges struct {
	// Sentences holds the value of the sentences edge.
	Sentences []*Sentence `json:"sentences,omitempty"`
	// contains filtered or unexported fields
}

UserEdges holds the relations/edges for other nodes in the graph.

func (UserEdges) SentencesOrErr

func (e UserEdges) SentencesOrErr() ([]*Sentence, error)

SentencesOrErr returns the Sentences value or an error if the edge was not loaded in eager-loading.

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy

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

func (*UserGroupBy) Bool

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

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

func (*UserGroupBy) BoolX

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

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

func (*UserGroupBy) Bools

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

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

func (*UserGroupBy) BoolsX

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

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

func (*UserGroupBy) Float64

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

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

func (*UserGroupBy) Float64X

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

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

func (*UserGroupBy) Float64s

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

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

func (*UserGroupBy) Float64sX

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

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

func (*UserGroupBy) Int

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

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

func (*UserGroupBy) IntX

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

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

func (*UserGroupBy) Ints

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

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

func (*UserGroupBy) IntsX

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

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

func (*UserGroupBy) Scan

func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error

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

func (*UserGroupBy) ScanX

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

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

func (*UserGroupBy) String

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

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

func (*UserGroupBy) StringX

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

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

func (*UserGroupBy) Strings

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

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

func (*UserGroupBy) StringsX

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

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

type UserMutation

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

UserMutation represents an operation that mutates the User nodes in the graph.

func (*UserMutation) AddField

func (m *UserMutation) 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 (*UserMutation) AddSentenceIDs

func (m *UserMutation) AddSentenceIDs(ids ...uuid.UUID)

AddSentenceIDs adds the "sentences" edge to the Sentence entity by ids.

func (*UserMutation) AddedEdges

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

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

func (*UserMutation) AddedField

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

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

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

func (*UserMutation) AddedIDs

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

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

func (*UserMutation) ClearEdge

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

func (m *UserMutation) 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 (*UserMutation) ClearSentences

func (m *UserMutation) ClearSentences()

ClearSentences clears the "sentences" edge to the Sentence entity.

func (*UserMutation) ClearedEdges

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

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

func (*UserMutation) ClearedFields

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

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

func (UserMutation) Client

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

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

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

func (*UserMutation) Field

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

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

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

func (*UserMutation) Fields

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

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

func (m *UserMutation) 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 (*UserMutation) IPAddress

func (m *UserMutation) IPAddress() (r string, exists bool)

IPAddress returns the value of the "ip_address" field in the mutation.

func (*UserMutation) OldField

func (m *UserMutation) 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 (*UserMutation) OldIPAddress

func (m *UserMutation) OldIPAddress(ctx context.Context) (v string, err error)

OldIPAddress returns the old "ip_address" field's value of the User entity. If the User 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 (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) RemoveSentenceIDs

func (m *UserMutation) RemoveSentenceIDs(ids ...uuid.UUID)

RemoveSentenceIDs removes the "sentences" edge to the Sentence entity by IDs.

func (*UserMutation) RemovedEdges

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

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

func (*UserMutation) RemovedIDs

func (m *UserMutation) 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 (*UserMutation) RemovedSentencesIDs

func (m *UserMutation) RemovedSentencesIDs() (ids []uuid.UUID)

RemovedSentences returns the removed IDs of the "sentences" edge to the Sentence entity.

func (*UserMutation) ResetEdge

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

func (m *UserMutation) 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 (*UserMutation) ResetIPAddress

func (m *UserMutation) ResetIPAddress()

ResetIPAddress resets all changes to the "ip_address" field.

func (*UserMutation) ResetSentences

func (m *UserMutation) ResetSentences()

ResetSentences resets all changes to the "sentences" edge.

func (*UserMutation) SentencesCleared

func (m *UserMutation) SentencesCleared() bool

SentencesCleared reports if the "sentences" edge to the Sentence entity was cleared.

func (*UserMutation) SentencesIDs

func (m *UserMutation) SentencesIDs() (ids []uuid.UUID)

SentencesIDs returns the "sentences" edge IDs in the mutation.

func (*UserMutation) SetField

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

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

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

func (*UserMutation) SetIPAddress

func (m *UserMutation) SetIPAddress(s string)

SetIPAddress sets the "ip_address" field.

func (*UserMutation) SetOp

func (m *UserMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) Where

func (m *UserMutation) Where(ps ...predicate.User)

Where appends a list predicates to the UserMutation builder.

func (*UserMutation) WhereP

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

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

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) Aggregate

func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate returns a UserSelect configured with the given aggregations.

func (*UserQuery) All

func (uq *UserQuery) All(ctx context.Context) ([]*User, error)

All executes the query and returns a list of Users.

func (*UserQuery) AllX

func (uq *UserQuery) AllX(ctx context.Context) []*User

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

func (*UserQuery) Clone

func (uq *UserQuery) Clone() *UserQuery

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

func (*UserQuery) Count

func (uq *UserQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*UserQuery) CountX

func (uq *UserQuery) CountX(ctx context.Context) int

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

func (*UserQuery) Exist

func (uq *UserQuery) Exist(ctx context.Context) (bool, error)

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

func (*UserQuery) ExistX

func (uq *UserQuery) ExistX(ctx context.Context) bool

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

func (*UserQuery) First

func (uq *UserQuery) First(ctx context.Context) (*User, error)

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

func (*UserQuery) FirstID

func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*UserQuery) FirstIDX

func (uq *UserQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*UserQuery) FirstX

func (uq *UserQuery) FirstX(ctx context.Context) *User

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

func (*UserQuery) GroupBy

func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy

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

client.User.Query().
	GroupBy(user.FieldIPAddress).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserQuery) IDs

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

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

func (*UserQuery) IDsX

func (uq *UserQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*UserQuery) Limit

func (uq *UserQuery) Limit(limit int) *UserQuery

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

func (*UserQuery) Offset

func (uq *UserQuery) Offset(offset int) *UserQuery

Offset to start from.

func (*UserQuery) Only

func (uq *UserQuery) Only(ctx context.Context) (*User, error)

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

func (*UserQuery) OnlyID

func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*UserQuery) OnlyIDX

func (uq *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*UserQuery) OnlyX

func (uq *UserQuery) OnlyX(ctx context.Context) *User

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

func (*UserQuery) Order

func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery

Order specifies how the records should be ordered.

func (*UserQuery) QuerySentences

func (uq *UserQuery) QuerySentences() *SentenceQuery

QuerySentences chains the current query on the "sentences" edge.

func (*UserQuery) Select

func (uq *UserQuery) Select(fields ...string) *UserSelect

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

client.User.Query().
	Select(user.FieldIPAddress).
	Scan(ctx, &v)

func (*UserQuery) Unique

func (uq *UserQuery) Unique(unique bool) *UserQuery

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

func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithSentences

func (uq *UserQuery) WithSentences(opts ...func(*SentenceQuery)) *UserQuery

WithSentences tells the query-builder to eager-load the nodes that are connected to the "sentences" edge. The optional arguments are used to configure the query builder of the edge.

type UserSelect

type UserSelect struct {
	*UserQuery
	// contains filtered or unexported fields
}

UserSelect is the builder for selecting fields of User entities.

func (*UserSelect) Aggregate

func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate adds the given aggregation functions to the selector query.

func (*UserSelect) Bool

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

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

func (*UserSelect) BoolX

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

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

func (*UserSelect) Bools

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

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

func (*UserSelect) BoolsX

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

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

func (*UserSelect) Float64

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

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

func (*UserSelect) Float64X

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

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

func (*UserSelect) Float64s

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

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

func (*UserSelect) Float64sX

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

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

func (*UserSelect) Int

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

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

func (*UserSelect) IntX

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

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

func (*UserSelect) Ints

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

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

func (*UserSelect) IntsX

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

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

func (*UserSelect) Scan

func (us *UserSelect) Scan(ctx context.Context, v any) error

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

func (*UserSelect) ScanX

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

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

func (*UserSelect) String

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

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

func (*UserSelect) StringX

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

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

func (*UserSelect) Strings

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

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

func (*UserSelect) StringsX

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

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

type UserUpdate

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

UserUpdate is the builder for updating User entities.

func (*UserUpdate) AddSentenceIDs

func (uu *UserUpdate) AddSentenceIDs(ids ...uuid.UUID) *UserUpdate

AddSentenceIDs adds the "sentences" edge to the Sentence entity by IDs.

func (*UserUpdate) AddSentences

func (uu *UserUpdate) AddSentences(s ...*Sentence) *UserUpdate

AddSentences adds the "sentences" edges to the Sentence entity.

func (*UserUpdate) ClearSentences

func (uu *UserUpdate) ClearSentences() *UserUpdate

ClearSentences clears all "sentences" edges to the Sentence entity.

func (*UserUpdate) Exec

func (uu *UserUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpdate) ExecX

func (uu *UserUpdate) ExecX(ctx context.Context)

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

func (*UserUpdate) Mutation

func (uu *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemoveSentenceIDs

func (uu *UserUpdate) RemoveSentenceIDs(ids ...uuid.UUID) *UserUpdate

RemoveSentenceIDs removes the "sentences" edge to Sentence entities by IDs.

func (*UserUpdate) RemoveSentences

func (uu *UserUpdate) RemoveSentences(s ...*Sentence) *UserUpdate

RemoveSentences removes "sentences" edges to Sentence entities.

func (*UserUpdate) Save

func (uu *UserUpdate) Save(ctx context.Context) (int, error)

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

func (*UserUpdate) SaveX

func (uu *UserUpdate) SaveX(ctx context.Context) int

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

func (*UserUpdate) SetIPAddress

func (uu *UserUpdate) SetIPAddress(s string) *UserUpdate

SetIPAddress sets the "ip_address" field.

func (*UserUpdate) Where

func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOne

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

UserUpdateOne is the builder for updating a single User entity.

func (*UserUpdateOne) AddSentenceIDs

func (uuo *UserUpdateOne) AddSentenceIDs(ids ...uuid.UUID) *UserUpdateOne

AddSentenceIDs adds the "sentences" edge to the Sentence entity by IDs.

func (*UserUpdateOne) AddSentences

func (uuo *UserUpdateOne) AddSentences(s ...*Sentence) *UserUpdateOne

AddSentences adds the "sentences" edges to the Sentence entity.

func (*UserUpdateOne) ClearSentences

func (uuo *UserUpdateOne) ClearSentences() *UserUpdateOne

ClearSentences clears all "sentences" edges to the Sentence entity.

func (*UserUpdateOne) Exec

func (uuo *UserUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

func (uuo *UserUpdateOne) ExecX(ctx context.Context)

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

func (*UserUpdateOne) Mutation

func (uuo *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemoveSentenceIDs

func (uuo *UserUpdateOne) RemoveSentenceIDs(ids ...uuid.UUID) *UserUpdateOne

RemoveSentenceIDs removes the "sentences" edge to Sentence entities by IDs.

func (*UserUpdateOne) RemoveSentences

func (uuo *UserUpdateOne) RemoveSentences(s ...*Sentence) *UserUpdateOne

RemoveSentences removes "sentences" edges to Sentence entities.

func (*UserUpdateOne) Save

func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User

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

func (*UserUpdateOne) Select

func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne

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

func (*UserUpdateOne) SetIPAddress

func (uuo *UserUpdateOne) SetIPAddress(s string) *UserUpdateOne

SetIPAddress sets the "ip_address" field.

func (*UserUpdateOne) Where

func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne

Where appends a list predicates to the UserUpdate builder.

type Users

type Users []*User

Users is a parsable slice of User.

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