ent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeChat = "Chat"
)

Variables

View Source
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")

ErrTxStarted is returned when trying to start a new transaction from a transactional client.

Functions

func Asc

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

Asc applies the given fields in ASC order.

func Desc

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

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Chat

type Chat struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// UserId holds the value of the "userId" field.
	UserId uuid.UUID `json:"userId,omitempty"`
	// Models holds the value of the "models" field.
	Models []string `json:"models,omitempty"`
	// Tags holds the value of the "tags" field.
	Tags []string `json:"tags,omitempty"`
	// History holds the value of the "history" field.
	History v1.History `json:"history,omitempty"`
	// Messages holds the value of the "messages" field.
	Messages []v1.Message `json:"messages,omitempty"`
	// CreatedAt holds the value of the "createdAt" field.
	CreatedAt time.Time `json:"createdAt,omitempty"`
	// contains filtered or unexported fields
}

Chat is the model entity for the Chat schema.

func (*Chat) String

func (c *Chat) String() string

String implements the fmt.Stringer.

func (*Chat) Unwrap

func (c *Chat) Unwrap() *Chat

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

func (c *Chat) Update() *ChatUpdateOne

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

func (*Chat) Value

func (c *Chat) Value(name string) (ent.Value, error)

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

type ChatClient

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

ChatClient is a client for the Chat schema.

func NewChatClient

func NewChatClient(c config) *ChatClient

NewChatClient returns a client for the Chat from the given config.

func (*ChatClient) Create

func (c *ChatClient) Create() *ChatCreate

Create returns a builder for creating a Chat entity.

func (*ChatClient) CreateBulk

func (c *ChatClient) CreateBulk(builders ...*ChatCreate) *ChatCreateBulk

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

func (*ChatClient) Delete

func (c *ChatClient) Delete() *ChatDelete

Delete returns a delete builder for Chat.

func (*ChatClient) DeleteOne

func (c *ChatClient) DeleteOne(ch *Chat) *ChatDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*ChatClient) DeleteOneID

func (c *ChatClient) DeleteOneID(id uuid.UUID) *ChatDeleteOne

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

func (*ChatClient) Get

func (c *ChatClient) Get(ctx context.Context, id uuid.UUID) (*Chat, error)

Get returns a Chat entity by its id.

func (*ChatClient) GetX

func (c *ChatClient) GetX(ctx context.Context, id uuid.UUID) *Chat

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

func (*ChatClient) Hooks

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

Hooks returns the client hooks.

func (*ChatClient) Intercept

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

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

func (*ChatClient) Interceptors

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

Interceptors returns the client interceptors.

func (*ChatClient) MapCreateBulk

func (c *ChatClient) MapCreateBulk(slice any, setFunc func(*ChatCreate, int)) *ChatCreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*ChatClient) Query

func (c *ChatClient) Query() *ChatQuery

Query returns a query builder for Chat.

func (*ChatClient) Update

func (c *ChatClient) Update() *ChatUpdate

Update returns an update builder for Chat.

func (*ChatClient) UpdateOne

func (c *ChatClient) UpdateOne(ch *Chat) *ChatUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ChatClient) UpdateOneID

func (c *ChatClient) UpdateOneID(id uuid.UUID) *ChatUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ChatClient) Use

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

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

type ChatCreate

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

ChatCreate is the builder for creating a Chat entity.

func (*ChatCreate) Exec

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

Exec executes the query.

func (*ChatCreate) ExecX

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

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

func (*ChatCreate) Mutation

func (cc *ChatCreate) Mutation() *ChatMutation

Mutation returns the ChatMutation object of the builder.

func (*ChatCreate) OnConflict

func (cc *ChatCreate) OnConflict(opts ...sql.ConflictOption) *ChatUpsertOne

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

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

func (*ChatCreate) OnConflictColumns

func (cc *ChatCreate) OnConflictColumns(columns ...string) *ChatUpsertOne

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

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

func (*ChatCreate) Save

func (cc *ChatCreate) Save(ctx context.Context) (*Chat, error)

Save creates the Chat in the database.

func (*ChatCreate) SaveX

func (cc *ChatCreate) SaveX(ctx context.Context) *Chat

SaveX calls Save and panics if Save returns an error.

func (*ChatCreate) SetCreatedAt

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

SetCreatedAt sets the "createdAt" field.

func (*ChatCreate) SetHistory

func (cc *ChatCreate) SetHistory(v v1.History) *ChatCreate

SetHistory sets the "history" field.

func (*ChatCreate) SetID

func (cc *ChatCreate) SetID(u uuid.UUID) *ChatCreate

SetID sets the "id" field.

func (*ChatCreate) SetMessages

func (cc *ChatCreate) SetMessages(v []v1.Message) *ChatCreate

SetMessages sets the "messages" field.

func (*ChatCreate) SetModels

func (cc *ChatCreate) SetModels(s []string) *ChatCreate

SetModels sets the "models" field.

func (*ChatCreate) SetNillableCreatedAt

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

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

func (*ChatCreate) SetNillableID

func (cc *ChatCreate) SetNillableID(u *uuid.UUID) *ChatCreate

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

func (*ChatCreate) SetTags

func (cc *ChatCreate) SetTags(s []string) *ChatCreate

SetTags sets the "tags" field.

func (*ChatCreate) SetTitle

func (cc *ChatCreate) SetTitle(s string) *ChatCreate

SetTitle sets the "title" field.

func (*ChatCreate) SetUserId

func (cc *ChatCreate) SetUserId(u uuid.UUID) *ChatCreate

SetUserId sets the "userId" field.

type ChatCreateBulk

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

ChatCreateBulk is the builder for creating many Chat entities in bulk.

func (*ChatCreateBulk) Exec

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

Exec executes the query.

func (*ChatCreateBulk) ExecX

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

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

func (*ChatCreateBulk) OnConflict

func (ccb *ChatCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChatUpsertBulk

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

client.Chat.CreateBulk(builders...).
	OnConflict(
		// Update the row with the new values
		// the was proposed for insertion.
		sql.ResolveWithNewValues(),
	).
	// Override some of the fields with custom
	// update values.
	Update(func(u *ent.ChatUpsert) {
		SetTitle(v+v).
	}).
	Exec(ctx)

func (*ChatCreateBulk) OnConflictColumns

func (ccb *ChatCreateBulk) OnConflictColumns(columns ...string) *ChatUpsertBulk

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

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

func (*ChatCreateBulk) Save

func (ccb *ChatCreateBulk) Save(ctx context.Context) ([]*Chat, error)

Save creates the Chat entities in the database.

func (*ChatCreateBulk) SaveX

func (ccb *ChatCreateBulk) SaveX(ctx context.Context) []*Chat

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

type ChatDelete

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

ChatDelete is the builder for deleting a Chat entity.

func (*ChatDelete) Exec

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

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

func (*ChatDelete) ExecX

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

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

func (*ChatDelete) Where

func (cd *ChatDelete) Where(ps ...predicate.Chat) *ChatDelete

Where appends a list predicates to the ChatDelete builder.

type ChatDeleteOne

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

ChatDeleteOne is the builder for deleting a single Chat entity.

func (*ChatDeleteOne) Exec

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

Exec executes the deletion query.

func (*ChatDeleteOne) ExecX

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

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

func (*ChatDeleteOne) Where

func (cdo *ChatDeleteOne) Where(ps ...predicate.Chat) *ChatDeleteOne

Where appends a list predicates to the ChatDelete builder.

type ChatGroupBy

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

ChatGroupBy is the group-by builder for Chat entities.

func (*ChatGroupBy) Aggregate

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

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

func (*ChatGroupBy) Bool

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

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

func (*ChatGroupBy) BoolX

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

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

func (*ChatGroupBy) Bools

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

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

func (*ChatGroupBy) BoolsX

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

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

func (*ChatGroupBy) Float64

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

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

func (*ChatGroupBy) Float64X

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

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

func (*ChatGroupBy) Float64s

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

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

func (*ChatGroupBy) Float64sX

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

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

func (*ChatGroupBy) Int

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

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

func (*ChatGroupBy) IntX

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

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

func (*ChatGroupBy) Ints

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

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

func (*ChatGroupBy) IntsX

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

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

func (*ChatGroupBy) Scan

func (cgb *ChatGroupBy) Scan(ctx context.Context, v any) error

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

func (*ChatGroupBy) ScanX

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

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

func (*ChatGroupBy) String

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

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

func (*ChatGroupBy) StringX

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

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

func (*ChatGroupBy) Strings

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

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

func (*ChatGroupBy) StringsX

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

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

type ChatMutation

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

ChatMutation represents an operation that mutates the Chat nodes in the graph.

func (*ChatMutation) AddField

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

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

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

func (*ChatMutation) AddedField

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

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

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

func (*ChatMutation) AddedIDs

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

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

func (*ChatMutation) AppendMessages

func (m *ChatMutation) AppendMessages(v []v1.Message)

AppendMessages adds v to the "messages" field.

func (*ChatMutation) AppendModels

func (m *ChatMutation) AppendModels(s []string)

AppendModels adds s to the "models" field.

func (*ChatMutation) AppendTags

func (m *ChatMutation) AppendTags(s []string)

AppendTags adds s to the "tags" field.

func (*ChatMutation) AppendedMessages

func (m *ChatMutation) AppendedMessages() ([]v1.Message, bool)

AppendedMessages returns the list of values that were appended to the "messages" field in this mutation.

func (*ChatMutation) AppendedModels

func (m *ChatMutation) AppendedModels() ([]string, bool)

AppendedModels returns the list of values that were appended to the "models" field in this mutation.

func (*ChatMutation) AppendedTags

func (m *ChatMutation) AppendedTags() ([]string, bool)

AppendedTags returns the list of values that were appended to the "tags" field in this mutation.

func (*ChatMutation) ClearEdge

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

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

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

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

func (*ChatMutation) ClearedFields

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

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

func (ChatMutation) Client

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

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

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

func (*ChatMutation) EdgeCleared

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

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

func (*ChatMutation) Field

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

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

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

func (*ChatMutation) Fields

func (m *ChatMutation) 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 (*ChatMutation) History

func (m *ChatMutation) History() (r v1.History, exists bool)

History returns the value of the "history" field in the mutation.

func (*ChatMutation) ID

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

func (m *ChatMutation) 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 (*ChatMutation) Messages

func (m *ChatMutation) Messages() (r []v1.Message, exists bool)

Messages returns the value of the "messages" field in the mutation.

func (*ChatMutation) Models

func (m *ChatMutation) Models() (r []string, exists bool)

Models returns the value of the "models" field in the mutation.

func (*ChatMutation) OldCreatedAt

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

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

func (m *ChatMutation) 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 (*ChatMutation) OldHistory

func (m *ChatMutation) OldHistory(ctx context.Context) (v v1.History, err error)

OldHistory returns the old "history" field's value of the Chat entity. If the Chat 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 (*ChatMutation) OldMessages

func (m *ChatMutation) OldMessages(ctx context.Context) (v []v1.Message, err error)

OldMessages returns the old "messages" field's value of the Chat entity. If the Chat 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 (*ChatMutation) OldModels

func (m *ChatMutation) OldModels(ctx context.Context) (v []string, err error)

OldModels returns the old "models" field's value of the Chat entity. If the Chat 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 (*ChatMutation) OldTags

func (m *ChatMutation) OldTags(ctx context.Context) (v []string, err error)

OldTags returns the old "tags" field's value of the Chat entity. If the Chat 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 (*ChatMutation) OldTitle

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

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

func (m *ChatMutation) OldUserId(ctx context.Context) (v uuid.UUID, err error)

OldUserId returns the old "userId" field's value of the Chat entity. If the Chat 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 (*ChatMutation) Op

func (m *ChatMutation) Op() Op

Op returns the operation name.

func (*ChatMutation) RemovedEdges

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

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

func (*ChatMutation) RemovedIDs

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

func (m *ChatMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "createdAt" field.

func (*ChatMutation) ResetEdge

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

func (m *ChatMutation) 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 (*ChatMutation) ResetHistory

func (m *ChatMutation) ResetHistory()

ResetHistory resets all changes to the "history" field.

func (*ChatMutation) ResetMessages

func (m *ChatMutation) ResetMessages()

ResetMessages resets all changes to the "messages" field.

func (*ChatMutation) ResetModels

func (m *ChatMutation) ResetModels()

ResetModels resets all changes to the "models" field.

func (*ChatMutation) ResetTags

func (m *ChatMutation) ResetTags()

ResetTags resets all changes to the "tags" field.

func (*ChatMutation) ResetTitle

func (m *ChatMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*ChatMutation) ResetUserId

func (m *ChatMutation) ResetUserId()

ResetUserId resets all changes to the "userId" field.

func (*ChatMutation) SetCreatedAt

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

SetCreatedAt sets the "createdAt" field.

func (*ChatMutation) SetField

func (m *ChatMutation) 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 (*ChatMutation) SetHistory

func (m *ChatMutation) SetHistory(v v1.History)

SetHistory sets the "history" field.

func (*ChatMutation) SetID

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

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

func (*ChatMutation) SetMessages

func (m *ChatMutation) SetMessages(v []v1.Message)

SetMessages sets the "messages" field.

func (*ChatMutation) SetModels

func (m *ChatMutation) SetModels(s []string)

SetModels sets the "models" field.

func (*ChatMutation) SetOp

func (m *ChatMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*ChatMutation) SetTags

func (m *ChatMutation) SetTags(s []string)

SetTags sets the "tags" field.

func (*ChatMutation) SetTitle

func (m *ChatMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*ChatMutation) SetUserId

func (m *ChatMutation) SetUserId(u uuid.UUID)

SetUserId sets the "userId" field.

func (*ChatMutation) Tags

func (m *ChatMutation) Tags() (r []string, exists bool)

Tags returns the value of the "tags" field in the mutation.

func (*ChatMutation) Title

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

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

func (ChatMutation) Tx

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

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

func (*ChatMutation) Type

func (m *ChatMutation) Type() string

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

func (*ChatMutation) UserId

func (m *ChatMutation) UserId() (r uuid.UUID, exists bool)

UserId returns the value of the "userId" field in the mutation.

func (*ChatMutation) Where

func (m *ChatMutation) Where(ps ...predicate.Chat)

Where appends a list predicates to the ChatMutation builder.

func (*ChatMutation) WhereP

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

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

type ChatQuery

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

ChatQuery is the builder for querying Chat entities.

func (*ChatQuery) Aggregate

func (cq *ChatQuery) Aggregate(fns ...AggregateFunc) *ChatSelect

Aggregate returns a ChatSelect configured with the given aggregations.

func (*ChatQuery) All

func (cq *ChatQuery) All(ctx context.Context) ([]*Chat, error)

All executes the query and returns a list of Chats.

func (*ChatQuery) AllX

func (cq *ChatQuery) AllX(ctx context.Context) []*Chat

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

func (*ChatQuery) Clone

func (cq *ChatQuery) Clone() *ChatQuery

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

func (*ChatQuery) Count

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

Count returns the count of the given query.

func (*ChatQuery) CountX

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

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

func (*ChatQuery) Exist

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

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

func (*ChatQuery) ExistX

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

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

func (*ChatQuery) First

func (cq *ChatQuery) First(ctx context.Context) (*Chat, error)

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

func (*ChatQuery) FirstID

func (cq *ChatQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*ChatQuery) FirstIDX

func (cq *ChatQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*ChatQuery) FirstX

func (cq *ChatQuery) FirstX(ctx context.Context) *Chat

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

func (*ChatQuery) GroupBy

func (cq *ChatQuery) GroupBy(field string, fields ...string) *ChatGroupBy

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

client.Chat.Query().
	GroupBy(chat.FieldTitle).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ChatQuery) IDs

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

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

func (*ChatQuery) IDsX

func (cq *ChatQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*ChatQuery) Limit

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

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

func (*ChatQuery) Offset

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

Offset to start from.

func (*ChatQuery) Only

func (cq *ChatQuery) Only(ctx context.Context) (*Chat, error)

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

func (*ChatQuery) OnlyID

func (cq *ChatQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*ChatQuery) OnlyIDX

func (cq *ChatQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*ChatQuery) OnlyX

func (cq *ChatQuery) OnlyX(ctx context.Context) *Chat

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

func (*ChatQuery) Order

func (cq *ChatQuery) Order(o ...chat.OrderOption) *ChatQuery

Order specifies how the records should be ordered.

func (*ChatQuery) Select

func (cq *ChatQuery) Select(fields ...string) *ChatSelect

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

client.Chat.Query().
	Select(chat.FieldTitle).
	Scan(ctx, &v)

func (*ChatQuery) Unique

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

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

func (cq *ChatQuery) Where(ps ...predicate.Chat) *ChatQuery

Where adds a new predicate for the ChatQuery builder.

type ChatSelect

type ChatSelect struct {
	*ChatQuery
	// contains filtered or unexported fields
}

ChatSelect is the builder for selecting fields of Chat entities.

func (*ChatSelect) Aggregate

func (cs *ChatSelect) Aggregate(fns ...AggregateFunc) *ChatSelect

Aggregate adds the given aggregation functions to the selector query.

func (*ChatSelect) Bool

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

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

func (*ChatSelect) BoolX

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

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

func (*ChatSelect) Bools

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

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

func (*ChatSelect) BoolsX

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

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

func (*ChatSelect) Float64

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

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

func (*ChatSelect) Float64X

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

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

func (*ChatSelect) Float64s

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

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

func (*ChatSelect) Float64sX

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

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

func (*ChatSelect) Int

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

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

func (*ChatSelect) IntX

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

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

func (*ChatSelect) Ints

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

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

func (*ChatSelect) IntsX

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

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

func (*ChatSelect) Scan

func (cs *ChatSelect) Scan(ctx context.Context, v any) error

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

func (*ChatSelect) ScanX

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

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

func (*ChatSelect) String

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

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

func (*ChatSelect) StringX

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

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

func (*ChatSelect) Strings

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

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

func (*ChatSelect) StringsX

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

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

type ChatUpdate

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

ChatUpdate is the builder for updating Chat entities.

func (*ChatUpdate) AppendMessages

func (cu *ChatUpdate) AppendMessages(v []v1.Message) *ChatUpdate

AppendMessages appends v to the "messages" field.

func (*ChatUpdate) AppendModels

func (cu *ChatUpdate) AppendModels(s []string) *ChatUpdate

AppendModels appends s to the "models" field.

func (*ChatUpdate) AppendTags

func (cu *ChatUpdate) AppendTags(s []string) *ChatUpdate

AppendTags appends s to the "tags" field.

func (*ChatUpdate) Exec

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

Exec executes the query.

func (*ChatUpdate) ExecX

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

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

func (*ChatUpdate) Mutation

func (cu *ChatUpdate) Mutation() *ChatMutation

Mutation returns the ChatMutation object of the builder.

func (*ChatUpdate) Save

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

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

func (*ChatUpdate) SaveX

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

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

func (*ChatUpdate) SetHistory

func (cu *ChatUpdate) SetHistory(v v1.History) *ChatUpdate

SetHistory sets the "history" field.

func (*ChatUpdate) SetMessages

func (cu *ChatUpdate) SetMessages(v []v1.Message) *ChatUpdate

SetMessages sets the "messages" field.

func (*ChatUpdate) SetModels

func (cu *ChatUpdate) SetModels(s []string) *ChatUpdate

SetModels sets the "models" field.

func (*ChatUpdate) SetNillableHistory

func (cu *ChatUpdate) SetNillableHistory(v *v1.History) *ChatUpdate

SetNillableHistory sets the "history" field if the given value is not nil.

func (*ChatUpdate) SetNillableTitle

func (cu *ChatUpdate) SetNillableTitle(s *string) *ChatUpdate

SetNillableTitle sets the "title" field if the given value is not nil.

func (*ChatUpdate) SetNillableUserId

func (cu *ChatUpdate) SetNillableUserId(u *uuid.UUID) *ChatUpdate

SetNillableUserId sets the "userId" field if the given value is not nil.

func (*ChatUpdate) SetTags

func (cu *ChatUpdate) SetTags(s []string) *ChatUpdate

SetTags sets the "tags" field.

func (*ChatUpdate) SetTitle

func (cu *ChatUpdate) SetTitle(s string) *ChatUpdate

SetTitle sets the "title" field.

func (*ChatUpdate) SetUserId

func (cu *ChatUpdate) SetUserId(u uuid.UUID) *ChatUpdate

SetUserId sets the "userId" field.

func (*ChatUpdate) Where

func (cu *ChatUpdate) Where(ps ...predicate.Chat) *ChatUpdate

Where appends a list predicates to the ChatUpdate builder.

type ChatUpdateOne

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

ChatUpdateOne is the builder for updating a single Chat entity.

func (*ChatUpdateOne) AppendMessages

func (cuo *ChatUpdateOne) AppendMessages(v []v1.Message) *ChatUpdateOne

AppendMessages appends v to the "messages" field.

func (*ChatUpdateOne) AppendModels

func (cuo *ChatUpdateOne) AppendModels(s []string) *ChatUpdateOne

AppendModels appends s to the "models" field.

func (*ChatUpdateOne) AppendTags

func (cuo *ChatUpdateOne) AppendTags(s []string) *ChatUpdateOne

AppendTags appends s to the "tags" field.

func (*ChatUpdateOne) Exec

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

Exec executes the query on the entity.

func (*ChatUpdateOne) ExecX

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

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

func (*ChatUpdateOne) Mutation

func (cuo *ChatUpdateOne) Mutation() *ChatMutation

Mutation returns the ChatMutation object of the builder.

func (*ChatUpdateOne) Save

func (cuo *ChatUpdateOne) Save(ctx context.Context) (*Chat, error)

Save executes the query and returns the updated Chat entity.

func (*ChatUpdateOne) SaveX

func (cuo *ChatUpdateOne) SaveX(ctx context.Context) *Chat

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

func (*ChatUpdateOne) Select

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

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

func (*ChatUpdateOne) SetHistory

func (cuo *ChatUpdateOne) SetHistory(v v1.History) *ChatUpdateOne

SetHistory sets the "history" field.

func (*ChatUpdateOne) SetMessages

func (cuo *ChatUpdateOne) SetMessages(v []v1.Message) *ChatUpdateOne

SetMessages sets the "messages" field.

func (*ChatUpdateOne) SetModels

func (cuo *ChatUpdateOne) SetModels(s []string) *ChatUpdateOne

SetModels sets the "models" field.

func (*ChatUpdateOne) SetNillableHistory

func (cuo *ChatUpdateOne) SetNillableHistory(v *v1.History) *ChatUpdateOne

SetNillableHistory sets the "history" field if the given value is not nil.

func (*ChatUpdateOne) SetNillableTitle

func (cuo *ChatUpdateOne) SetNillableTitle(s *string) *ChatUpdateOne

SetNillableTitle sets the "title" field if the given value is not nil.

func (*ChatUpdateOne) SetNillableUserId

func (cuo *ChatUpdateOne) SetNillableUserId(u *uuid.UUID) *ChatUpdateOne

SetNillableUserId sets the "userId" field if the given value is not nil.

func (*ChatUpdateOne) SetTags

func (cuo *ChatUpdateOne) SetTags(s []string) *ChatUpdateOne

SetTags sets the "tags" field.

func (*ChatUpdateOne) SetTitle

func (cuo *ChatUpdateOne) SetTitle(s string) *ChatUpdateOne

SetTitle sets the "title" field.

func (*ChatUpdateOne) SetUserId

func (cuo *ChatUpdateOne) SetUserId(u uuid.UUID) *ChatUpdateOne

SetUserId sets the "userId" field.

func (*ChatUpdateOne) Where

func (cuo *ChatUpdateOne) Where(ps ...predicate.Chat) *ChatUpdateOne

Where appends a list predicates to the ChatUpdate builder.

type ChatUpsert

type ChatUpsert struct {
	*sql.UpdateSet
}

ChatUpsert is the "OnConflict" setter.

func (*ChatUpsert) SetHistory

func (u *ChatUpsert) SetHistory(v v1.History) *ChatUpsert

SetHistory sets the "history" field.

func (*ChatUpsert) SetMessages

func (u *ChatUpsert) SetMessages(v []v1.Message) *ChatUpsert

SetMessages sets the "messages" field.

func (*ChatUpsert) SetModels

func (u *ChatUpsert) SetModels(v []string) *ChatUpsert

SetModels sets the "models" field.

func (*ChatUpsert) SetTags

func (u *ChatUpsert) SetTags(v []string) *ChatUpsert

SetTags sets the "tags" field.

func (*ChatUpsert) SetTitle

func (u *ChatUpsert) SetTitle(v string) *ChatUpsert

SetTitle sets the "title" field.

func (*ChatUpsert) SetUserId

func (u *ChatUpsert) SetUserId(v uuid.UUID) *ChatUpsert

SetUserId sets the "userId" field.

func (*ChatUpsert) UpdateHistory

func (u *ChatUpsert) UpdateHistory() *ChatUpsert

UpdateHistory sets the "history" field to the value that was provided on create.

func (*ChatUpsert) UpdateMessages

func (u *ChatUpsert) UpdateMessages() *ChatUpsert

UpdateMessages sets the "messages" field to the value that was provided on create.

func (*ChatUpsert) UpdateModels

func (u *ChatUpsert) UpdateModels() *ChatUpsert

UpdateModels sets the "models" field to the value that was provided on create.

func (*ChatUpsert) UpdateTags

func (u *ChatUpsert) UpdateTags() *ChatUpsert

UpdateTags sets the "tags" field to the value that was provided on create.

func (*ChatUpsert) UpdateTitle

func (u *ChatUpsert) UpdateTitle() *ChatUpsert

UpdateTitle sets the "title" field to the value that was provided on create.

func (*ChatUpsert) UpdateUserId

func (u *ChatUpsert) UpdateUserId() *ChatUpsert

UpdateUserId sets the "userId" field to the value that was provided on create.

type ChatUpsertBulk

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

ChatUpsertBulk is the builder for "upsert"-ing a bulk of Chat nodes.

func (*ChatUpsertBulk) DoNothing

func (u *ChatUpsertBulk) DoNothing() *ChatUpsertBulk

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

func (*ChatUpsertBulk) Exec

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

Exec executes the query.

func (*ChatUpsertBulk) ExecX

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

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

func (*ChatUpsertBulk) Ignore

func (u *ChatUpsertBulk) Ignore() *ChatUpsertBulk

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

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

func (*ChatUpsertBulk) SetHistory

func (u *ChatUpsertBulk) SetHistory(v v1.History) *ChatUpsertBulk

SetHistory sets the "history" field.

func (*ChatUpsertBulk) SetMessages

func (u *ChatUpsertBulk) SetMessages(v []v1.Message) *ChatUpsertBulk

SetMessages sets the "messages" field.

func (*ChatUpsertBulk) SetModels

func (u *ChatUpsertBulk) SetModels(v []string) *ChatUpsertBulk

SetModels sets the "models" field.

func (*ChatUpsertBulk) SetTags

func (u *ChatUpsertBulk) SetTags(v []string) *ChatUpsertBulk

SetTags sets the "tags" field.

func (*ChatUpsertBulk) SetTitle

func (u *ChatUpsertBulk) SetTitle(v string) *ChatUpsertBulk

SetTitle sets the "title" field.

func (*ChatUpsertBulk) SetUserId

func (u *ChatUpsertBulk) SetUserId(v uuid.UUID) *ChatUpsertBulk

SetUserId sets the "userId" field.

func (*ChatUpsertBulk) Update

func (u *ChatUpsertBulk) Update(set func(*ChatUpsert)) *ChatUpsertBulk

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

func (*ChatUpsertBulk) UpdateHistory

func (u *ChatUpsertBulk) UpdateHistory() *ChatUpsertBulk

UpdateHistory sets the "history" field to the value that was provided on create.

func (*ChatUpsertBulk) UpdateMessages

func (u *ChatUpsertBulk) UpdateMessages() *ChatUpsertBulk

UpdateMessages sets the "messages" field to the value that was provided on create.

func (*ChatUpsertBulk) UpdateModels

func (u *ChatUpsertBulk) UpdateModels() *ChatUpsertBulk

UpdateModels sets the "models" field to the value that was provided on create.

func (*ChatUpsertBulk) UpdateNewValues

func (u *ChatUpsertBulk) UpdateNewValues() *ChatUpsertBulk

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

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

func (*ChatUpsertBulk) UpdateTags

func (u *ChatUpsertBulk) UpdateTags() *ChatUpsertBulk

UpdateTags sets the "tags" field to the value that was provided on create.

func (*ChatUpsertBulk) UpdateTitle

func (u *ChatUpsertBulk) UpdateTitle() *ChatUpsertBulk

UpdateTitle sets the "title" field to the value that was provided on create.

func (*ChatUpsertBulk) UpdateUserId

func (u *ChatUpsertBulk) UpdateUserId() *ChatUpsertBulk

UpdateUserId sets the "userId" field to the value that was provided on create.

type ChatUpsertOne

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

ChatUpsertOne is the builder for "upsert"-ing

one Chat node.

func (*ChatUpsertOne) DoNothing

func (u *ChatUpsertOne) DoNothing() *ChatUpsertOne

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

func (*ChatUpsertOne) Exec

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

Exec executes the query.

func (*ChatUpsertOne) ExecX

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

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

func (*ChatUpsertOne) ID

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

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

func (*ChatUpsertOne) IDX

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

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

func (*ChatUpsertOne) Ignore

func (u *ChatUpsertOne) Ignore() *ChatUpsertOne

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

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

func (*ChatUpsertOne) SetHistory

func (u *ChatUpsertOne) SetHistory(v v1.History) *ChatUpsertOne

SetHistory sets the "history" field.

func (*ChatUpsertOne) SetMessages

func (u *ChatUpsertOne) SetMessages(v []v1.Message) *ChatUpsertOne

SetMessages sets the "messages" field.

func (*ChatUpsertOne) SetModels

func (u *ChatUpsertOne) SetModels(v []string) *ChatUpsertOne

SetModels sets the "models" field.

func (*ChatUpsertOne) SetTags

func (u *ChatUpsertOne) SetTags(v []string) *ChatUpsertOne

SetTags sets the "tags" field.

func (*ChatUpsertOne) SetTitle

func (u *ChatUpsertOne) SetTitle(v string) *ChatUpsertOne

SetTitle sets the "title" field.

func (*ChatUpsertOne) SetUserId

func (u *ChatUpsertOne) SetUserId(v uuid.UUID) *ChatUpsertOne

SetUserId sets the "userId" field.

func (*ChatUpsertOne) Update

func (u *ChatUpsertOne) Update(set func(*ChatUpsert)) *ChatUpsertOne

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

func (*ChatUpsertOne) UpdateHistory

func (u *ChatUpsertOne) UpdateHistory() *ChatUpsertOne

UpdateHistory sets the "history" field to the value that was provided on create.

func (*ChatUpsertOne) UpdateMessages

func (u *ChatUpsertOne) UpdateMessages() *ChatUpsertOne

UpdateMessages sets the "messages" field to the value that was provided on create.

func (*ChatUpsertOne) UpdateModels

func (u *ChatUpsertOne) UpdateModels() *ChatUpsertOne

UpdateModels sets the "models" field to the value that was provided on create.

func (*ChatUpsertOne) UpdateNewValues

func (u *ChatUpsertOne) UpdateNewValues() *ChatUpsertOne

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

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

func (*ChatUpsertOne) UpdateTags

func (u *ChatUpsertOne) UpdateTags() *ChatUpsertOne

UpdateTags sets the "tags" field to the value that was provided on create.

func (*ChatUpsertOne) UpdateTitle

func (u *ChatUpsertOne) UpdateTitle() *ChatUpsertOne

UpdateTitle sets the "title" field to the value that was provided on create.

func (*ChatUpsertOne) UpdateUserId

func (u *ChatUpsertOne) UpdateUserId() *ChatUpsertOne

UpdateUserId sets the "userId" field to the value that was provided on create.

type Chats

type Chats []*Chat

Chats is a parsable slice of Chat.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Chat is the client for interacting with the Chat builders.
	Chat *ChatClient
	// 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().
	Chat.
	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 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 {

	// Chat is the client for interacting with the Chat builders.
	Chat *ChatClient
	// contains filtered or unexported fields
}

Tx is a transactional client that is created by calling Client.Tx().

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

TxFromContext returns a Tx stored inside a context, or nil if there isn't one.

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidationError

type ValidationError struct {
	Name string // Field or edge name.
	// contains filtered or unexported fields
}

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL