// 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/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" "github.com/google/uuid" ) // TeamGroupModel is the model entity for the TeamGroupModel schema. type TeamGroupModel struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // GroupID holds the value of the "group_id" field. GroupID uuid.UUID `json:"group_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 TeamGroupModelQuery when eager-loading is set. Edges TeamGroupModelEdges `json:"edges"` selectValues sql.SelectValues } // TeamGroupModelEdges holds the relations/edges for other nodes in the graph. type TeamGroupModelEdges struct { // Group holds the value of the group edge. Group *TeamGroup `json:"group,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 } // GroupOrErr returns the Group value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e TeamGroupModelEdges) GroupOrErr() (*TeamGroup, error) { if e.Group != nil { return e.Group, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: teamgroup.Label} } return nil, &NotLoadedError{edge: "group"} } // 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 TeamGroupModelEdges) 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 (*TeamGroupModel) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case teamgroupmodel.FieldCreatedAt: values[i] = new(sql.NullTime) case teamgroupmodel.FieldID, teamgroupmodel.FieldGroupID, teamgroupmodel.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 TeamGroupModel fields. func (_m *TeamGroupModel) 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 teamgroupmodel.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 teamgroupmodel.FieldGroupID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field group_id", values[i]) } else if value != nil { _m.GroupID = *value } case teamgroupmodel.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 teamgroupmodel.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 TeamGroupModel. // This includes values selected through modifiers, order, etc. func (_m *TeamGroupModel) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryGroup queries the "group" edge of the TeamGroupModel entity. func (_m *TeamGroupModel) QueryGroup() *TeamGroupQuery { return NewTeamGroupModelClient(_m.config).QueryGroup(_m) } // QueryModel queries the "model" edge of the TeamGroupModel entity. func (_m *TeamGroupModel) QueryModel() *ModelQuery { return NewTeamGroupModelClient(_m.config).QueryModel(_m) } // Update returns a builder for updating this TeamGroupModel. // Note that you need to call TeamGroupModel.Unwrap() before calling this method if this TeamGroupModel // was returned from a transaction, and the transaction was committed or rolled back. func (_m *TeamGroupModel) Update() *TeamGroupModelUpdateOne { return NewTeamGroupModelClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the TeamGroupModel 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 *TeamGroupModel) Unwrap() *TeamGroupModel { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("db: TeamGroupModel is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *TeamGroupModel) String() string { var builder strings.Builder builder.WriteString("TeamGroupModel(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("group_id=") builder.WriteString(fmt.Sprintf("%v", _m.GroupID)) 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() } // TeamGroupModels is a parsable slice of TeamGroupModel. type TeamGroupModels []*TeamGroupModel