Document error handling in README

This commit is contained in:
Jinzhu 2013-10-28 11:24:51 +08:00
parent c412729570
commit 0906333291
1 changed files with 7 additions and 0 deletions

View File

@ -151,6 +151,13 @@ db.CreateTable(&User{})
// Run Raw SQL // Run Raw SQL
db.Exec("drop table users;") 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 ## Advanced Usage With Query Chain