From 09063332916cddefdaca391376c09e8f407845c7 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 28 Oct 2013 11:24:51 +0800 Subject: [PATCH] Document error handling in README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index c774bfd8..ac843627 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,13 @@ db.CreateTable(&User{}) // Run Raw SQL db.Exec("drop table users;") + +// Error Handling +query := db.Where("name = ?", "jinzhu").First(&user) +query := db.First(&user).Limit(10).Find(&users) +//// query.Error -> the last error happened +//// query.Errors -> all errors happened +//// If an error happened, gorm will stop do insert, update, delete operations ``` ## Advanced Usage With Query Chain