Debian Codegraph @

ent/timestamp.go

raw
1 // Code generated by ent, DO NOT EDIT.
2
3 package ent
4
5 import (
6 "fmt"
7 "strings"
8 "time"
9
10 "entgo.io/ent"
11 "entgo.io/ent/dialect/sql"
12 "github.com/google/uuid"
13 "github.com/in-toto/archivista/ent/signature"
14 "github.com/in-toto/archivista/ent/timestamp"
15 )
16
17 // Timestamp is the model entity for the Timestamp schema.
18 type Timestamp struct {
19 config `json:"-"`
20 // ID of the ent.
21 ID uuid.UUID `json:"id,omitempty"`
22 // Type holds the value of the "type" field.
23 Type string `json:"type,omitempty"`
24 // Timestamp holds the value of the "timestamp" field.
25 Timestamp time.Time `json:"timestamp,omitempty"`
26 // Edges holds the relations/edges for other nodes in the graph.
27 // The values are being populated by the TimestampQuery when eager-loading is set.
28 Edges TimestampEdges `json:"edges"`
29 signature_timestamps *uuid.UUID
30 selectValues sql.SelectValues
31 }
32
33 // TimestampEdges holds the relations/edges for other nodes in the graph.
34 type TimestampEdges struct {
35 // Signature holds the value of the signature edge.
36 Signature *Signature `json:"signature,omitempty"`
37 // loadedTypes holds the information for reporting if a
38 // type was loaded (or requested) in eager-loading or not.
39 loadedTypes [1]bool
40 // totalCount holds the count of the edges above.
41 totalCount [1]map[string]int
42 }
43
44 // SignatureOrErr returns the Signature value or an error if the edge
45 // was not loaded in eager-loading, or loaded but was not found.
46 func (e TimestampEdges) SignatureOrErr() (*Signature, error) {
47 if e.Signature != nil {
48 return e.Signature, nil
49 } else if e.loadedTypes[0] {
50 return nil, &NotFoundError{label: signature.Label}
51 }
52 return nil, &NotLoadedError{edge: "signature"}
53 }
54
55 // scanValues returns the types for scanning values from sql.Rows.
56 func (*Timestamp) scanValues(columns []string) ([]any, error) {
57 values := make([]any, len(columns))
58 for i := range columns {
59 switch columns[i] {
60 case timestamp.FieldType:
61 values[i] = new(sql.NullString)
62 case timestamp.FieldTimestamp:
63 values[i] = new(sql.NullTime)
64 case timestamp.FieldID:
65 values[i] = new(uuid.UUID)
66 case timestamp.ForeignKeys[0]: // signature_timestamps
67 values[i] = &sql.NullScanner{S: new(uuid.UUID)}
68 default:
69 values[i] = new(sql.UnknownType)
70 }
71 }
72 return values, nil
73 }
74
75 // assignValues assigns the values that were returned from sql.Rows (after scanning)
76 // to the Timestamp fields.
77 func (_m *Timestamp) assignValues(columns []string, values []any) error {
78 if m, n := len(values), len(columns); m < n {
79 return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
80 }
81 for i := range columns {
82 switch columns[i] {
83 case timestamp.FieldID:
84 if value, ok := values[i].(*uuid.UUID); !ok {
85 return fmt.Errorf("unexpected type %T for field id", values[i])
86 } else if value != nil {
87 _m.ID = *value
88 }
89 case timestamp.FieldType:
90 if value, ok := values[i].(*sql.NullString); !ok {
91 return fmt.Errorf("unexpected type %T for field type", values[i])
92 } else if value.Valid {
93 _m.Type = value.String
94 }
95 case timestamp.FieldTimestamp:
96 if value, ok := values[i].(*sql.NullTime); !ok {
97 return fmt.Errorf("unexpected type %T for field timestamp", values[i])
98 } else if value.Valid {
99 _m.Timestamp = value.Time
100 }
101 case timestamp.ForeignKeys[0]:
102 if value, ok := values[i].(*sql.NullScanner); !ok {
103 return fmt.Errorf("unexpected type %T for field signature_timestamps", values[i])
104 } else if value.Valid {
105 _m.signature_timestamps = new(uuid.UUID)
106 *_m.signature_timestamps = *value.S.(*uuid.UUID)
107 }
108 default:
109 _m.selectValues.Set(columns[i], values[i])
110 }
111 }
112 return nil
113 }
114
115 // Value returns the ent.Value that was dynamically selected and assigned to the Timestamp.
116 // This includes values selected through modifiers, order, etc.
117 func (_m *Timestamp) Value(name string) (ent.Value, error) {
118 return _m.selectValues.Get(name)
119 }
120
121 // QuerySignature queries the "signature" edge of the Timestamp entity.
122 func (_m *Timestamp) QuerySignature() *SignatureQuery {
123 return NewTimestampClient(_m.config).QuerySignature(_m)
124 }
125
126 // Update returns a builder for updating this Timestamp.
127 // Note that you need to call Timestamp.Unwrap() before calling this method if this Timestamp
128 // was returned from a transaction, and the transaction was committed or rolled back.
129 func (_m *Timestamp) Update() *TimestampUpdateOne {
130 return NewTimestampClient(_m.config).UpdateOne(_m)
131 }
132
133 // Unwrap unwraps the Timestamp entity that was returned from a transaction after it was closed,
134 // so that all future queries will be executed through the driver which created the transaction.
135 func (_m *Timestamp) Unwrap() *Timestamp {
136 _tx, ok := _m.config.driver.(*txDriver)
137 if !ok {
138 panic("ent: Timestamp is not a transactional entity")
139 }
140 _m.config.driver = _tx.drv
141 return _m
142 }
143
144 // String implements the fmt.Stringer.
145 func (_m *Timestamp) String() string {
146 var builder strings.Builder
147 builder.WriteString("Timestamp(")
148 builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
149 builder.WriteString("type=")
150 builder.WriteString(_m.Type)
151 builder.WriteString(", ")
152 builder.WriteString("timestamp=")
153 builder.WriteString(_m.Timestamp.Format(time.ANSIC))
154 builder.WriteByte(')')
155 return builder.String()
156 }
157
158 // Timestamps is a parsable slice of Timestamp.
159 type Timestamps []*Timestamp