28 lines
474 B
Go
28 lines
474 B
Go
package ent
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/mixin"
|
|
)
|
|
|
|
// TimeMixin implements the ent.Mixin for sharing
|
|
// time fields with package schemas.
|
|
type TimeMixin struct {
|
|
mixin.Schema
|
|
}
|
|
|
|
// Fields of the TimeMixin.
|
|
func (TimeMixin) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Time("created_at").
|
|
Default(time.Now).
|
|
Immutable(),
|
|
field.Time("updated_at").
|
|
Default(time.Now).
|
|
UpdateDefault(time.Now),
|
|
}
|
|
}
|