175 lines
5.4 KiB
Go
175 lines
5.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"voidraft/internal/models/ent/document"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Document is the model entity for the Document schema.
|
|
type Document struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// UUID for cross-device sync (UUIDv7)
|
|
UUID string `json:"uuid"`
|
|
// creation time
|
|
CreatedAt string `json:"created_at"`
|
|
// update time
|
|
UpdatedAt string `json:"updated_at"`
|
|
// deleted at
|
|
DeletedAt *string `json:"deleted_at,omitempty"`
|
|
// document title
|
|
Title string `json:"title"`
|
|
// document content
|
|
Content string `json:"content"`
|
|
// document locked status
|
|
Locked bool `json:"locked"`
|
|
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.FieldLocked:
|
|
values[i] = new(sql.NullBool)
|
|
case document.FieldID:
|
|
values[i] = new(sql.NullInt64)
|
|
case document.FieldUUID, document.FieldCreatedAt, document.FieldUpdatedAt, document.FieldDeletedAt, document.FieldTitle, document.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 Document fields.
|
|
func (_m *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)
|
|
}
|
|
_m.ID = int(value.Int64)
|
|
case document.FieldUUID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field uuid", values[i])
|
|
} else if value.Valid {
|
|
_m.UUID = value.String
|
|
}
|
|
case document.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.String
|
|
}
|
|
case document.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = value.String
|
|
}
|
|
case document.FieldDeletedAt:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
|
} else if value.Valid {
|
|
_m.DeletedAt = new(string)
|
|
*_m.DeletedAt = value.String
|
|
}
|
|
case document.FieldTitle:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field title", values[i])
|
|
} else if value.Valid {
|
|
_m.Title = value.String
|
|
}
|
|
case document.FieldContent:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field content", values[i])
|
|
} else if value.Valid {
|
|
_m.Content = value.String
|
|
}
|
|
case document.FieldLocked:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field locked", values[i])
|
|
} else if value.Valid {
|
|
_m.Locked = value.Bool
|
|
}
|
|
default:
|
|
_m.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 (_m *Document) Value(name string) (ent.Value, error) {
|
|
return _m.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 (_m *Document) Update() *DocumentUpdateOne {
|
|
return NewDocumentClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// 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 (_m *Document) Unwrap() *Document {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Document is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *Document) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Document(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("uuid=")
|
|
builder.WriteString(_m.UUID)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(_m.UpdatedAt)
|
|
builder.WriteString(", ")
|
|
if v := _m.DeletedAt; v != nil {
|
|
builder.WriteString("deleted_at=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("title=")
|
|
builder.WriteString(_m.Title)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("content=")
|
|
builder.WriteString(_m.Content)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("locked=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Locked))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Documents is a parsable slice of Document.
|
|
type Documents []*Document
|