Skip to content

Commit

Permalink
Rename SourceBuilder to FromBuilder (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
sim-wangyan committed Nov 6, 2023
1 parent d138f7c commit 78b56a1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ or build condition sql for some orm framework, like [gorm](https://github.com/go
## Example

SELECT * FROM t_cat WHERE id > ? AND (price >= ? OR is_sold = ?)


var Db *sqlx.DB
....

c := Cat{}
builder := sqlxb.Of(&c).Gt("id", 10000).And(func(sub *CondBuilder) {
sub.Gte("price", catRo.Price).OR().Eq("is_sold", catRo.IsSold))
})

vs, dataSql, countSql, _ := builder.Build().Sql()
catList := []Cat{}
err = sqlx.DB.Select(&catList, dataSql, vs...)
err = Db.Select(&catList, dataSql, vs...)


## Contributing
Expand Down

0 comments on commit 78b56a1

Please sign in to comment.