mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/doc: update field docs
Reviewed By: alexsn Differential Revision: D17074006 fbshipit-source-id: e69c09a5db12b6b59ad6fb00fb47362eb4ab2863
This commit is contained in:
committed by
Facebook Github Bot
parent
62772e0c85
commit
a79c1c20c0
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user