homebox/backend/ent/schema/user.go
Hayden 31b34241e0
feat: item-attachments CRUD (#22)
* change /content/ -> /homebox/

* add cache to code generators

* update env variables to set data storage

* update env variables

* set env variables in prod container

* implement attachment post route (WIP)

* get attachment endpoint

* attachment download

* implement string utilities lib

* implement generic drop zone

* use explicit truncate

* remove clean dir

* drop strings composable for lib

* update item types and add attachments

* add attachment API

* implement service context

* consolidate API code

* implement editing attachments

* implement upload limit configuration

* improve error handling

* add docs for max upload size

* fix test cases
2022-09-24 11:33:38 -08:00

52 lines
962 B
Go

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/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),
}
}
// 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,
}),
}
}