Debian Codegraph @

ent/schema/timestamp.go

raw
1 // Copyright 2022 The Archivista Contributors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package schema
16
17 import (
18 "entgo.io/ent"
19 "entgo.io/ent/schema/edge"
20 "entgo.io/ent/schema/field"
21 "github.com/google/uuid"
22 )
23
24 type Timestamp struct {
25 ent.Schema
26 }
27
28 func (Timestamp) Fields() []ent.Field {
29 return []ent.Field{
30 field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(),
31 field.String("type"),
32 field.Time("timestamp"),
33 }
34 }
35
36 func (Timestamp) Edges() []ent.Edge {
37 return []ent.Edge{
38 edge.From("signature", Signature.Type).Ref("timestamps").Unique(),
39 }
40 }