// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "entgo.io/ent" "entgo.io/ent/dialect/sql" "within.website/x/cmd/tourian/ent/chatmessage" ) // ChatMessage is the model entity for the ChatMessage schema. type ChatMessage struct { config `json:"-"` // 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"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*ChatMessage) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case chatmessage.FieldID, chatmessage.FieldConversationID, chatmessage.FieldRole, chatmessage.FieldContent: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the ChatMessage fields. func (cm *ChatMessage) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { case chatmessage.FieldID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field id", values[i]) } else if value.Valid { cm.ID = value.String } case chatmessage.FieldConversationID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field conversation_id", values[i]) } else if value.Valid { cm.ConversationID = value.String } case chatmessage.FieldRole: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field role", values[i]) } else if value.Valid { cm.Role = value.String } case chatmessage.FieldContent: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field content", values[i]) } else if value.Valid { cm.Content = value.String } default: cm.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the ChatMessage. // This includes values selected through modifiers, order, etc. func (cm *ChatMessage) Value(name string) (ent.Value, error) { return cm.selectValues.Get(name) } // 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 (cm *ChatMessage) Update() *ChatMessageUpdateOne { return NewChatMessageClient(cm.config).UpdateOne(cm) } // 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 (cm *ChatMessage) Unwrap() *ChatMessage { _tx, ok := cm.config.driver.(*txDriver) if !ok { panic("ent: ChatMessage is not a transactional entity") } cm.config.driver = _tx.drv return cm } // String implements the fmt.Stringer. func (cm *ChatMessage) String() string { var builder strings.Builder builder.WriteString("ChatMessage(") builder.WriteString(fmt.Sprintf("id=%v, ", cm.ID)) builder.WriteString("conversation_id=") builder.WriteString(cm.ConversationID) builder.WriteString(", ") builder.WriteString("role=") builder.WriteString(cm.Role) builder.WriteString(", ") builder.WriteString("content=") builder.WriteString(cm.Content) builder.WriteByte(')') return builder.String() } // ChatMessages is a parsable slice of ChatMessage. type ChatMessages []*ChatMessage