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