// 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/gitbot" "github.com/chaitin/MonkeyCode/backend/db/project" "github.com/chaitin/MonkeyCode/backend/db/projectgitbot" "github.com/google/uuid" ) // ProjectGitBot is the model entity for the ProjectGitBot schema. type ProjectGitBot struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // ProjectID holds the value of the "project_id" field. ProjectID uuid.UUID `json:"project_id,omitempty"` // GitBotID holds the value of the "git_bot_id" field. GitBotID uuid.UUID `json:"git_bot_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 ProjectGitBotQuery when eager-loading is set. Edges ProjectGitBotEdges `json:"edges"` selectValues sql.SelectValues } // ProjectGitBotEdges holds the relations/edges for other nodes in the graph. type ProjectGitBotEdges struct { // Project holds the value of the project edge. Project *Project `json:"project,omitempty"` // GitBot holds the value of the git_bot edge. GitBot *GitBot `json:"git_bot,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [2]bool } // ProjectOrErr returns the Project value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e ProjectGitBotEdges) ProjectOrErr() (*Project, error) { if e.Project != nil { return e.Project, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: project.Label} } return nil, &NotLoadedError{edge: "project"} } // GitBotOrErr returns the GitBot value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e ProjectGitBotEdges) GitBotOrErr() (*GitBot, error) { if e.GitBot != nil { return e.GitBot, nil } else if e.loadedTypes[1] { return nil, &NotFoundError{label: gitbot.Label} } return nil, &NotLoadedError{edge: "git_bot"} } // scanValues returns the types for scanning values from sql.Rows. func (*ProjectGitBot) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case projectgitbot.FieldCreatedAt: values[i] = new(sql.NullTime) case projectgitbot.FieldID, projectgitbot.FieldProjectID, projectgitbot.FieldGitBotID: 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 ProjectGitBot fields. func (_m *ProjectGitBot) 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 projectgitbot.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 projectgitbot.FieldProjectID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field project_id", values[i]) } else if value != nil { _m.ProjectID = *value } case projectgitbot.FieldGitBotID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field git_bot_id", values[i]) } else if value != nil { _m.GitBotID = *value } case projectgitbot.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 ProjectGitBot. // This includes values selected through modifiers, order, etc. func (_m *ProjectGitBot) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryProject queries the "project" edge of the ProjectGitBot entity. func (_m *ProjectGitBot) QueryProject() *ProjectQuery { return NewProjectGitBotClient(_m.config).QueryProject(_m) } // QueryGitBot queries the "git_bot" edge of the ProjectGitBot entity. func (_m *ProjectGitBot) QueryGitBot() *GitBotQuery { return NewProjectGitBotClient(_m.config).QueryGitBot(_m) } // Update returns a builder for updating this ProjectGitBot. // Note that you need to call ProjectGitBot.Unwrap() before calling this method if this ProjectGitBot // was returned from a transaction, and the transaction was committed or rolled back. func (_m *ProjectGitBot) Update() *ProjectGitBotUpdateOne { return NewProjectGitBotClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the ProjectGitBot 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 *ProjectGitBot) Unwrap() *ProjectGitBot { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("db: ProjectGitBot is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *ProjectGitBot) String() string { var builder strings.Builder builder.WriteString("ProjectGitBot(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("project_id=") builder.WriteString(fmt.Sprintf("%v", _m.ProjectID)) builder.WriteString(", ") builder.WriteString("git_bot_id=") builder.WriteString(fmt.Sprintf("%v", _m.GitBotID)) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // ProjectGitBots is a parsable slice of ProjectGitBot. type ProjectGitBots []*ProjectGitBot