diff --git a/orm/README.md b/orm/README.md index 1976b911..b9da3ba1 100644 --- a/orm/README.md +++ b/orm/README.md @@ -4,9 +4,13 @@ a powerful orm framework now, beta, unstable, may be changing some api make your app build failed. -**Driver Support:** +**Support Database:** * MySQL: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) +* PostgreSQL: [github.com/lib/pq](https://github.com/lib/pq) +* Sqlite3: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) + +Passed all test, but need more feedback. **Features:** @@ -139,7 +143,5 @@ more details and examples in docs and test - some unrealized api - examples - docs -- support sqlite -- support postgres ## diff --git a/orm/docs/zh/Orm.md b/orm/docs/zh/Orm.md index edd44f17..a43f0b81 100644 --- a/orm/docs/zh/Orm.md +++ b/orm/docs/zh/Orm.md @@ -66,6 +66,18 @@ func main() { ## 数据库的设置 +目前 orm 支持三种数据库,以下为测试过的 driver + +将你需要使用的 driver 加入 import 中 + +```go +import ( + _ "github.com/go-sql-driver/mysql" + _ "github.com/lib/pq" + _ "github.com/mattn/go-sqlite3" +) +``` + #### RegisterDriver 三种数据库类型 diff --git a/orm/docs/zh/Raw.md b/orm/docs/zh/Raw.md index c01e5467..0d571edf 100644 --- a/orm/docs/zh/Raw.md +++ b/orm/docs/zh/Raw.md @@ -1,6 +1,13 @@ ## 使用SQL语句进行查询 -使用 Raw SQL 查询,无需使用 ORM 表定义 +* 使用 Raw SQL 查询,无需使用 ORM 表定义 +* 多数据库,都可直接使用占位符号 `?`,自动转换 +* 查询时的参数,支持使用 Model Struct 和 Slice, Array + +```go +ids := []int{1, 2, 3} +p.Raw("SELECT name FROM user WHERE id IN (?, ?, ?)", ids) +``` 创建一个 **RawSeter** @@ -44,8 +51,9 @@ TODO 用于单条 sql 语句,重复利用,替换参数然后执行。 ```go -num, err := r.SetArgs("set name", "name1").Exec() -num, err := r.SetArgs("set name", "name2").Exec() +num, err := r.SetArgs("arg1", "arg2").Exec() +num, err := r.SetArgs("arg1", "arg2").Exec() +... ``` #### Values / ValuesList / ValuesFlat