Created
December 10, 2021 04:27
-
-
Save manakuro/7c7f0bf9c9e330e8bdb671c96124d4ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Fields of the Todo. | |
| func (Todo) Fields() []ent.Field { | |
| return []ent.Field{ | |
| field.Int("user_id").Optional(), | |
| field.String("name").Default(""), | |
| field.Enum("status"). | |
| NamedValues( | |
| "InProgress", "IN_PROGRESS", | |
| "Completed", "COMPLETED", | |
| ). | |
| Default("IN_PROGRESS"), | |
| field.Int("priority").Default(0), | |
| field.Time("created_at"). | |
| Default(time.Now). | |
| SchemaType(map[string]string{ | |
| dialect.MySQL: "datetime DEFAULT CURRENT_TIMESTAMP", | |
| }). | |
| Immutable(), | |
| field.Time("updated_at"). | |
| Default(time.Now). | |
| SchemaType(map[string]string{ | |
| dialect.MySQL: "datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", | |
| }). | |
| Immutable(), | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment