forked from mirrors/homebox
refactor: remove empty services (#116)
* remove empty services * remove old factory * remove old static files * cleanup more duplicate service code * file/folder reorg
This commit is contained in:
parent
6529549289
commit
cd82fe0d89
179 changed files with 514 additions and 582 deletions
42
backend/internal/data/ent/schema/attachment.go
Normal file
42
backend/internal/data/ent/schema/attachment.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// Attachment holds the schema definition for the Attachment entity.
|
||||
type Attachment struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Attachment) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the Attachment.
|
||||
func (Attachment) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Enum("type").
|
||||
Values("photo", "manual", "warranty", "attachment", "receipt").
|
||||
Default("attachment"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Attachment.
|
||||
func (Attachment) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("item", Item.Type).
|
||||
Ref("attachments").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.From("document", Document.Type).
|
||||
Ref("attachments").
|
||||
Required().
|
||||
Unique(),
|
||||
}
|
||||
}
|
47
backend/internal/data/ent/schema/auth_tokens.go
Normal file
47
backend/internal/data/ent/schema/auth_tokens.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// AuthTokens holds the schema definition for the AuthTokens entity.
|
||||
type AuthTokens struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (AuthTokens) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the AuthTokens.
|
||||
func (AuthTokens) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Bytes("token").
|
||||
Unique(),
|
||||
field.Time("expires_at").
|
||||
Default(func() time.Time { return time.Now().Add(time.Hour * 24 * 7) }),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the AuthTokens.
|
||||
func (AuthTokens) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("user", User.Type).
|
||||
Ref("auth_tokens").
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
func (AuthTokens) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("token"),
|
||||
}
|
||||
}
|
50
backend/internal/data/ent/schema/document.go
Normal file
50
backend/internal/data/ent/schema/document.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// Document holds the schema definition for the Document entity.
|
||||
type Document struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Document) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the Document.
|
||||
func (Document) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("title").
|
||||
MaxLen(255).
|
||||
NotEmpty(),
|
||||
field.String("path").
|
||||
MaxLen(500).
|
||||
NotEmpty(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Document.
|
||||
func (Document) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("group", Group.Type).
|
||||
Ref("documents").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.To("document_tokens", DocumentToken.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("attachments", Attachment.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
}
|
50
backend/internal/data/ent/schema/document_token.go
Normal file
50
backend/internal/data/ent/schema/document_token.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// DocumentToken holds the schema definition for the DocumentToken entity.
|
||||
type DocumentToken struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (DocumentToken) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the DocumentToken.
|
||||
func (DocumentToken) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Bytes("token").
|
||||
NotEmpty().
|
||||
Unique(),
|
||||
field.Int("uses").
|
||||
Default(1),
|
||||
field.Time("expires_at").
|
||||
Default(func() time.Time { return time.Now().Add(time.Minute * 10) }),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the DocumentToken.
|
||||
func (DocumentToken) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("document", Document.Type).
|
||||
Ref("document_tokens").
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
func (DocumentToken) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("token"),
|
||||
}
|
||||
}
|
62
backend/internal/data/ent/schema/group.go
Normal file
62
backend/internal/data/ent/schema/group.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// Group holds the schema definition for the Group entity.
|
||||
type Group struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Group) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the Home.
|
||||
func (Group) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name").
|
||||
MaxLen(255).
|
||||
NotEmpty(),
|
||||
field.Enum("currency").
|
||||
Default("usd").
|
||||
Values("usd", "eur", "gbp", "jpy"), // TODO: add more currencies
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Home.
|
||||
func (Group) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("users", User.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("locations", Location.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("items", Item.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("labels", Label.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("documents", Document.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("invitation_tokens", GroupInvitationToken.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
}
|
42
backend/internal/data/ent/schema/group_invitation_token.go
Normal file
42
backend/internal/data/ent/schema/group_invitation_token.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// GroupInvitationToken holds the schema definition for the GroupInvitationToken entity.
|
||||
type GroupInvitationToken struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (GroupInvitationToken) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the GroupInvitationToken.
|
||||
func (GroupInvitationToken) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Bytes("token").
|
||||
Unique(),
|
||||
field.Time("expires_at").
|
||||
Default(func() time.Time { return time.Now().Add(time.Hour * 24 * 7) }),
|
||||
field.Int("uses").
|
||||
Default(0),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the GroupInvitationToken.
|
||||
func (GroupInvitationToken) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("group", Group.Type).
|
||||
Ref("invitation_tokens").
|
||||
Unique(),
|
||||
}
|
||||
}
|
118
backend/internal/data/ent/schema/item.go
Normal file
118
backend/internal/data/ent/schema/item.go
Normal file
|
@ -0,0 +1,118 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// Item holds the schema definition for the Item entity.
|
||||
type Item struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Item) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
mixins.DetailsMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
func (Item) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
// Unique index on the "title" field.
|
||||
index.Fields("name"),
|
||||
index.Fields("manufacturer"),
|
||||
index.Fields("model_number"),
|
||||
index.Fields("serial_number"),
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the Item.
|
||||
func (Item) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("import_ref").
|
||||
Optional().
|
||||
MaxLen(100).
|
||||
Immutable(),
|
||||
field.String("notes").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
field.Int("quantity").
|
||||
Default(1),
|
||||
field.Bool("insured").
|
||||
Default(false),
|
||||
|
||||
// ------------------------------------
|
||||
// item identification
|
||||
field.String("serial_number").
|
||||
MaxLen(255).
|
||||
Optional(),
|
||||
field.String("model_number").
|
||||
MaxLen(255).
|
||||
Optional(),
|
||||
field.String("manufacturer").
|
||||
MaxLen(255).
|
||||
Optional(),
|
||||
|
||||
// ------------------------------------
|
||||
// Item Warranty
|
||||
field.Bool("lifetime_warranty").
|
||||
Default(false),
|
||||
field.Time("warranty_expires").
|
||||
Optional(),
|
||||
field.Text("warranty_details").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
|
||||
// ------------------------------------
|
||||
// item purchase
|
||||
field.Time("purchase_time").
|
||||
Optional(),
|
||||
field.String("purchase_from").
|
||||
Optional(),
|
||||
field.Float("purchase_price").
|
||||
Default(0),
|
||||
|
||||
// ------------------------------------
|
||||
// Sold Details
|
||||
field.Time("sold_time").
|
||||
Optional(),
|
||||
field.String("sold_to").
|
||||
Optional(),
|
||||
field.Float("sold_price").
|
||||
Default(0),
|
||||
field.String("sold_notes").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Item.
|
||||
func (Item) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("children", Item.Type).
|
||||
From("parent").
|
||||
Unique(),
|
||||
edge.From("group", Group.Type).
|
||||
Ref("items").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.From("label", Label.Type).
|
||||
Ref("items"),
|
||||
edge.From("location", Location.Type).
|
||||
Ref("items").
|
||||
Unique(),
|
||||
edge.To("fields", ItemField.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("attachments", Attachment.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
}
|
48
backend/internal/data/ent/schema/item_field.go
Normal file
48
backend/internal/data/ent/schema/item_field.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// ItemField holds the schema definition for the ItemField entity.
|
||||
type ItemField struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (ItemField) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
mixins.DetailsMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the ItemField.
|
||||
func (ItemField) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Enum("type").
|
||||
Values("text", "number", "boolean", "time"),
|
||||
field.String("text_value").
|
||||
MaxLen(500).
|
||||
Optional(),
|
||||
field.Int("number_value").
|
||||
Optional(),
|
||||
field.Bool("boolean_value").
|
||||
Default(false),
|
||||
field.Time("time_value").
|
||||
Default(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the ItemField.
|
||||
func (ItemField) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("item", Item.Type).
|
||||
Ref("fields").
|
||||
Unique(),
|
||||
}
|
||||
}
|
40
backend/internal/data/ent/schema/label.go
Normal file
40
backend/internal/data/ent/schema/label.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// Label holds the schema definition for the Label entity.
|
||||
type Label struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Label) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
mixins.DetailsMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the Label.
|
||||
func (Label) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("color").
|
||||
MaxLen(255).
|
||||
Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Label.
|
||||
func (Label) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("group", Group.Type).
|
||||
Ref("labels").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.To("items", Item.Type),
|
||||
}
|
||||
}
|
42
backend/internal/data/ent/schema/location.go
Normal file
42
backend/internal/data/ent/schema/location.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// Location holds the schema definition for the Location entity.
|
||||
type Location struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Location) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
mixins.DetailsMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the Location.
|
||||
func (Location) Fields() []ent.Field {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Edges of the Location.
|
||||
func (Location) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("children", Location.Type).
|
||||
From("parent").
|
||||
Unique(),
|
||||
edge.From("group", Group.Type).
|
||||
Ref("locations").
|
||||
Unique().
|
||||
Required(),
|
||||
edge.To("items", Item.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
}
|
42
backend/internal/data/ent/schema/mixins/base.go
Normal file
42
backend/internal/data/ent/schema/mixins/base.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package mixins
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/mixin"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type BaseMixin struct {
|
||||
mixin.Schema
|
||||
}
|
||||
|
||||
func (BaseMixin) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.UUID("id", uuid.UUID{}).
|
||||
Default(uuid.New),
|
||||
field.Time("created_at").
|
||||
Immutable().
|
||||
Default(time.Now),
|
||||
field.Time("updated_at").
|
||||
Default(time.Now).
|
||||
UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
type DetailsMixin struct {
|
||||
mixin.Schema
|
||||
}
|
||||
|
||||
func (DetailsMixin) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name").
|
||||
MaxLen(255).
|
||||
NotEmpty(),
|
||||
field.String("description").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
}
|
||||
}
|
18
backend/internal/data/ent/schema/templates/has_id.tmpl
Normal file
18
backend/internal/data/ent/schema/templates/has_id.tmpl
Normal file
|
@ -0,0 +1,18 @@
|
|||
{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}}
|
||||
{{/* gotype: entgo.io/ent/entc/gen.Graph */}}
|
||||
|
||||
{{ define "has_id" }}
|
||||
|
||||
{{/* Add the base header for the generated file */}}
|
||||
{{ $pkg := base $.Config.Package }}
|
||||
{{ template "header" $ }}
|
||||
import "github.com/google/uuid"
|
||||
{{/* Loop over all nodes and implement the "HasID" interface */}}
|
||||
{{ range $n := $.Nodes }}
|
||||
{{ $receiver := $n.Receiver }}
|
||||
func ({{ $receiver }} *{{ $n.Name }}) GetID() uuid.UUID {
|
||||
return {{ $receiver }}.ID
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
60
backend/internal/data/ent/schema/user.go
Normal file
60
backend/internal/data/ent/schema/user.go
Normal file
|
@ -0,0 +1,60 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// User holds the schema definition for the User entity.
|
||||
type User struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (User) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the User.
|
||||
func (User) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name").
|
||||
MaxLen(255).
|
||||
NotEmpty(),
|
||||
field.String("email").
|
||||
MaxLen(255).
|
||||
NotEmpty().
|
||||
Unique(),
|
||||
field.String("password").
|
||||
MaxLen(255).
|
||||
NotEmpty().
|
||||
Sensitive(),
|
||||
field.Bool("is_superuser").
|
||||
Default(false),
|
||||
field.Enum("role").
|
||||
Default("user").
|
||||
Values("user", "owner"),
|
||||
field.Bool("superuser").
|
||||
Default(false),
|
||||
field.Time("activated_on").
|
||||
Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the User.
|
||||
func (User) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("group", Group.Type).
|
||||
Ref("users").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.To("auth_tokens", AuthTokens.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue