v0.1.3 Find function now supports both slice and map; Add Table function for multi tables and temperory tables support

This commit is contained in:
Lunny Xiao 2013-05-19 14:11:47 +08:00
parent c181aefc4f
commit 2ba2241584
2 changed files with 26 additions and 1 deletions

View File

@ -16,6 +16,7 @@ Drivers for Go's sql package which currently support database/sql includes:
## Changelog ## Changelog
* **v0.1.3** : Find function now supports both slice and map; Add Table function for multi tables and temperory tables support
* **v0.1.2** : Insert function now supports both struct and slice pointer parameters, batch inserting and auto transaction * **v0.1.2** : Insert function now supports both struct and slice pointer parameters, batch inserting and auto transaction
* **v0.1.1** : Add Id, In functions and improved README * **v0.1.1** : Add Id, In functions and improved README
* **v0.1.0** : Inital release. * **v0.1.0** : Inital release.
@ -319,7 +320,18 @@ type Userinfo struct {
Created time.Time Created time.Time
} }
``` ```
3.For customize table name, use Table() function, for example:
```Go
// batch create tables
for i := 0; i < 10; i++ {
engine.Table(fmt.Sprintf("user_%v", i)).CreateTable(&Userinfo{})
}
// insert into table according id
user := Userinfo{Uid: 25, Username:"sslfs"}
engine.Table(fmt.Sprintf("user_%v", user.Uid % 10)).Insert(&user)
```
## Documents ## Documents

View File

@ -16,6 +16,7 @@ xorm是一个Go语言的ORM库. 通过它可以使数据库操作非常简便。
## 更新日志 ## 更新日志
* **v0.1.3** : Find函数现在支持传入Slice或者Map当传入Map时key为id新增Table函数以为多表和临时表进行支持。
* **v0.1.2** : Insert函数支持混合struct和slice指针传入并根据数据库类型自动批量插入同时自动添加事务 * **v0.1.2** : Insert函数支持混合struct和slice指针传入并根据数据库类型自动批量插入同时自动添加事务
* **v0.1.1** : 添加 Id, In 函数,改善 README 文档 * **v0.1.1** : 添加 Id, In 函数,改善 README 文档
* **v0.1.0** : 初始化工程 * **v0.1.0** : 初始化工程
@ -30,7 +31,7 @@ xorm是一个Go语言的ORM库. 通过它可以使数据库操作非常简便。
* 使用连写来简化调用 * 使用连写来简化调用
* 支持使用Id, In, Where, Limit, Join, Having等函数和结构体等方式作为条件 * 支持使用Id, In, Where, Limit, Join, Having, Table等函数和结构体等方式作为条件
## 安装 ## 安装
@ -314,6 +315,18 @@ type Userinfo struct {
Created time.Time Created time.Time
} }
``` ```
3.对于自定义的表名可以用Table函数进行操作比如
```Go
// batch create tables
for i := 0; i < 10; i++ {
engine.Table(fmt.Sprintf("user_%v", i)).CreateTable(&Userinfo{})
}
// insert into table according id
user := Userinfo{Uid: 25, Username:"sslfs"}
engine.Table(fmt.Sprintf("user_%v", user.Uid % 10)).Insert(&user)
```
## 文档 ## 文档