// Code generated by ent, DO NOT EDIT. package db import ( "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/chaitin/MonkeyCode/backend/db/model" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teammodel" "github.com/google/uuid" ) // TeamModel is the model entity for the TeamModel schema. type TeamModel struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // TeamID holds the value of the "team_id" field. TeamID uuid.UUID `json:"team_id,omitempty"` // ModelID holds the value of the "model_id" field. ModelID uuid.UUID `json:"model_id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the TeamModelQuery when eager-loading is set. Edges TeamModelEdges `json:"edges"` selectValues sql.SelectValues } // TeamModelEdges holds the relations/edges for other nodes in the graph. type TeamModelEdges struct { // Team holds the value of the team edge. Team *Team `json:"team,omitempty"` // Model holds the value of the model edge. Model *Model `json:"model,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [2]bool } // TeamOrErr returns the Team value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e TeamModelEdges) TeamOrErr() (*Team, error) { if e.Team != nil { return e.Team, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: team.Label} } return nil, &NotLoadedError{edge: "team"} } // ModelOrErr returns the Model value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e TeamModelEdges) ModelOrErr() (*Model, error) { if e.Model != nil { return e.Model, nil } else if e.loadedTypes[1] { return nil, &NotFoundError{label: model.Label} } return nil, &NotLoadedError{edge: "model"} } // scanValues returns the types for scanning values from sql.Rows. func (*TeamModel) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case teammodel.FieldCreatedAt: values[i] = new(sql.NullTime) case teammodel.FieldID, teammodel.FieldTeamID, teammodel.FieldModelID: 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 TeamModel fields. func (_m *TeamModel) 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 teammodel.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 teammodel.FieldTeamID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field team_id", values[i]) } else if value != nil { _m.TeamID = *value } case teammodel.FieldModelID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field model_id", values[i]) } else if value != nil { _m.ModelID = *value } case teammodel.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 } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the TeamModel. // This includes values selected through modifiers, order, etc. func (_m *TeamModel) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryTeam queries the "team" edge of the TeamModel entity. func (_m *TeamModel) QueryTeam() *TeamQuery { return NewTeamModelClient(_m.config).QueryTeam(_m) } // QueryModel queries the "model" edge of the TeamModel entity. func (_m *TeamModel) QueryModel() *ModelQuery { return NewTeamModelClient(_m.config).QueryModel(_m) } // Update returns a builder for updating this TeamModel. // Note that you need to call TeamModel.Unwrap() before calling this method if this TeamModel // was returned from a transaction, and the transaction was committed or rolled back. func (_m *TeamModel) Update() *TeamModelUpdateOne { return NewTeamModelClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the TeamModel 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 *TeamModel) Unwrap() *TeamModel { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("db: TeamModel is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *TeamModel) String() string { var builder strings.Builder builder.WriteString("TeamModel(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("team_id=") builder.WriteString(fmt.Sprintf("%v", _m.TeamID)) builder.WriteString(", ") builder.WriteString("model_id=") builder.WriteString(fmt.Sprintf("%v", _m.ModelID)) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // TeamModels is a parsable slice of TeamModel. type TeamModels []*TeamModel