securitysecret.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "entgo.io/ent"
  8. "entgo.io/ent/dialect/sql"
  9. "github.com/Wei-Shaw/sub2api/ent/securitysecret"
  10. )
  11. // SecuritySecret is the model entity for the SecuritySecret schema.
  12. type SecuritySecret struct {
  13. config `json:"-"`
  14. // ID of the ent.
  15. ID int64 `json:"id,omitempty"`
  16. // CreatedAt holds the value of the "created_at" field.
  17. CreatedAt time.Time `json:"created_at,omitempty"`
  18. // UpdatedAt holds the value of the "updated_at" field.
  19. UpdatedAt time.Time `json:"updated_at,omitempty"`
  20. // Key holds the value of the "key" field.
  21. Key string `json:"key,omitempty"`
  22. // Value holds the value of the "value" field.
  23. Value string `json:"value,omitempty"`
  24. selectValues sql.SelectValues
  25. }
  26. // scanValues returns the types for scanning values from sql.Rows.
  27. func (*SecuritySecret) scanValues(columns []string) ([]any, error) {
  28. values := make([]any, len(columns))
  29. for i := range columns {
  30. switch columns[i] {
  31. case securitysecret.FieldID:
  32. values[i] = new(sql.NullInt64)
  33. case securitysecret.FieldKey, securitysecret.FieldValue:
  34. values[i] = new(sql.NullString)
  35. case securitysecret.FieldCreatedAt, securitysecret.FieldUpdatedAt:
  36. values[i] = new(sql.NullTime)
  37. default:
  38. values[i] = new(sql.UnknownType)
  39. }
  40. }
  41. return values, nil
  42. }
  43. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  44. // to the SecuritySecret fields.
  45. func (_m *SecuritySecret) assignValues(columns []string, values []any) error {
  46. if m, n := len(values), len(columns); m < n {
  47. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  48. }
  49. for i := range columns {
  50. switch columns[i] {
  51. case securitysecret.FieldID:
  52. value, ok := values[i].(*sql.NullInt64)
  53. if !ok {
  54. return fmt.Errorf("unexpected type %T for field id", value)
  55. }
  56. _m.ID = int64(value.Int64)
  57. case securitysecret.FieldCreatedAt:
  58. if value, ok := values[i].(*sql.NullTime); !ok {
  59. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  60. } else if value.Valid {
  61. _m.CreatedAt = value.Time
  62. }
  63. case securitysecret.FieldUpdatedAt:
  64. if value, ok := values[i].(*sql.NullTime); !ok {
  65. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  66. } else if value.Valid {
  67. _m.UpdatedAt = value.Time
  68. }
  69. case securitysecret.FieldKey:
  70. if value, ok := values[i].(*sql.NullString); !ok {
  71. return fmt.Errorf("unexpected type %T for field key", values[i])
  72. } else if value.Valid {
  73. _m.Key = value.String
  74. }
  75. case securitysecret.FieldValue:
  76. if value, ok := values[i].(*sql.NullString); !ok {
  77. return fmt.Errorf("unexpected type %T for field value", values[i])
  78. } else if value.Valid {
  79. _m.Value = value.String
  80. }
  81. default:
  82. _m.selectValues.Set(columns[i], values[i])
  83. }
  84. }
  85. return nil
  86. }
  87. // GetValue returns the ent.Value that was dynamically selected and assigned to the SecuritySecret.
  88. // This includes values selected through modifiers, order, etc.
  89. func (_m *SecuritySecret) GetValue(name string) (ent.Value, error) {
  90. return _m.selectValues.Get(name)
  91. }
  92. // Update returns a builder for updating this SecuritySecret.
  93. // Note that you need to call SecuritySecret.Unwrap() before calling this method if this SecuritySecret
  94. // was returned from a transaction, and the transaction was committed or rolled back.
  95. func (_m *SecuritySecret) Update() *SecuritySecretUpdateOne {
  96. return NewSecuritySecretClient(_m.config).UpdateOne(_m)
  97. }
  98. // Unwrap unwraps the SecuritySecret entity that was returned from a transaction after it was closed,
  99. // so that all future queries will be executed through the driver which created the transaction.
  100. func (_m *SecuritySecret) Unwrap() *SecuritySecret {
  101. _tx, ok := _m.config.driver.(*txDriver)
  102. if !ok {
  103. panic("ent: SecuritySecret is not a transactional entity")
  104. }
  105. _m.config.driver = _tx.drv
  106. return _m
  107. }
  108. // String implements the fmt.Stringer.
  109. func (_m *SecuritySecret) String() string {
  110. var builder strings.Builder
  111. builder.WriteString("SecuritySecret(")
  112. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  113. builder.WriteString("created_at=")
  114. builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
  115. builder.WriteString(", ")
  116. builder.WriteString("updated_at=")
  117. builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
  118. builder.WriteString(", ")
  119. builder.WriteString("key=")
  120. builder.WriteString(_m.Key)
  121. builder.WriteString(", ")
  122. builder.WriteString("value=")
  123. builder.WriteString(_m.Value)
  124. builder.WriteByte(')')
  125. return builder.String()
  126. }
  127. // SecuritySecrets is a parsable slice of SecuritySecret.
  128. type SecuritySecrets []*SecuritySecret