// Code generated by ent, DO NOT EDIT. package ent import ( "encoding/json" "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "git.gorlug.de/code/ersteller/starter/ent/googleauth" "git.gorlug.de/code/ersteller/starter/ent/schema" "git.gorlug.de/code/ersteller/starter/ent/user" ) // GoogleAuth is the model entity for the GoogleAuth schema. type GoogleAuth struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // Credentials holds the value of the "credentials" field. Credentials schema.Credentials `json:"credentials,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the GoogleAuthQuery when eager-loading is set. Edges GoogleAuthEdges `json:"edges"` google_auth_user *int selectValues sql.SelectValues } // GoogleAuthEdges holds the relations/edges for other nodes in the graph. type GoogleAuthEdges struct { // User holds the value of the user edge. User *User `json:"user,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e GoogleAuthEdges) UserOrErr() (*User, error) { if e.User != nil { return e.User, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } // scanValues returns the types for scanning values from sql.Rows. func (*GoogleAuth) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case googleauth.FieldCredentials: values[i] = new([]byte) case googleauth.FieldID: values[i] = new(sql.NullInt64) case googleauth.FieldCreatedAt, googleauth.FieldUpdatedAt: values[i] = new(sql.NullTime) case googleauth.ForeignKeys[0]: // google_auth_user 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 GoogleAuth fields. func (_m *GoogleAuth) 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 googleauth.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } _m.ID = int(value.Int64) case googleauth.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 } case googleauth.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = value.Time } case googleauth.FieldCredentials: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field credentials", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.Credentials); err != nil { return fmt.Errorf("unmarshal field credentials: %w", err) } } case googleauth.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field google_auth_user", value) } else if value.Valid { _m.google_auth_user = new(int) *_m.google_auth_user = int(value.Int64) } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the GoogleAuth. // This includes values selected through modifiers, order, etc. func (_m *GoogleAuth) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryUser queries the "user" edge of the GoogleAuth entity. func (_m *GoogleAuth) QueryUser() *UserQuery { return NewGoogleAuthClient(_m.config).QueryUser(_m) } // Update returns a builder for updating this GoogleAuth. // Note that you need to call GoogleAuth.Unwrap() before calling this method if this GoogleAuth // was returned from a transaction, and the transaction was committed or rolled back. func (_m *GoogleAuth) Update() *GoogleAuthUpdateOne { return NewGoogleAuthClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the GoogleAuth 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 *GoogleAuth) Unwrap() *GoogleAuth { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: GoogleAuth is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *GoogleAuth) String() string { var builder strings.Builder builder.WriteString("GoogleAuth(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("credentials=") builder.WriteString(fmt.Sprintf("%v", _m.Credentials)) builder.WriteByte(')') return builder.String() } // GoogleAuths is a parsable slice of GoogleAuth. type GoogleAuths []*GoogleAuth