mirror of https://github.com/go-gorm/gorm.git
Update README
This commit is contained in:
parent
83ee11e184
commit
d22cd2e9d7
15
README.md
15
README.md
|
@ -374,10 +374,16 @@ user.Age = 100
|
||||||
db.Save(&user)
|
db.Save(&user)
|
||||||
//// UPDATE users SET name='jinzhu 2', age=100, updated_at = '2013-11-17 21:34:10' WHERE id=111;
|
//// UPDATE users SET name='jinzhu 2', age=100, updated_at = '2013-11-17 21:34:10' WHERE id=111;
|
||||||
|
|
||||||
|
db.Where("active = ?", true).Save(&user)
|
||||||
|
//// UPDATE users SET name='jinzhu 2', age=100, updated_at = '2013-11-17 21:34:10' WHERE id=111 AND active = true;
|
||||||
|
|
||||||
// Update an attribute if it is changed
|
// Update an attribute if it is changed
|
||||||
db.Model(&user).Update("name", "hello")
|
db.Model(&user).Update("name", "hello")
|
||||||
//// UPDATE users SET name='hello', updated_at = '2013-11-17 21:34:10' WHERE id=111;
|
//// UPDATE users SET name='hello', updated_at = '2013-11-17 21:34:10' WHERE id=111;
|
||||||
|
|
||||||
|
db.Model(&user).Where("active = ?", true).Update("name", "hello")
|
||||||
|
//// UPDATE users SET name='hello', updated_at = '2013-11-17 21:34:10' WHERE id=111 AND active = true;
|
||||||
|
|
||||||
db.First(&user, 111).Update("name", "hello")
|
db.First(&user, 111).Update("name", "hello")
|
||||||
//// SELECT * FROM users LIMIT 1;
|
//// SELECT * FROM users LIMIT 1;
|
||||||
//// UPDATE users SET name='hello', updated_at = '2013-11-17 21:34:10' WHERE id=111;
|
//// UPDATE users SET name='hello', updated_at = '2013-11-17 21:34:10' WHERE id=111;
|
||||||
|
@ -1116,12 +1122,13 @@ db.Where("email = ?", "x@example.org").Attrs(User{RegisteredIp: "111.111.111.111
|
||||||
```
|
```
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
* db.RegisterFuncation("Search", func() {})
|
* db.Select("Languages", "Name").Update(&user)
|
||||||
db.Model(&[]User{}).Limit(10).Do("Search", "search func's argument")
|
db.Omit("Languages").Update(&user)
|
||||||
db.Mode(&User{}).Do("EditForm").Get("edit_form_html")
|
* Auto migrate indexes
|
||||||
DefaultTimeZone, R/W Splitting, Validation
|
* db.Model(&product).Update("quantity", db.RawString("quantity - 1"))
|
||||||
* Github Pages
|
* Github Pages
|
||||||
* AlertColumn, DropColumn
|
* AlertColumn, DropColumn
|
||||||
|
* R/W Splitting, Validation
|
||||||
|
|
||||||
# Author
|
# Author
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue