propertyschema.go•4.34 kB
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Southclaws/storyden/internal/ent/propertyschema"
"github.com/rs/xid"
)
// PropertySchema is the model entity for the PropertySchema schema.
type PropertySchema struct {
config
// ID of the ent.
ID xid.ID `json:"id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PropertySchemaQuery when eager-loading is set.
Edges PropertySchemaEdges `json:"edges"`
selectValues sql.SelectValues
}
// PropertySchemaEdges holds the relations/edges for other nodes in the graph.
type PropertySchemaEdges struct {
// Node holds the value of the node edge.
Node []*Node `json:"node,omitempty"`
// Fields holds the value of the fields edge.
Fields []*PropertySchemaField `json:"fields,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// NodeOrErr returns the Node value or an error if the edge
// was not loaded in eager-loading.
func (e PropertySchemaEdges) NodeOrErr() ([]*Node, error) {
if e.loadedTypes[0] {
return e.Node, nil
}
return nil, &NotLoadedError{edge: "node"}
}
// FieldsOrErr returns the Fields value or an error if the edge
// was not loaded in eager-loading.
func (e PropertySchemaEdges) FieldsOrErr() ([]*PropertySchemaField, error) {
if e.loadedTypes[1] {
return e.Fields, nil
}
return nil, &NotLoadedError{edge: "fields"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*PropertySchema) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case propertyschema.FieldID:
values[i] = new(xid.ID)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the PropertySchema fields.
func (_m *PropertySchema) 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 propertyschema.FieldID:
if value, ok := values[i].(*xid.ID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the PropertySchema.
// This includes values selected through modifiers, order, etc.
func (_m *PropertySchema) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryNode queries the "node" edge of the PropertySchema entity.
func (_m *PropertySchema) QueryNode() *NodeQuery {
return NewPropertySchemaClient(_m.config).QueryNode(_m)
}
// QueryFields queries the "fields" edge of the PropertySchema entity.
func (_m *PropertySchema) QueryFields() *PropertySchemaFieldQuery {
return NewPropertySchemaClient(_m.config).QueryFields(_m)
}
// Update returns a builder for updating this PropertySchema.
// Note that you need to call PropertySchema.Unwrap() before calling this method if this PropertySchema
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *PropertySchema) Update() *PropertySchemaUpdateOne {
return NewPropertySchemaClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the PropertySchema 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 *PropertySchema) Unwrap() *PropertySchema {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: PropertySchema is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *PropertySchema) String() string {
var builder strings.Builder
builder.WriteString("PropertySchema(")
builder.WriteString(fmt.Sprintf("id=%v", _m.ID))
builder.WriteByte(')')
return builder.String()
}
// PropertySchemas is a parsable slice of PropertySchema.
type PropertySchemas []*PropertySchema