orm update docs
Showing
3 changed files
with
28 additions
and
6 deletions
| ... | @@ -4,9 +4,13 @@ a powerful orm framework | ... | @@ -4,9 +4,13 @@ a powerful orm framework |
| 4 | 4 | ||
| 5 | now, beta, unstable, may be changing some api make your app build failed. | 5 | now, beta, unstable, may be changing some api make your app build failed. |
| 6 | 6 | ||
| 7 | **Driver Support:** | 7 | **Support Database:** |
| 8 | 8 | ||
| 9 | * MySQL: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) | 9 | * MySQL: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) |
| 10 | * PostgreSQL: [github.com/lib/pq](https://github.com/lib/pq) | ||
| 11 | * Sqlite3: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) | ||
| 12 | |||
| 13 | Passed all test, but need more feedback. | ||
| 10 | 14 | ||
| 11 | **Features:** | 15 | **Features:** |
| 12 | 16 | ||
| ... | @@ -139,7 +143,5 @@ more details and examples in docs and test | ... | @@ -139,7 +143,5 @@ more details and examples in docs and test |
| 139 | - some unrealized api | 143 | - some unrealized api |
| 140 | - examples | 144 | - examples |
| 141 | - docs | 145 | - docs |
| 142 | - support sqlite | ||
| 143 | - support postgres | ||
| 144 | 146 | ||
| 145 | ## | 147 | ## | ... | ... |
| ... | @@ -66,6 +66,18 @@ func main() { | ... | @@ -66,6 +66,18 @@ func main() { |
| 66 | 66 | ||
| 67 | ## 数据库的设置 | 67 | ## 数据库的设置 |
| 68 | 68 | ||
| 69 | 目前 orm 支持三种数据库,以下为测试过的 driver | ||
| 70 | |||
| 71 | 将你需要使用的 driver 加入 import 中 | ||
| 72 | |||
| 73 | ```go | ||
| 74 | import ( | ||
| 75 | _ "github.com/go-sql-driver/mysql" | ||
| 76 | _ "github.com/lib/pq" | ||
| 77 | _ "github.com/mattn/go-sqlite3" | ||
| 78 | ) | ||
| 79 | ``` | ||
| 80 | |||
| 69 | #### RegisterDriver | 81 | #### RegisterDriver |
| 70 | 82 | ||
| 71 | 三种数据库类型 | 83 | 三种数据库类型 | ... | ... |
| 1 | ## 使用SQL语句进行查询 | 1 | ## 使用SQL语句进行查询 |
| 2 | 2 | ||
| 3 | 使用 Raw SQL 查询,无需使用 ORM 表定义 | 3 | * 使用 Raw SQL 查询,无需使用 ORM 表定义 |
| 4 | * 多数据库,都可直接使用占位符号 `?`,自动转换 | ||
| 5 | * 查询时的参数,支持使用 Model Struct 和 Slice, Array | ||
| 6 | |||
| 7 | ```go | ||
| 8 | ids := []int{1, 2, 3} | ||
| 9 | p.Raw("SELECT name FROM user WHERE id IN (?, ?, ?)", ids) | ||
| 10 | ``` | ||
| 4 | 11 | ||
| 5 | 创建一个 **RawSeter** | 12 | 创建一个 **RawSeter** |
| 6 | 13 | ||
| ... | @@ -44,8 +51,9 @@ TODO | ... | @@ -44,8 +51,9 @@ TODO |
| 44 | 用于单条 sql 语句,重复利用,替换参数然后执行。 | 51 | 用于单条 sql 语句,重复利用,替换参数然后执行。 |
| 45 | 52 | ||
| 46 | ```go | 53 | ```go |
| 47 | num, err := r.SetArgs("set name", "name1").Exec() | 54 | num, err := r.SetArgs("arg1", "arg2").Exec() |
| 48 | num, err := r.SetArgs("set name", "name2").Exec() | 55 | num, err := r.SetArgs("arg1", "arg2").Exec() |
| 56 | ... | ||
| 49 | ``` | 57 | ``` |
| 50 | #### Values / ValuesList / ValuesFlat | 58 | #### Values / ValuesList / ValuesFlat |
| 51 | 59 | ... | ... |
-
Please register or sign in to post a comment