rano/db/ent/schema/schema.go

37 lines
637 B
Go
Raw Normal View History

2024-11-10 09:22:33 +00:00
package schema
import (
"time"
"entgo.io/contrib/entgql"
"entgo.io/ent/schema/field"
)
var fieldID = field.Int64("id").
Immutable().
Unique()
var fieldCreated = field.Time("created_at").
Immutable().
Default(time.Now).
StructTag(`json:"createdAt"`).
Annotations(
entgql.OrderField("created"),
)
var fieldUpdated = field.Time("updated_at").
Default(time.Now).
UpdateDefault(time.Now).
StructTag(`json:"updatedAt"`).
Annotations(
entgql.OrderField("updated"),
)
var fieldDeleted = field.Time("deleted_at").
Optional().
Nillable().
StructTag(`json:"deletedAt"`).
Annotations(
entgql.OrderField("deleted"),
)