2024-03-13 14:39:45 +01:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2024-05-16 17:36:44 +02:00
|
|
|
"portfolio/database/ent/project"
|
2024-03-13 14:39:45 +01:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Project is the model entity for the Project schema.
|
|
|
|
|
type Project struct {
|
|
|
|
|
config `json:"-"`
|
|
|
|
|
// ID of the ent.
|
|
|
|
|
ID int `json:"id,omitempty"`
|
|
|
|
|
// Name holds the value of the "name" field.
|
|
|
|
|
Name string `json:"name,omitempty"`
|
2024-05-19 17:04:15 +02:00
|
|
|
// Description holds the value of the "description" field.
|
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
|
// URL holds the value of the "url" field.
|
|
|
|
|
URL string `json:"url,omitempty"`
|
|
|
|
|
// ImageURL holds the value of the "image_url" field.
|
|
|
|
|
ImageURL string `json:"image_url,omitempty"`
|
|
|
|
|
// DocURL holds the value of the "doc_url" field.
|
|
|
|
|
DocURL string `json:"doc_url,omitempty"`
|
2024-03-13 14:39:45 +01:00
|
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
|
|
|
// The values are being populated by the ProjectQuery when eager-loading is set.
|
|
|
|
|
Edges ProjectEdges `json:"edges"`
|
|
|
|
|
selectValues sql.SelectValues
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProjectEdges holds the relations/edges for other nodes in the graph.
|
|
|
|
|
type ProjectEdges struct {
|
2024-05-19 17:04:15 +02:00
|
|
|
// Users holds the value of the users edge.
|
|
|
|
|
Users []*User `json:"users,omitempty"`
|
|
|
|
|
// Teams holds the value of the teams edge.
|
|
|
|
|
Teams []*Team `json:"teams,omitempty"`
|
2024-03-13 14:39:45 +01:00
|
|
|
// loadedTypes holds the information for reporting if a
|
|
|
|
|
// type was loaded (or requested) in eager-loading or not.
|
2024-05-19 17:04:15 +02:00
|
|
|
loadedTypes [2]bool
|
2024-03-13 14:39:45 +01:00
|
|
|
}
|
|
|
|
|
|
2024-05-19 17:04:15 +02:00
|
|
|
// UsersOrErr returns the Users value or an error if the edge
|
|
|
|
|
// was not loaded in eager-loading.
|
|
|
|
|
func (e ProjectEdges) UsersOrErr() ([]*User, error) {
|
|
|
|
|
if e.loadedTypes[0] {
|
|
|
|
|
return e.Users, nil
|
2024-03-13 14:39:45 +01:00
|
|
|
}
|
2024-05-19 17:04:15 +02:00
|
|
|
return nil, &NotLoadedError{edge: "users"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TeamsOrErr returns the Teams value or an error if the edge
|
|
|
|
|
// was not loaded in eager-loading.
|
|
|
|
|
func (e ProjectEdges) TeamsOrErr() ([]*Team, error) {
|
|
|
|
|
if e.loadedTypes[1] {
|
|
|
|
|
return e.Teams, nil
|
|
|
|
|
}
|
|
|
|
|
return nil, &NotLoadedError{edge: "teams"}
|
2024-03-13 14:39:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
|
|
|
func (*Project) scanValues(columns []string) ([]any, error) {
|
|
|
|
|
values := make([]any, len(columns))
|
|
|
|
|
for i := range columns {
|
|
|
|
|
switch columns[i] {
|
|
|
|
|
case project.FieldID:
|
|
|
|
|
values[i] = new(sql.NullInt64)
|
2024-05-19 17:04:15 +02:00
|
|
|
case project.FieldName, project.FieldDescription, project.FieldURL, project.FieldImageURL, project.FieldDocURL:
|
2024-03-13 14:39:45 +01:00
|
|
|
values[i] = new(sql.NullString)
|
|
|
|
|
default:
|
|
|
|
|
values[i] = new(sql.UnknownType)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return values, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
|
|
|
// to the Project fields.
|
|
|
|
|
func (pr *Project) 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 project.FieldID:
|
|
|
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
|
|
|
}
|
|
|
|
|
pr.ID = int(value.Int64)
|
|
|
|
|
case project.FieldName:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
pr.Name = value.String
|
|
|
|
|
}
|
2024-05-19 17:04:15 +02:00
|
|
|
case project.FieldDescription:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
pr.Description = value.String
|
|
|
|
|
}
|
|
|
|
|
case project.FieldURL:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field url", values[i])
|
2024-03-13 14:39:45 +01:00
|
|
|
} else if value.Valid {
|
2024-05-19 17:04:15 +02:00
|
|
|
pr.URL = value.String
|
|
|
|
|
}
|
|
|
|
|
case project.FieldImageURL:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field image_url", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
pr.ImageURL = value.String
|
|
|
|
|
}
|
|
|
|
|
case project.FieldDocURL:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field doc_url", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
pr.DocURL = value.String
|
2024-03-13 14:39:45 +01:00
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
pr.selectValues.Set(columns[i], values[i])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Project.
|
|
|
|
|
// This includes values selected through modifiers, order, etc.
|
|
|
|
|
func (pr *Project) Value(name string) (ent.Value, error) {
|
|
|
|
|
return pr.selectValues.Get(name)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-19 17:04:15 +02:00
|
|
|
// QueryUsers queries the "users" edge of the Project entity.
|
|
|
|
|
func (pr *Project) QueryUsers() *UserQuery {
|
|
|
|
|
return NewProjectClient(pr.config).QueryUsers(pr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QueryTeams queries the "teams" edge of the Project entity.
|
|
|
|
|
func (pr *Project) QueryTeams() *TeamQuery {
|
|
|
|
|
return NewProjectClient(pr.config).QueryTeams(pr)
|
2024-03-13 14:39:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns a builder for updating this Project.
|
|
|
|
|
// Note that you need to call Project.Unwrap() before calling this method if this Project
|
|
|
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
|
|
|
func (pr *Project) Update() *ProjectUpdateOne {
|
|
|
|
|
return NewProjectClient(pr.config).UpdateOne(pr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Unwrap unwraps the Project 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 (pr *Project) Unwrap() *Project {
|
|
|
|
|
_tx, ok := pr.config.driver.(*txDriver)
|
|
|
|
|
if !ok {
|
|
|
|
|
panic("ent: Project is not a transactional entity")
|
|
|
|
|
}
|
|
|
|
|
pr.config.driver = _tx.drv
|
|
|
|
|
return pr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer.
|
|
|
|
|
func (pr *Project) String() string {
|
|
|
|
|
var builder strings.Builder
|
|
|
|
|
builder.WriteString("Project(")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", pr.ID))
|
|
|
|
|
builder.WriteString("name=")
|
|
|
|
|
builder.WriteString(pr.Name)
|
2024-05-19 17:04:15 +02:00
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("description=")
|
|
|
|
|
builder.WriteString(pr.Description)
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("url=")
|
|
|
|
|
builder.WriteString(pr.URL)
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("image_url=")
|
|
|
|
|
builder.WriteString(pr.ImageURL)
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("doc_url=")
|
|
|
|
|
builder.WriteString(pr.DocURL)
|
2024-03-13 14:39:45 +01:00
|
|
|
builder.WriteByte(')')
|
|
|
|
|
return builder.String()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Projects is a parsable slice of Project.
|
|
|
|
|
type Projects []*Project
|