2024-07-20 15:37:01 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
"leafdev.top/leaf/rag/ent/documentblock"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DocumentBlock is the model entity for the DocumentBlock schema.
|
|
|
|
type DocumentBlock struct {
|
|
|
|
config `json:"-"`
|
|
|
|
// ID of the ent.
|
|
|
|
ID int `json:"id,omitempty"`
|
|
|
|
// Content holds the value of the "content" field.
|
|
|
|
Content string `json:"content,omitempty"`
|
|
|
|
// Order holds the value of the "order" field.
|
2024-07-20 17:20:52 +00:00
|
|
|
Order int64 `json:"order,omitempty"`
|
2024-07-20 15:37:01 +00:00
|
|
|
// DocumentID holds the value of the "document_id" field.
|
2024-07-20 17:20:52 +00:00
|
|
|
DocumentID int64 `json:"document_id,omitempty"`
|
2024-07-20 15:37:01 +00:00
|
|
|
// UserID holds the value of the "user_id" field.
|
|
|
|
UserID string `json:"user_id,omitempty"`
|
|
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
|
|
// The values are being populated by the DocumentBlockQuery when eager-loading is set.
|
|
|
|
Edges DocumentBlockEdges `json:"edges"`
|
|
|
|
selectValues sql.SelectValues
|
|
|
|
}
|
|
|
|
|
|
|
|
// DocumentBlockEdges holds the relations/edges for other nodes in the graph.
|
|
|
|
type DocumentBlockEdges struct {
|
|
|
|
// Document holds the value of the document edge.
|
|
|
|
Document []*Document `json:"document,omitempty"`
|
|
|
|
// loadedTypes holds the information for reporting if a
|
|
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
|
|
loadedTypes [1]bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// DocumentOrErr returns the Document value or an error if the edge
|
|
|
|
// was not loaded in eager-loading.
|
|
|
|
func (e DocumentBlockEdges) DocumentOrErr() ([]*Document, error) {
|
|
|
|
if e.loadedTypes[0] {
|
|
|
|
return e.Document, nil
|
|
|
|
}
|
|
|
|
return nil, &NotLoadedError{edge: "document"}
|
|
|
|
}
|
|
|
|
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
|
|
func (*DocumentBlock) scanValues(columns []string) ([]any, error) {
|
|
|
|
values := make([]any, len(columns))
|
|
|
|
for i := range columns {
|
|
|
|
switch columns[i] {
|
|
|
|
case documentblock.FieldID, documentblock.FieldOrder, documentblock.FieldDocumentID:
|
|
|
|
values[i] = new(sql.NullInt64)
|
2024-07-21 09:24:43 +00:00
|
|
|
case documentblock.FieldContent, documentblock.FieldUserID:
|
2024-07-20 15:37:01 +00:00
|
|
|
values[i] = new(sql.NullString)
|
|
|
|
case documentblock.FieldCreatedAt, documentblock.FieldUpdatedAt:
|
|
|
|
values[i] = new(sql.NullTime)
|
|
|
|
default:
|
|
|
|
values[i] = new(sql.UnknownType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return values, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
|
|
// to the DocumentBlock fields.
|
|
|
|
func (db *DocumentBlock) 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 documentblock.FieldID:
|
|
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
|
|
}
|
|
|
|
db.ID = int(value.Int64)
|
|
|
|
case documentblock.FieldContent:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field content", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
db.Content = value.String
|
|
|
|
}
|
|
|
|
case documentblock.FieldOrder:
|
|
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field order", values[i])
|
|
|
|
} else if value.Valid {
|
2024-07-20 17:20:52 +00:00
|
|
|
db.Order = value.Int64
|
2024-07-20 15:37:01 +00:00
|
|
|
}
|
|
|
|
case documentblock.FieldDocumentID:
|
|
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field document_id", values[i])
|
|
|
|
} else if value.Valid {
|
2024-07-20 17:20:52 +00:00
|
|
|
db.DocumentID = value.Int64
|
2024-07-20 15:37:01 +00:00
|
|
|
}
|
|
|
|
case documentblock.FieldUserID:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field user_id", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
db.UserID = value.String
|
|
|
|
}
|
|
|
|
case documentblock.FieldCreatedAt:
|
|
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
db.CreatedAt = value.Time
|
|
|
|
}
|
|
|
|
case documentblock.FieldUpdatedAt:
|
|
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
db.UpdatedAt = value.Time
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
db.selectValues.Set(columns[i], values[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the DocumentBlock.
|
|
|
|
// This includes values selected through modifiers, order, etc.
|
|
|
|
func (db *DocumentBlock) Value(name string) (ent.Value, error) {
|
|
|
|
return db.selectValues.Get(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryDocument queries the "document" edge of the DocumentBlock entity.
|
|
|
|
func (db *DocumentBlock) QueryDocument() *DocumentQuery {
|
|
|
|
return NewDocumentBlockClient(db.config).QueryDocument(db)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update returns a builder for updating this DocumentBlock.
|
|
|
|
// Note that you need to call DocumentBlock.Unwrap() before calling this method if this DocumentBlock
|
|
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
|
|
func (db *DocumentBlock) Update() *DocumentBlockUpdateOne {
|
|
|
|
return NewDocumentBlockClient(db.config).UpdateOne(db)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unwrap unwraps the DocumentBlock 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 (db *DocumentBlock) Unwrap() *DocumentBlock {
|
|
|
|
_tx, ok := db.config.driver.(*txDriver)
|
|
|
|
if !ok {
|
|
|
|
panic("ent: DocumentBlock is not a transactional entity")
|
|
|
|
}
|
|
|
|
db.config.driver = _tx.drv
|
|
|
|
return db
|
|
|
|
}
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer.
|
|
|
|
func (db *DocumentBlock) String() string {
|
|
|
|
var builder strings.Builder
|
|
|
|
builder.WriteString("DocumentBlock(")
|
|
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", db.ID))
|
|
|
|
builder.WriteString("content=")
|
|
|
|
builder.WriteString(db.Content)
|
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("order=")
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", db.Order))
|
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("document_id=")
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", db.DocumentID))
|
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("user_id=")
|
|
|
|
builder.WriteString(db.UserID)
|
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("created_at=")
|
|
|
|
builder.WriteString(db.CreatedAt.Format(time.ANSIC))
|
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("updated_at=")
|
|
|
|
builder.WriteString(db.UpdatedAt.Format(time.ANSIC))
|
|
|
|
builder.WriteByte(')')
|
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// DocumentBlocks is a parsable slice of DocumentBlock.
|
|
|
|
type DocumentBlocks []*DocumentBlock
|