From 08c6a5ad0b26c12fa0aaed058122e964f331489e Mon Sep 17 00:00:00 2001 From: Joe Ferrucci Date: Sun, 22 Jan 2017 09:04:40 -0800 Subject: [PATCH 1/2] Update models.md Incorrect syntax. --- documents/models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documents/models.md b/documents/models.md index 4935e30c..e0ed1f7c 100644 --- a/documents/models.md +++ b/documents/models.md @@ -164,7 +164,7 @@ Save records having `UpdatedAt` field will set it to current time. ```go db.Save(&user) // will set `UpdatedAt` to current time -db.Model(&user).Update("name", "jinzhu") // will set `UpdatedAt` to current time +db.Model(&user).Update("UpdatedAt", time.Now()) // will set `UpdatedAt` to current time ``` ### Use `DeletedAt` to store record's deleted time if field exists From 4b4b6b8a423d661cafb2b6754995cee029f0ba92 Mon Sep 17 00:00:00 2001 From: Joe Ferrucci Date: Sun, 22 Jan 2017 11:35:34 -0800 Subject: [PATCH 2/2] Clarification Clarify when `UpdatedAt` is updated. --- documents/models.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documents/models.md b/documents/models.md index e0ed1f7c..b04cb040 100644 --- a/documents/models.md +++ b/documents/models.md @@ -163,9 +163,9 @@ db.Model(&user).Update("CreatedAt", time.Now()) Save records having `UpdatedAt` field will set it to current time. ```go +// Whenever one or more `user` fields are edited using Save() or Update(), `UpdatedAt` will be set to current time db.Save(&user) // will set `UpdatedAt` to current time -db.Model(&user).Update("UpdatedAt", time.Now()) // will set `UpdatedAt` to current time -``` +db.Model(&user).Update("name", "jinzhu") // will set `UpdatedAt` to current time ### Use `DeletedAt` to store record's deleted time if field exists