Skip to content

Commit

Permalink
doc: update readme (#16)
Browse files Browse the repository at this point in the history
* doc: update README.md

* doc: update README.md

* fix: fix updateById bug

* doc: update README.md

* doc: update README.md
  • Loading branch information
afumu authored Feb 9, 2023
1 parent 0d84687 commit 8222550
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Gorm-plus

Gorm-plus是基于Gorm的增强版,类似Mybatis-plus语法。
## 特性
- [x] 无侵入:只做增强不做改变
Expand Down Expand Up @@ -270,4 +271,42 @@ func init() {
for _, student := range page.Records {
log.Printf("student:%v\n", student)
}
~~~
##### 根据ID更新
~~~go
student := Student{ID: 3, Name: "lisi"}
student.Name = "lisi"
resultDb := gplus.UpdateById[Student](&student)
log.Printf("error:%v\n", resultDb.Error)
log.Printf("RowsAffected:%v\n", resultDb.RowsAffected)
~~~
##### 根据条件更新
~~~go
query, model := gplus.NewQuery[Student]()
query.Eq(&model.Name, "zhangsan").Set(&model.Age, 30)
resultDb := gplus.Update[Student](query)
log.Printf("error:%v\n", resultDb.Error)
log.Printf("RowsAffected:%v\n", resultDb.RowsAffected)
~~~
##### 根据ID删除
~~~go
resultDb := gplus.DeleteById[Student](4)
log.Printf("error:%v\n", resultDb.Error)
log.Printf("RowsAffected:%v\n", resultDb.RowsAffected)
~~~
##### 根据多个ID删除
~~~go
var ids = []int{5, 6}
resultDb := gplus.DeleteByIds[Student](ids)
log.Printf("error:%v\n", resultDb.Error)
log.Printf("RowsAffected:%v\n", resultDb.RowsAffected)
~~~
##### 根据条件删除
~~~go
query, model := gplus.NewQuery[Student]()
query.Eq(&model.Name, "lisi")
resultDb := gplus.Delete(query)
log.Printf("error:%v\n", resultDb.Error)
log.Printf("RowsAffected:%v\n", resultDb.RowsAffected)
=======
~~~

0 comments on commit 8222550

Please sign in to comment.