ent

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: CC0-1.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeChatMessage  = "ChatMessage"
	TypeConversation = "Conversation"
)

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 ChatMessage

type ChatMessage struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// ConversationID holds the value of the "conversation_id" field.
	ConversationID string `json:"conversation_id,omitempty"`
	// Role holds the value of the "role" field.
	Role string `json:"role,omitempty"`
	// Content holds the value of the "content" field.
	Content string `json:"content,omitempty"`
	// contains filtered or unexported fields
}

ChatMessage is the model entity for the ChatMessage schema.

func (*ChatMessage) String

func (cm *ChatMessage) String() string

String implements the fmt.Stringer.

func (*ChatMessage) Unwrap

func (cm *ChatMessage) Unwrap() *ChatMessage

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

func (cm *ChatMessage) Update() *ChatMessageUpdateOne

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

func (*ChatMessage) Value

func (cm *ChatMessage) Value(name string) (ent.Value, error)

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

type ChatMessageClient

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

ChatMessageClient is a client for the ChatMessage schema.

func NewChatMessageClient

func NewChatMessageClient(c config) *ChatMessageClient

NewChatMessageClient returns a client for the ChatMessage from the given config.

func (*ChatMessageClient) Create

func (c *ChatMessageClient) Create() *ChatMessageCreate

Create returns a builder for creating a ChatMessage entity.

func (*ChatMessageClient) CreateBulk

func (c *ChatMessageClient) CreateBulk(builders ...*ChatMessageCreate) *ChatMessageCreateBulk

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

func (*ChatMessageClient) Delete

func (c *ChatMessageClient) Delete() *ChatMessageDelete

Delete returns a delete builder for ChatMessage.

func (*ChatMessageClient) DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*ChatMessageClient) DeleteOneID

func (c *ChatMessageClient) DeleteOneID(id string) *ChatMessageDeleteOne

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

func (*ChatMessageClient) Get

Get returns a ChatMessage entity by its id.

func (*ChatMessageClient) GetX

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

func (*ChatMessageClient) Hooks

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

Hooks returns the client hooks.

func (*ChatMessageClient) Intercept

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

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

func (*ChatMessageClient) Interceptors

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

Interceptors returns the client interceptors.

func (*ChatMessageClient) MapCreateBulk

func (c *ChatMessageClient) MapCreateBulk(slice any, setFunc func(*ChatMessageCreate, int)) *ChatMessageCreateBulk

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

func (c *ChatMessageClient) Query() *ChatMessageQuery

Query returns a query builder for ChatMessage.

func (*ChatMessageClient) Update

func (c *ChatMessageClient) Update() *ChatMessageUpdate

Update returns an update builder for ChatMessage.

func (*ChatMessageClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*ChatMessageClient) UpdateOneID

func (c *ChatMessageClient) UpdateOneID(id string) *ChatMessageUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ChatMessageClient) Use

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

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

type ChatMessageCreate

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

ChatMessageCreate is the builder for creating a ChatMessage entity.

func (*ChatMessageCreate) Exec

func (cmc *ChatMessageCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*ChatMessageCreate) ExecX

func (cmc *ChatMessageCreate) ExecX(ctx context.Context)

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

func (*ChatMessageCreate) Mutation

func (cmc *ChatMessageCreate) Mutation() *ChatMessageMutation

Mutation returns the ChatMessageMutation object of the builder.

func (*ChatMessageCreate) Save

func (cmc *ChatMessageCreate) Save(ctx context.Context) (*ChatMessage, error)

Save creates the ChatMessage in the database.

func (*ChatMessageCreate) SaveX

func (cmc *ChatMessageCreate) SaveX(ctx context.Context) *ChatMessage

SaveX calls Save and panics if Save returns an error.

func (*ChatMessageCreate) SetContent

func (cmc *ChatMessageCreate) SetContent(s string) *ChatMessageCreate

SetContent sets the "content" field.

func (*ChatMessageCreate) SetConversationID

func (cmc *ChatMessageCreate) SetConversationID(s string) *ChatMessageCreate

SetConversationID sets the "conversation_id" field.

func (*ChatMessageCreate) SetID

SetID sets the "id" field.

func (*ChatMessageCreate) SetRole

func (cmc *ChatMessageCreate) SetRole(s string) *ChatMessageCreate

SetRole sets the "role" field.

type ChatMessageCreateBulk

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

ChatMessageCreateBulk is the builder for creating many ChatMessage entities in bulk.

func (*ChatMessageCreateBulk) Exec

func (cmcb *ChatMessageCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*ChatMessageCreateBulk) ExecX

func (cmcb *ChatMessageCreateBulk) ExecX(ctx context.Context)

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

func (*ChatMessageCreateBulk) Save

func (cmcb *ChatMessageCreateBulk) Save(ctx context.Context) ([]*ChatMessage, error)

Save creates the ChatMessage entities in the database.

func (*ChatMessageCreateBulk) SaveX

func (cmcb *ChatMessageCreateBulk) SaveX(ctx context.Context) []*ChatMessage

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

type ChatMessageDelete

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

ChatMessageDelete is the builder for deleting a ChatMessage entity.

func (*ChatMessageDelete) Exec

func (cmd *ChatMessageDelete) Exec(ctx context.Context) (int, error)

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

func (*ChatMessageDelete) ExecX

func (cmd *ChatMessageDelete) ExecX(ctx context.Context) int

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

func (*ChatMessageDelete) Where

Where appends a list predicates to the ChatMessageDelete builder.

type ChatMessageDeleteOne

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

ChatMessageDeleteOne is the builder for deleting a single ChatMessage entity.

func (*ChatMessageDeleteOne) Exec

func (cmdo *ChatMessageDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*ChatMessageDeleteOne) ExecX

func (cmdo *ChatMessageDeleteOne) ExecX(ctx context.Context)

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

func (*ChatMessageDeleteOne) Where

Where appends a list predicates to the ChatMessageDelete builder.

type ChatMessageGroupBy

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

ChatMessageGroupBy is the group-by builder for ChatMessage entities.

func (*ChatMessageGroupBy) Aggregate

func (cmgb *ChatMessageGroupBy) Aggregate(fns ...AggregateFunc) *ChatMessageGroupBy

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

func (*ChatMessageGroupBy) Bool

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

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

func (*ChatMessageGroupBy) BoolX

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

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

func (*ChatMessageGroupBy) Bools

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

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

func (*ChatMessageGroupBy) BoolsX

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

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

func (*ChatMessageGroupBy) Float64

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

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

func (*ChatMessageGroupBy) Float64X

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

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

func (*ChatMessageGroupBy) Float64s

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

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

func (*ChatMessageGroupBy) Float64sX

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

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

func (*ChatMessageGroupBy) Int

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

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

func (*ChatMessageGroupBy) IntX

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

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

func (*ChatMessageGroupBy) Ints

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

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

func (*ChatMessageGroupBy) IntsX

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

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

func (*ChatMessageGroupBy) Scan

func (cmgb *ChatMessageGroupBy) Scan(ctx context.Context, v any) error

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

func (*ChatMessageGroupBy) ScanX

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

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

func (*ChatMessageGroupBy) String

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

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

func (*ChatMessageGroupBy) StringX

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

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

func (*ChatMessageGroupBy) Strings

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

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

func (*ChatMessageGroupBy) StringsX

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

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

type ChatMessageMutation

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

ChatMessageMutation represents an operation that mutates the ChatMessage nodes in the graph.

func (*ChatMessageMutation) AddField

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

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

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

func (*ChatMessageMutation) AddedField

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

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

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

func (*ChatMessageMutation) AddedIDs

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

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

func (*ChatMessageMutation) ClearEdge

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

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

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

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

func (*ChatMessageMutation) ClearedFields

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

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

func (ChatMessageMutation) Client

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

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

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

func (*ChatMessageMutation) ConversationID

func (m *ChatMessageMutation) ConversationID() (r string, exists bool)

ConversationID returns the value of the "conversation_id" field in the mutation.

func (*ChatMessageMutation) EdgeCleared

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

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

func (*ChatMessageMutation) Field

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

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

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

func (*ChatMessageMutation) Fields

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

func (m *ChatMessageMutation) ID() (id string, 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 (*ChatMessageMutation) IDs

func (m *ChatMessageMutation) IDs(ctx context.Context) ([]string, 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 (*ChatMessageMutation) OldContent

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

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

func (m *ChatMessageMutation) OldConversationID(ctx context.Context) (v string, err error)

OldConversationID returns the old "conversation_id" field's value of the ChatMessage entity. If the ChatMessage 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 (*ChatMessageMutation) OldField

func (m *ChatMessageMutation) 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 (*ChatMessageMutation) OldRole

func (m *ChatMessageMutation) OldRole(ctx context.Context) (v string, err error)

OldRole returns the old "role" field's value of the ChatMessage entity. If the ChatMessage 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 (*ChatMessageMutation) Op

func (m *ChatMessageMutation) Op() Op

Op returns the operation name.

func (*ChatMessageMutation) RemovedEdges

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

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

func (*ChatMessageMutation) RemovedIDs

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

func (m *ChatMessageMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*ChatMessageMutation) ResetConversationID

func (m *ChatMessageMutation) ResetConversationID()

ResetConversationID resets all changes to the "conversation_id" field.

func (*ChatMessageMutation) ResetEdge

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

func (m *ChatMessageMutation) 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 (*ChatMessageMutation) ResetRole

func (m *ChatMessageMutation) ResetRole()

ResetRole resets all changes to the "role" field.

func (*ChatMessageMutation) Role

func (m *ChatMessageMutation) Role() (r string, exists bool)

Role returns the value of the "role" field in the mutation.

func (*ChatMessageMutation) SetContent

func (m *ChatMessageMutation) SetContent(s string)

SetContent sets the "content" field.

func (*ChatMessageMutation) SetConversationID

func (m *ChatMessageMutation) SetConversationID(s string)

SetConversationID sets the "conversation_id" field.

func (*ChatMessageMutation) SetField

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

func (m *ChatMessageMutation) SetID(id string)

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

func (*ChatMessageMutation) SetOp

func (m *ChatMessageMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*ChatMessageMutation) SetRole

func (m *ChatMessageMutation) SetRole(s string)

SetRole sets the "role" field.

func (ChatMessageMutation) Tx

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

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

func (*ChatMessageMutation) Type

func (m *ChatMessageMutation) Type() string

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

func (*ChatMessageMutation) Where

func (m *ChatMessageMutation) Where(ps ...predicate.ChatMessage)

Where appends a list predicates to the ChatMessageMutation builder.

func (*ChatMessageMutation) WhereP

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

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

type ChatMessageQuery

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

ChatMessageQuery is the builder for querying ChatMessage entities.

func (*ChatMessageQuery) Aggregate

func (cmq *ChatMessageQuery) Aggregate(fns ...AggregateFunc) *ChatMessageSelect

Aggregate returns a ChatMessageSelect configured with the given aggregations.

func (*ChatMessageQuery) All

func (cmq *ChatMessageQuery) All(ctx context.Context) ([]*ChatMessage, error)

All executes the query and returns a list of ChatMessages.

func (*ChatMessageQuery) AllX

func (cmq *ChatMessageQuery) AllX(ctx context.Context) []*ChatMessage

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

func (*ChatMessageQuery) Clone

func (cmq *ChatMessageQuery) Clone() *ChatMessageQuery

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

func (*ChatMessageQuery) Count

func (cmq *ChatMessageQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*ChatMessageQuery) CountX

func (cmq *ChatMessageQuery) CountX(ctx context.Context) int

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

func (*ChatMessageQuery) Exist

func (cmq *ChatMessageQuery) Exist(ctx context.Context) (bool, error)

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

func (*ChatMessageQuery) ExistX

func (cmq *ChatMessageQuery) ExistX(ctx context.Context) bool

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

func (*ChatMessageQuery) First

func (cmq *ChatMessageQuery) First(ctx context.Context) (*ChatMessage, error)

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

func (*ChatMessageQuery) FirstID

func (cmq *ChatMessageQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*ChatMessageQuery) FirstIDX

func (cmq *ChatMessageQuery) FirstIDX(ctx context.Context) string

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

func (*ChatMessageQuery) FirstX

func (cmq *ChatMessageQuery) FirstX(ctx context.Context) *ChatMessage

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

func (*ChatMessageQuery) GroupBy

func (cmq *ChatMessageQuery) GroupBy(field string, fields ...string) *ChatMessageGroupBy

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

client.ChatMessage.Query().
	GroupBy(chatmessage.FieldConversationID).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ChatMessageQuery) IDs

func (cmq *ChatMessageQuery) IDs(ctx context.Context) (ids []string, err error)

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

func (*ChatMessageQuery) IDsX

func (cmq *ChatMessageQuery) IDsX(ctx context.Context) []string

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

func (*ChatMessageQuery) Limit

func (cmq *ChatMessageQuery) Limit(limit int) *ChatMessageQuery

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

func (*ChatMessageQuery) Offset

func (cmq *ChatMessageQuery) Offset(offset int) *ChatMessageQuery

Offset to start from.

func (*ChatMessageQuery) Only

func (cmq *ChatMessageQuery) Only(ctx context.Context) (*ChatMessage, error)

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

func (*ChatMessageQuery) OnlyID

func (cmq *ChatMessageQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*ChatMessageQuery) OnlyIDX

func (cmq *ChatMessageQuery) OnlyIDX(ctx context.Context) string

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

func (*ChatMessageQuery) OnlyX

func (cmq *ChatMessageQuery) OnlyX(ctx context.Context) *ChatMessage

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

func (*ChatMessageQuery) Order

Order specifies how the records should be ordered.

func (*ChatMessageQuery) Select

func (cmq *ChatMessageQuery) Select(fields ...string) *ChatMessageSelect

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

client.ChatMessage.Query().
	Select(chatmessage.FieldConversationID).
	Scan(ctx, &v)

func (*ChatMessageQuery) Unique

func (cmq *ChatMessageQuery) Unique(unique bool) *ChatMessageQuery

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

Where adds a new predicate for the ChatMessageQuery builder.

type ChatMessageSelect

type ChatMessageSelect struct {
	*ChatMessageQuery
	// contains filtered or unexported fields
}

ChatMessageSelect is the builder for selecting fields of ChatMessage entities.

func (*ChatMessageSelect) Aggregate

func (cms *ChatMessageSelect) Aggregate(fns ...AggregateFunc) *ChatMessageSelect

Aggregate adds the given aggregation functions to the selector query.

func (*ChatMessageSelect) Bool

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

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

func (*ChatMessageSelect) BoolX

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

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

func (*ChatMessageSelect) Bools

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

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

func (*ChatMessageSelect) BoolsX

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

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

func (*ChatMessageSelect) Float64

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

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

func (*ChatMessageSelect) Float64X

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

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

func (*ChatMessageSelect) Float64s

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

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

func (*ChatMessageSelect) Float64sX

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

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

func (*ChatMessageSelect) Int

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

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

func (*ChatMessageSelect) IntX

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

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

func (*ChatMessageSelect) Ints

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

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

func (*ChatMessageSelect) IntsX

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

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

func (*ChatMessageSelect) Scan

func (cms *ChatMessageSelect) Scan(ctx context.Context, v any) error

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

func (*ChatMessageSelect) ScanX

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

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

func (*ChatMessageSelect) String

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

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

func (*ChatMessageSelect) StringX

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

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

func (*ChatMessageSelect) Strings

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

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

func (*ChatMessageSelect) StringsX

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

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

type ChatMessageUpdate

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

ChatMessageUpdate is the builder for updating ChatMessage entities.

func (*ChatMessageUpdate) Exec

func (cmu *ChatMessageUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*ChatMessageUpdate) ExecX

func (cmu *ChatMessageUpdate) ExecX(ctx context.Context)

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

func (*ChatMessageUpdate) Mutation

func (cmu *ChatMessageUpdate) Mutation() *ChatMessageMutation

Mutation returns the ChatMessageMutation object of the builder.

func (*ChatMessageUpdate) Save

func (cmu *ChatMessageUpdate) Save(ctx context.Context) (int, error)

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

func (*ChatMessageUpdate) SaveX

func (cmu *ChatMessageUpdate) SaveX(ctx context.Context) int

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

func (*ChatMessageUpdate) SetContent

func (cmu *ChatMessageUpdate) SetContent(s string) *ChatMessageUpdate

SetContent sets the "content" field.

func (*ChatMessageUpdate) SetConversationID

func (cmu *ChatMessageUpdate) SetConversationID(s string) *ChatMessageUpdate

SetConversationID sets the "conversation_id" field.

func (*ChatMessageUpdate) SetNillableContent

func (cmu *ChatMessageUpdate) SetNillableContent(s *string) *ChatMessageUpdate

SetNillableContent sets the "content" field if the given value is not nil.

func (*ChatMessageUpdate) SetNillableConversationID

func (cmu *ChatMessageUpdate) SetNillableConversationID(s *string) *ChatMessageUpdate

SetNillableConversationID sets the "conversation_id" field if the given value is not nil.

func (*ChatMessageUpdate) SetNillableRole

func (cmu *ChatMessageUpdate) SetNillableRole(s *string) *ChatMessageUpdate

SetNillableRole sets the "role" field if the given value is not nil.

func (*ChatMessageUpdate) SetRole

func (cmu *ChatMessageUpdate) SetRole(s string) *ChatMessageUpdate

SetRole sets the "role" field.

func (*ChatMessageUpdate) Where

Where appends a list predicates to the ChatMessageUpdate builder.

type ChatMessageUpdateOne

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

ChatMessageUpdateOne is the builder for updating a single ChatMessage entity.

func (*ChatMessageUpdateOne) Exec

func (cmuo *ChatMessageUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*ChatMessageUpdateOne) ExecX

func (cmuo *ChatMessageUpdateOne) ExecX(ctx context.Context)

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

func (*ChatMessageUpdateOne) Mutation

func (cmuo *ChatMessageUpdateOne) Mutation() *ChatMessageMutation

Mutation returns the ChatMessageMutation object of the builder.

func (*ChatMessageUpdateOne) Save

Save executes the query and returns the updated ChatMessage entity.

func (*ChatMessageUpdateOne) SaveX

func (cmuo *ChatMessageUpdateOne) SaveX(ctx context.Context) *ChatMessage

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

func (*ChatMessageUpdateOne) Select

func (cmuo *ChatMessageUpdateOne) Select(field string, fields ...string) *ChatMessageUpdateOne

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

func (*ChatMessageUpdateOne) SetContent

func (cmuo *ChatMessageUpdateOne) SetContent(s string) *ChatMessageUpdateOne

SetContent sets the "content" field.

func (*ChatMessageUpdateOne) SetConversationID

func (cmuo *ChatMessageUpdateOne) SetConversationID(s string) *ChatMessageUpdateOne

SetConversationID sets the "conversation_id" field.

func (*ChatMessageUpdateOne) SetNillableContent

func (cmuo *ChatMessageUpdateOne) SetNillableContent(s *string) *ChatMessageUpdateOne

SetNillableContent sets the "content" field if the given value is not nil.

func (*ChatMessageUpdateOne) SetNillableConversationID

func (cmuo *ChatMessageUpdateOne) SetNillableConversationID(s *string) *ChatMessageUpdateOne

SetNillableConversationID sets the "conversation_id" field if the given value is not nil.

func (*ChatMessageUpdateOne) SetNillableRole

func (cmuo *ChatMessageUpdateOne) SetNillableRole(s *string) *ChatMessageUpdateOne

SetNillableRole sets the "role" field if the given value is not nil.

func (*ChatMessageUpdateOne) SetRole

SetRole sets the "role" field.

func (*ChatMessageUpdateOne) Where

Where appends a list predicates to the ChatMessageUpdate builder.

type ChatMessages

type ChatMessages []*ChatMessage

ChatMessages is a parsable slice of ChatMessage.

type Client

type Client struct {

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

type Conversation struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// PageURL holds the value of the "page_url" field.
	PageURL string `json:"page_url,omitempty"`
	// contains filtered or unexported fields
}

Conversation is the model entity for the Conversation schema.

func (*Conversation) String

func (c *Conversation) String() string

String implements the fmt.Stringer.

func (*Conversation) Unwrap

func (c *Conversation) Unwrap() *Conversation

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

func (c *Conversation) Update() *ConversationUpdateOne

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

func (*Conversation) Value

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

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

type ConversationClient

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

ConversationClient is a client for the Conversation schema.

func NewConversationClient

func NewConversationClient(c config) *ConversationClient

NewConversationClient returns a client for the Conversation from the given config.

func (*ConversationClient) Create

Create returns a builder for creating a Conversation entity.

func (*ConversationClient) CreateBulk

func (c *ConversationClient) CreateBulk(builders ...*ConversationCreate) *ConversationCreateBulk

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

func (*ConversationClient) Delete

Delete returns a delete builder for Conversation.

func (*ConversationClient) DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*ConversationClient) DeleteOneID

func (c *ConversationClient) DeleteOneID(id string) *ConversationDeleteOne

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

func (*ConversationClient) Get

Get returns a Conversation entity by its id.

func (*ConversationClient) GetX

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

func (*ConversationClient) Hooks

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

Hooks returns the client hooks.

func (*ConversationClient) Intercept

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

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

func (*ConversationClient) Interceptors

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

Interceptors returns the client interceptors.

func (*ConversationClient) MapCreateBulk

func (c *ConversationClient) MapCreateBulk(slice any, setFunc func(*ConversationCreate, int)) *ConversationCreateBulk

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

Query returns a query builder for Conversation.

func (*ConversationClient) Update

Update returns an update builder for Conversation.

func (*ConversationClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*ConversationClient) UpdateOneID

func (c *ConversationClient) UpdateOneID(id string) *ConversationUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ConversationClient) Use

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

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

type ConversationCreate

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

ConversationCreate is the builder for creating a Conversation entity.

func (*ConversationCreate) Exec

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

Exec executes the query.

func (*ConversationCreate) ExecX

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

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

func (*ConversationCreate) Mutation

func (cc *ConversationCreate) Mutation() *ConversationMutation

Mutation returns the ConversationMutation object of the builder.

func (*ConversationCreate) Save

Save creates the Conversation in the database.

func (*ConversationCreate) SaveX

SaveX calls Save and panics if Save returns an error.

func (*ConversationCreate) SetID

SetID sets the "id" field.

func (*ConversationCreate) SetPageURL

func (cc *ConversationCreate) SetPageURL(s string) *ConversationCreate

SetPageURL sets the "page_url" field.

type ConversationCreateBulk

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

ConversationCreateBulk is the builder for creating many Conversation entities in bulk.

func (*ConversationCreateBulk) Exec

Exec executes the query.

func (*ConversationCreateBulk) ExecX

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

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

func (*ConversationCreateBulk) Save

Save creates the Conversation entities in the database.

func (*ConversationCreateBulk) SaveX

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

type ConversationDelete

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

ConversationDelete is the builder for deleting a Conversation entity.

func (*ConversationDelete) Exec

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

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

func (*ConversationDelete) ExecX

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

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

func (*ConversationDelete) Where

Where appends a list predicates to the ConversationDelete builder.

type ConversationDeleteOne

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

ConversationDeleteOne is the builder for deleting a single Conversation entity.

func (*ConversationDeleteOne) Exec

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

Exec executes the deletion query.

func (*ConversationDeleteOne) ExecX

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

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

func (*ConversationDeleteOne) Where

Where appends a list predicates to the ConversationDelete builder.

type ConversationGroupBy

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

ConversationGroupBy is the group-by builder for Conversation entities.

func (*ConversationGroupBy) Aggregate

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

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

func (*ConversationGroupBy) Bool

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

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

func (*ConversationGroupBy) BoolX

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

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

func (*ConversationGroupBy) Bools

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

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

func (*ConversationGroupBy) BoolsX

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

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

func (*ConversationGroupBy) Float64

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

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

func (*ConversationGroupBy) Float64X

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

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

func (*ConversationGroupBy) Float64s

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

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

func (*ConversationGroupBy) Float64sX

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

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

func (*ConversationGroupBy) Int

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

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

func (*ConversationGroupBy) IntX

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

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

func (*ConversationGroupBy) Ints

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

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

func (*ConversationGroupBy) IntsX

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

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

func (*ConversationGroupBy) Scan

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

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

func (*ConversationGroupBy) ScanX

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

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

func (*ConversationGroupBy) String

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

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

func (*ConversationGroupBy) StringX

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

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

func (*ConversationGroupBy) Strings

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

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

func (*ConversationGroupBy) StringsX

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

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

type ConversationMutation

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

ConversationMutation represents an operation that mutates the Conversation nodes in the graph.

func (*ConversationMutation) AddField

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

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

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

func (*ConversationMutation) AddedField

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

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

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

func (*ConversationMutation) AddedIDs

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

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

func (*ConversationMutation) ClearEdge

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

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

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

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

func (*ConversationMutation) ClearedFields

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

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

func (ConversationMutation) Client

func (m ConversationMutation) 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 (*ConversationMutation) EdgeCleared

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

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

func (*ConversationMutation) Field

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

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

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

func (*ConversationMutation) Fields

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

func (m *ConversationMutation) ID() (id string, 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 (*ConversationMutation) IDs

func (m *ConversationMutation) IDs(ctx context.Context) ([]string, 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 (*ConversationMutation) OldField

func (m *ConversationMutation) 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 (*ConversationMutation) OldPageURL

func (m *ConversationMutation) OldPageURL(ctx context.Context) (v string, err error)

OldPageURL returns the old "page_url" field's value of the Conversation entity. If the Conversation 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 (*ConversationMutation) Op

func (m *ConversationMutation) Op() Op

Op returns the operation name.

func (*ConversationMutation) PageURL

func (m *ConversationMutation) PageURL() (r string, exists bool)

PageURL returns the value of the "page_url" field in the mutation.

func (*ConversationMutation) RemovedEdges

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

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

func (*ConversationMutation) RemovedIDs

func (m *ConversationMutation) 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 (*ConversationMutation) ResetEdge

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

func (m *ConversationMutation) 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 (*ConversationMutation) ResetPageURL

func (m *ConversationMutation) ResetPageURL()

ResetPageURL resets all changes to the "page_url" field.

func (*ConversationMutation) SetField

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

func (m *ConversationMutation) SetID(id string)

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

func (*ConversationMutation) SetOp

func (m *ConversationMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*ConversationMutation) SetPageURL

func (m *ConversationMutation) SetPageURL(s string)

SetPageURL sets the "page_url" field.

func (ConversationMutation) Tx

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

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

func (*ConversationMutation) Type

func (m *ConversationMutation) Type() string

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

func (*ConversationMutation) Where

Where appends a list predicates to the ConversationMutation builder.

func (*ConversationMutation) WhereP

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

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

type ConversationQuery

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

ConversationQuery is the builder for querying Conversation entities.

func (*ConversationQuery) Aggregate

func (cq *ConversationQuery) Aggregate(fns ...AggregateFunc) *ConversationSelect

Aggregate returns a ConversationSelect configured with the given aggregations.

func (*ConversationQuery) All

func (cq *ConversationQuery) All(ctx context.Context) ([]*Conversation, error)

All executes the query and returns a list of Conversations.

func (*ConversationQuery) AllX

func (cq *ConversationQuery) AllX(ctx context.Context) []*Conversation

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

func (*ConversationQuery) Clone

func (cq *ConversationQuery) Clone() *ConversationQuery

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

func (*ConversationQuery) Count

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

Count returns the count of the given query.

func (*ConversationQuery) CountX

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

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

func (*ConversationQuery) Exist

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

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

func (*ConversationQuery) ExistX

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

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

func (*ConversationQuery) First

func (cq *ConversationQuery) First(ctx context.Context) (*Conversation, error)

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

func (*ConversationQuery) FirstID

func (cq *ConversationQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*ConversationQuery) FirstIDX

func (cq *ConversationQuery) FirstIDX(ctx context.Context) string

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

func (*ConversationQuery) FirstX

func (cq *ConversationQuery) FirstX(ctx context.Context) *Conversation

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

func (*ConversationQuery) GroupBy

func (cq *ConversationQuery) GroupBy(field string, fields ...string) *ConversationGroupBy

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

client.Conversation.Query().
	GroupBy(conversation.FieldPageURL).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ConversationQuery) IDs

func (cq *ConversationQuery) IDs(ctx context.Context) (ids []string, err error)

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

func (*ConversationQuery) IDsX

func (cq *ConversationQuery) IDsX(ctx context.Context) []string

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

func (*ConversationQuery) Limit

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

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

func (*ConversationQuery) Offset

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

Offset to start from.

func (*ConversationQuery) Only

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

func (*ConversationQuery) OnlyID

func (cq *ConversationQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*ConversationQuery) OnlyIDX

func (cq *ConversationQuery) OnlyIDX(ctx context.Context) string

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

func (*ConversationQuery) OnlyX

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

func (*ConversationQuery) Order

Order specifies how the records should be ordered.

func (*ConversationQuery) Select

func (cq *ConversationQuery) Select(fields ...string) *ConversationSelect

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

client.Conversation.Query().
	Select(conversation.FieldPageURL).
	Scan(ctx, &v)

func (*ConversationQuery) Unique

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

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

Where adds a new predicate for the ConversationQuery builder.

type ConversationSelect

type ConversationSelect struct {
	*ConversationQuery
	// contains filtered or unexported fields
}

ConversationSelect is the builder for selecting fields of Conversation entities.

func (*ConversationSelect) Aggregate

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

Aggregate adds the given aggregation functions to the selector query.

func (*ConversationSelect) Bool

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

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

func (*ConversationSelect) BoolX

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

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

func (*ConversationSelect) Bools

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

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

func (*ConversationSelect) BoolsX

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

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

func (*ConversationSelect) Float64

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

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

func (*ConversationSelect) Float64X

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

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

func (*ConversationSelect) Float64s

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

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

func (*ConversationSelect) Float64sX

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

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

func (*ConversationSelect) Int

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

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

func (*ConversationSelect) IntX

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

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

func (*ConversationSelect) Ints

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

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

func (*ConversationSelect) IntsX

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

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

func (*ConversationSelect) Scan

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

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

func (*ConversationSelect) ScanX

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

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

func (*ConversationSelect) String

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

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

func (*ConversationSelect) StringX

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

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

func (*ConversationSelect) Strings

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

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

func (*ConversationSelect) StringsX

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

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

type ConversationUpdate

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

ConversationUpdate is the builder for updating Conversation entities.

func (*ConversationUpdate) Exec

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

Exec executes the query.

func (*ConversationUpdate) ExecX

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

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

func (*ConversationUpdate) Mutation

func (cu *ConversationUpdate) Mutation() *ConversationMutation

Mutation returns the ConversationMutation object of the builder.

func (*ConversationUpdate) Save

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

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

func (*ConversationUpdate) SaveX

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

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

func (*ConversationUpdate) SetNillablePageURL

func (cu *ConversationUpdate) SetNillablePageURL(s *string) *ConversationUpdate

SetNillablePageURL sets the "page_url" field if the given value is not nil.

func (*ConversationUpdate) SetPageURL

func (cu *ConversationUpdate) SetPageURL(s string) *ConversationUpdate

SetPageURL sets the "page_url" field.

func (*ConversationUpdate) Where

Where appends a list predicates to the ConversationUpdate builder.

type ConversationUpdateOne

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

ConversationUpdateOne is the builder for updating a single Conversation entity.

func (*ConversationUpdateOne) Exec

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

Exec executes the query on the entity.

func (*ConversationUpdateOne) ExecX

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

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

func (*ConversationUpdateOne) Mutation

Mutation returns the ConversationMutation object of the builder.

func (*ConversationUpdateOne) Save

Save executes the query and returns the updated Conversation entity.

func (*ConversationUpdateOne) SaveX

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

func (*ConversationUpdateOne) Select

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

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

func (*ConversationUpdateOne) SetNillablePageURL

func (cuo *ConversationUpdateOne) SetNillablePageURL(s *string) *ConversationUpdateOne

SetNillablePageURL sets the "page_url" field if the given value is not nil.

func (*ConversationUpdateOne) SetPageURL

SetPageURL sets the "page_url" field.

func (*ConversationUpdateOne) Where

Where appends a list predicates to the ConversationUpdate builder.

type Conversations

type Conversations []*Conversation

Conversations is a parsable slice of Conversation.

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 {

	// ChatMessage is the client for interacting with the ChatMessage builders.
	ChatMessage *ChatMessageClient
	// Conversation is the client for interacting with the Conversation builders.
	Conversation *ConversationClient
	// 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