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