From 2ba2241584f348d346ea7da7fdd0fea26cc80a3f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 19 May 2013 14:11:47 +0800 Subject: [PATCH] v0.1.3 Find function now supports both slice and map; Add Table function for multi tables and temperory tables support --- README.md | 12 ++++++++++++ README_CN.md | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d066ac96..0a48af25 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Drivers for Go's sql package which currently support database/sql includes: ## 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.1** : Add Id, In functions and improved README * **v0.1.0** : Inital release. @@ -319,7 +320,18 @@ type Userinfo struct { 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 diff --git a/README_CN.md b/README_CN.md index 2e412bea..4ecbe2de 100644 --- a/README_CN.md +++ b/README_CN.md @@ -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.1** : 添加 Id, In 函数,改善 README 文档 * **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 } ``` +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) +``` ## 文档