// 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/document" ) // Document is the model entity for the Document schema. type Document struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // UserID holds the value of the "user_id" field. UserID string `json:"user_id,omitempty"` // LibraryID holds the value of the "library_id" field. LibraryID int64 `json:"library_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"` document_block_document *int selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*Document) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case document.FieldID, document.FieldLibraryID: values[i] = new(sql.NullInt64) case document.FieldName, document.FieldUserID: values[i] = new(sql.NullString) case document.FieldCreatedAt, document.FieldUpdatedAt: values[i] = new(sql.NullTime) case document.ForeignKeys[0]: // document_block_document values[i] = new(sql.NullInt64) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Document fields. func (d *Document) 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 document.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } d.ID = int(value.Int64) case document.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { d.Name = value.String } case document.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 { d.UserID = value.String } case document.FieldLibraryID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field library_id", values[i]) } else if value.Valid { d.LibraryID = value.Int64 } case document.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 { d.CreatedAt = value.Time } case document.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 { d.UpdatedAt = value.Time } case document.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field document_block_document", value) } else if value.Valid { d.document_block_document = new(int) *d.document_block_document = int(value.Int64) } default: d.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Document. // This includes values selected through modifiers, order, etc. func (d *Document) Value(name string) (ent.Value, error) { return d.selectValues.Get(name) } // Update returns a builder for updating this Document. // Note that you need to call Document.Unwrap() before calling this method if this Document // was returned from a transaction, and the transaction was committed or rolled back. func (d *Document) Update() *DocumentUpdateOne { return NewDocumentClient(d.config).UpdateOne(d) } // Unwrap unwraps the Document 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 (d *Document) Unwrap() *Document { _tx, ok := d.config.driver.(*txDriver) if !ok { panic("ent: Document is not a transactional entity") } d.config.driver = _tx.drv return d } // String implements the fmt.Stringer. func (d *Document) String() string { var builder strings.Builder builder.WriteString("Document(") builder.WriteString(fmt.Sprintf("id=%v, ", d.ID)) builder.WriteString("name=") builder.WriteString(d.Name) builder.WriteString(", ") builder.WriteString("user_id=") builder.WriteString(d.UserID) builder.WriteString(", ") builder.WriteString("library_id=") builder.WriteString(fmt.Sprintf("%v", d.LibraryID)) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(d.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(d.UpdatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // Documents is a parsable slice of Document. type Documents []*Document