-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotation.go
67 lines (54 loc) · 2.08 KB
/
annotation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package entx
// CascadeAnnotationName is a name for our cascading delete annotation
var CascadeAnnotationName = "DATUM_CASCADE"
// CascadeThroughAnnotationName is a name for our cascading through edge delete annotation
var CascadeThroughAnnotationName = "DATUM_CASCADE_THROUGH"
// SchemaGenAnnotationName is a name for our graphql schema generation annotation
var SchemaGenAnnotationName = "DATUM_SCHEMAGEN"
// CascadeAnnotation is an annotation used to indicate that an edge should be cascaded
type CascadeAnnotation struct {
Field string
}
// CascadeThroughAnnotation is an annotation used to indicate that an edge should be cascaded through
type CascadeThroughAnnotation struct {
Schemas []ThroughCleanup
}
// ThroughCleanup is a struct used to indicate the field and through edge to cascade through
type ThroughCleanup struct {
Field string
Through string
}
// SchemaGenAnnotation is an annotation used to indicate that schema generation should be skipped for this type
type SchemaGenAnnotation struct {
Skip bool
}
// Name returns the name of the CascadeAnnotation
func (a CascadeAnnotation) Name() string {
return CascadeAnnotationName
}
// Name returns the name of the CascadeThroughAnnotation
func (a CascadeThroughAnnotation) Name() string {
return CascadeThroughAnnotationName
}
// Name returns the name of the SchemaGenAnnotation
func (a SchemaGenAnnotation) Name() string {
return SchemaGenAnnotationName
}
// CascadeAnnotationField sets the field name of the edge containing the ID of a record from the current schema
func CascadeAnnotationField(fieldname string) *CascadeAnnotation {
return &CascadeAnnotation{
Field: fieldname,
}
}
// CascadeThroughAnnotationField sets the field name of the edge containing the ID of a record from the current schema
func CascadeThroughAnnotationField(schemas []ThroughCleanup) *CascadeThroughAnnotation {
return &CascadeThroughAnnotation{
Schemas: schemas,
}
}
// SchemaGenSkip sets the whether schema generation should be skipped for this type
func SchemaGenSkip(skip bool) *SchemaGenAnnotation {
return &SchemaGenAnnotation{
Skip: skip,
}
}