// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/dalbodeule/hop-gate/ent/domain" "github.com/google/uuid" ) // Domain is the model entity for the Domain schema. type Domain struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // Domain holds the value of the "domain" field. Domain string `json:"domain,omitempty"` // ClientAPIKey holds the value of the "client_api_key" field. ClientAPIKey string `json:"client_api_key,omitempty"` // Memo holds the value of the "memo" field. Memo string `json:"memo,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"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*Domain) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case domain.FieldDomain, domain.FieldClientAPIKey, domain.FieldMemo: values[i] = new(sql.NullString) case domain.FieldCreatedAt, domain.FieldUpdatedAt: values[i] = new(sql.NullTime) case domain.FieldID: values[i] = new(uuid.UUID) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Domain fields. func (_m *Domain) 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 domain.FieldID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field id", values[i]) } else if value != nil { _m.ID = *value } case domain.FieldDomain: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field domain", values[i]) } else if value.Valid { _m.Domain = value.String } case domain.FieldClientAPIKey: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field client_api_key", values[i]) } else if value.Valid { _m.ClientAPIKey = value.String } case domain.FieldMemo: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field memo", values[i]) } else if value.Valid { _m.Memo = value.String } case domain.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 { _m.CreatedAt = value.Time } case domain.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 { _m.UpdatedAt = value.Time } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Domain. // This includes values selected through modifiers, order, etc. func (_m *Domain) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this Domain. // Note that you need to call Domain.Unwrap() before calling this method if this Domain // was returned from a transaction, and the transaction was committed or rolled back. func (_m *Domain) Update() *DomainUpdateOne { return NewDomainClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Domain 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 *Domain) Unwrap() *Domain { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Domain is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *Domain) String() string { var builder strings.Builder builder.WriteString("Domain(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("domain=") builder.WriteString(_m.Domain) builder.WriteString(", ") builder.WriteString("client_api_key=") builder.WriteString(_m.ClientAPIKey) builder.WriteString(", ") builder.WriteString("memo=") builder.WriteString(_m.Memo) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // Domains is a parsable slice of Domain. type Domains []*Domain