// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "tss-rocks-be/ent/contributor" "tss-rocks-be/ent/contributorsociallink" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // ContributorSocialLink is the model entity for the ContributorSocialLink schema. type ContributorSocialLink struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // Type holds the value of the "type" field. Type contributorsociallink.Type `json:"type,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Value holds the value of the "value" field. Value string `json:"value,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ContributorSocialLinkQuery when eager-loading is set. Edges ContributorSocialLinkEdges `json:"edges"` contributor_social_links *int selectValues sql.SelectValues } // ContributorSocialLinkEdges holds the relations/edges for other nodes in the graph. type ContributorSocialLinkEdges struct { // Contributor holds the value of the contributor edge. Contributor *Contributor `json:"contributor,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // ContributorOrErr returns the Contributor value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e ContributorSocialLinkEdges) ContributorOrErr() (*Contributor, error) { if e.Contributor != nil { return e.Contributor, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: contributor.Label} } return nil, &NotLoadedError{edge: "contributor"} } // scanValues returns the types for scanning values from sql.Rows. func (*ContributorSocialLink) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case contributorsociallink.FieldID: values[i] = new(sql.NullInt64) case contributorsociallink.FieldType, contributorsociallink.FieldName, contributorsociallink.FieldValue: values[i] = new(sql.NullString) case contributorsociallink.ForeignKeys[0]: // contributor_social_links 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 ContributorSocialLink fields. func (csl *ContributorSocialLink) 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 contributorsociallink.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } csl.ID = int(value.Int64) case contributorsociallink.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { csl.Type = contributorsociallink.Type(value.String) } case contributorsociallink.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { csl.Name = value.String } case contributorsociallink.FieldValue: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field value", values[i]) } else if value.Valid { csl.Value = value.String } case contributorsociallink.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field contributor_social_links", value) } else if value.Valid { csl.contributor_social_links = new(int) *csl.contributor_social_links = int(value.Int64) } default: csl.selectValues.Set(columns[i], values[i]) } } return nil } // GetValue returns the ent.Value that was dynamically selected and assigned to the ContributorSocialLink. // This includes values selected through modifiers, order, etc. func (csl *ContributorSocialLink) GetValue(name string) (ent.Value, error) { return csl.selectValues.Get(name) } // QueryContributor queries the "contributor" edge of the ContributorSocialLink entity. func (csl *ContributorSocialLink) QueryContributor() *ContributorQuery { return NewContributorSocialLinkClient(csl.config).QueryContributor(csl) } // Update returns a builder for updating this ContributorSocialLink. // Note that you need to call ContributorSocialLink.Unwrap() before calling this method if this ContributorSocialLink // was returned from a transaction, and the transaction was committed or rolled back. func (csl *ContributorSocialLink) Update() *ContributorSocialLinkUpdateOne { return NewContributorSocialLinkClient(csl.config).UpdateOne(csl) } // Unwrap unwraps the ContributorSocialLink 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 (csl *ContributorSocialLink) Unwrap() *ContributorSocialLink { _tx, ok := csl.config.driver.(*txDriver) if !ok { panic("ent: ContributorSocialLink is not a transactional entity") } csl.config.driver = _tx.drv return csl } // String implements the fmt.Stringer. func (csl *ContributorSocialLink) String() string { var builder strings.Builder builder.WriteString("ContributorSocialLink(") builder.WriteString(fmt.Sprintf("id=%v, ", csl.ID)) builder.WriteString("type=") builder.WriteString(fmt.Sprintf("%v", csl.Type)) builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(csl.Name) builder.WriteString(", ") builder.WriteString("value=") builder.WriteString(csl.Value) builder.WriteByte(')') return builder.String() } // ContributorSocialLinks is a parsable slice of ContributorSocialLink. type ContributorSocialLinks []*ContributorSocialLink