From a79c1c20c0d020bcea162c8567cbd8fdd65fc049 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Tue, 27 Aug 2019 10:20:55 -0700 Subject: [PATCH] ent/doc: update field docs Reviewed By: alexsn Differential Revision: D17074006 fbshipit-source-id: e69c09a5db12b6b59ad6fb00fb47362eb4ab2863 --- doc/md/schema-fields.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/md/schema-fields.md b/doc/md/schema-fields.md index b2e9170ef..3298ee4df 100755 --- a/doc/md/schema-fields.md +++ b/doc/md/schema-fields.md @@ -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