// Code generated by ent, DO NOT EDIT.

package ent

import (
	"fmt"
	"galileo/ent/apicategory"
	"strings"

	"entgo.io/ent/dialect/sql"
)

// ApiCategory is the model entity for the ApiCategory schema.
type ApiCategory struct {
	config
	// ID of the ent.
	ID int `json:"id,omitempty"`
}

// scanValues returns the types for scanning values from sql.Rows.
func (*ApiCategory) scanValues(columns []string) ([]any, error) {
	values := make([]any, len(columns))
	for i := range columns {
		switch columns[i] {
		case apicategory.FieldID:
			values[i] = new(sql.NullInt64)
		default:
			return nil, fmt.Errorf("unexpected column %q for type ApiCategory", columns[i])
		}
	}
	return values, nil
}

// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ApiCategory fields.
func (ac *ApiCategory) 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 apicategory.FieldID:
			value, ok := values[i].(*sql.NullInt64)
			if !ok {
				return fmt.Errorf("unexpected type %T for field id", value)
			}
			ac.ID = int(value.Int64)
		}
	}
	return nil
}

// Update returns a builder for updating this ApiCategory.
// Note that you need to call ApiCategory.Unwrap() before calling this method if this ApiCategory
// was returned from a transaction, and the transaction was committed or rolled back.
func (ac *ApiCategory) Update() *ApiCategoryUpdateOne {
	return NewApiCategoryClient(ac.config).UpdateOne(ac)
}

// Unwrap unwraps the ApiCategory 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 (ac *ApiCategory) Unwrap() *ApiCategory {
	_tx, ok := ac.config.driver.(*txDriver)
	if !ok {
		panic("ent: ApiCategory is not a transactional entity")
	}
	ac.config.driver = _tx.drv
	return ac
}

// String implements the fmt.Stringer.
func (ac *ApiCategory) String() string {
	var builder strings.Builder
	builder.WriteString("ApiCategory(")
	builder.WriteString(fmt.Sprintf("id=%v", ac.ID))
	builder.WriteByte(')')
	return builder.String()
}

// ApiCategories is a parsable slice of ApiCategory.
type ApiCategories []*ApiCategory
