// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "tel-commerce/ent/business" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // Business is the model entity for the Business schema. type Business 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"` // Slug holds the value of the "slug" field. Slug string `json:"slug,omitempty"` // BotID holds the value of the "bot_id" field. BotID *string `json:"bot_id,omitempty"` // Description holds the value of the "description" field. Description *string `json:"description,omitempty"` // Company holds the value of the "company" field. Company string `json:"company,omitempty"` // AboutUs holds the value of the "about_us" field. AboutUs *string `json:"about_us,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 BusinessQuery when eager-loading is set. Edges BusinessEdges `json:"edges"` selectValues sql.SelectValues } // BusinessEdges holds the relations/edges for other nodes in the graph. type BusinessEdges struct { // BusinessCategory holds the value of the businessCategory edge. BusinessCategory []*BusinessCategory `json:"businessCategory,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // BusinessCategoryOrErr returns the BusinessCategory value or an error if the edge // was not loaded in eager-loading. func (e BusinessEdges) BusinessCategoryOrErr() ([]*BusinessCategory, error) { if e.loadedTypes[0] { return e.BusinessCategory, nil } return nil, &NotLoadedError{edge: "businessCategory"} } // scanValues returns the types for scanning values from sql.Rows. func (*Business) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case business.FieldID: values[i] = new(sql.NullInt64) case business.FieldName, business.FieldSlug, business.FieldBotID, business.FieldDescription, business.FieldCompany, business.FieldAboutUs: values[i] = new(sql.NullString) case business.FieldCreatedAt, business.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 Business fields. func (b *Business) 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 business.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } b.ID = int(value.Int64) case business.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { b.Name = value.String } case business.FieldSlug: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field slug", values[i]) } else if value.Valid { b.Slug = value.String } case business.FieldBotID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field bot_id", values[i]) } else if value.Valid { b.BotID = new(string) *b.BotID = value.String } case business.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { b.Description = new(string) *b.Description = value.String } case business.FieldCompany: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field company", values[i]) } else if value.Valid { b.Company = value.String } case business.FieldAboutUs: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field about_us", values[i]) } else if value.Valid { b.AboutUs = new(string) *b.AboutUs = value.String } case business.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 { b.CreatedAt = value.Time } case business.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 { b.UpdatedAt = value.Time } default: b.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Business. // This includes values selected through modifiers, order, etc. func (b *Business) Value(name string) (ent.Value, error) { return b.selectValues.Get(name) } // QueryBusinessCategory queries the "businessCategory" edge of the Business entity. func (b *Business) QueryBusinessCategory() *BusinessCategoryQuery { return NewBusinessClient(b.config).QueryBusinessCategory(b) } // Update returns a builder for updating this Business. // Note that you need to call Business.Unwrap() before calling this method if this Business // was returned from a transaction, and the transaction was committed or rolled back. func (b *Business) Update() *BusinessUpdateOne { return NewBusinessClient(b.config).UpdateOne(b) } // Unwrap unwraps the Business 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 (b *Business) Unwrap() *Business { _tx, ok := b.config.driver.(*txDriver) if !ok { panic("ent: Business is not a transactional entity") } b.config.driver = _tx.drv return b } // String implements the fmt.Stringer. func (b *Business) String() string { var builder strings.Builder builder.WriteString("Business(") builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) builder.WriteString("name=") builder.WriteString(b.Name) builder.WriteString(", ") builder.WriteString("slug=") builder.WriteString(b.Slug) builder.WriteString(", ") if v := b.BotID; v != nil { builder.WriteString("bot_id=") builder.WriteString(*v) } builder.WriteString(", ") if v := b.Description; v != nil { builder.WriteString("description=") builder.WriteString(*v) } builder.WriteString(", ") builder.WriteString("company=") builder.WriteString(b.Company) builder.WriteString(", ") if v := b.AboutUs; v != nil { builder.WriteString("about_us=") builder.WriteString(*v) } builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(b.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(b.UpdatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // Businesses is a parsable slice of Business. type Businesses []*Business