ent/doc: update field docs

Reviewed By: alexsn

Differential Revision: D17074006

fbshipit-source-id: e69c09a5db12b6b59ad6fb00fb47362eb4ab2863
This commit is contained in:
Ariel Mashraki
2019-08-27 10:20:55 -07:00
committed by Facebook Github Bot
parent 62772e0c85
commit a79c1c20c0

View File

@@ -88,7 +88,20 @@ To read more about how each type is mapped to its database-type, go to the [Migr
## Default Values
**Non-unique** fields support default values using the `.Default` method.
**Non-unique** fields support default values using the `.Default` and `.UpdateDefault` methods.
```go
// Fields of the User.
func (User) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Default(time.Now),
field.Time("updated_at").
Default(time.Now).
UpdateDefault(time.Now),
}
}
```
## Validators