// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "code.icod.de/dalu/gomanager/ent/logentry" "code.icod.de/dalu/gomanager/ent/project" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // Logentry is the model entity for the Logentry schema. type Logentry struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // Date holds the value of the "date" field. Date time.Time `json:"date,omitempty"` // Content holds the value of the "content" field. Content string `json:"content,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the LogentryQuery when eager-loading is set. Edges LogentryEdges `json:"edges"` project_logentries *int selectValues sql.SelectValues } // LogentryEdges holds the relations/edges for other nodes in the graph. type LogentryEdges struct { // Project holds the value of the project edge. Project *Project `json:"project,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]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 LogentryEdges) ProjectOrErr() (*Project, error) { if e.loadedTypes[0] { if e.Project == nil { // Edge was loaded but was not found. return nil, &NotFoundError{label: project.Label} } return e.Project, nil } return nil, &NotLoadedError{edge: "project"} } // scanValues returns the types for scanning values from sql.Rows. func (*Logentry) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case logentry.FieldID: values[i] = new(sql.NullInt64) case logentry.FieldContent: values[i] = new(sql.NullString) case logentry.FieldDate: values[i] = new(sql.NullTime) case logentry.ForeignKeys[0]: // project_logentries values[i] = new(sql.NullInt64) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Logentry fields. func (l *Logentry) 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 logentry.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } l.ID = int(value.Int64) case logentry.FieldDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field date", values[i]) } else if value.Valid { l.Date = value.Time } case logentry.FieldContent: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field content", values[i]) } else if value.Valid { l.Content = value.String } case logentry.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field project_logentries", value) } else if value.Valid { l.project_logentries = new(int) *l.project_logentries = int(value.Int64) } default: l.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Logentry. // This includes values selected through modifiers, order, etc. func (l *Logentry) Value(name string) (ent.Value, error) { return l.selectValues.Get(name) } // QueryProject queries the "project" edge of the Logentry entity. func (l *Logentry) QueryProject() *ProjectQuery { return NewLogentryClient(l.config).QueryProject(l) } // Update returns a builder for updating this Logentry. // Note that you need to call Logentry.Unwrap() before calling this method if this Logentry // was returned from a transaction, and the transaction was committed or rolled back. func (l *Logentry) Update() *LogentryUpdateOne { return NewLogentryClient(l.config).UpdateOne(l) } // Unwrap unwraps the Logentry 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 (l *Logentry) Unwrap() *Logentry { _tx, ok := l.config.driver.(*txDriver) if !ok { panic("ent: Logentry is not a transactional entity") } l.config.driver = _tx.drv return l } // String implements the fmt.Stringer. func (l *Logentry) String() string { var builder strings.Builder builder.WriteString("Logentry(") builder.WriteString(fmt.Sprintf("id=%v, ", l.ID)) builder.WriteString("date=") builder.WriteString(l.Date.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("content=") builder.WriteString(l.Content) builder.WriteByte(')') return builder.String() } // Logentries is a parsable slice of Logentry. type Logentries []*Logentry