diff --git a/docs/LICENSE b/docs/LICENSE new file mode 100644 index 00000000..9ac0c261 --- /dev/null +++ b/docs/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2013 - 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..db6d7fe2 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,19 @@ +# What is this? + +An open source project for Xorm documentation. + +## How to contribute? + +Fork, update and submit a pull request. No matter how big or small, your changes are welcome! + +## How does it work? + +Xorm Web server checks for updates to this folder and updates the main documentation automatically. + +## Note + +Xorm documentation is written using standard markdown syntax. Please submit your changes using the same syntax. + +## License + +This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text. \ No newline at end of file diff --git a/docs/en-US/about.md b/docs/en-US/about.md new file mode 100644 index 00000000..275314f9 --- /dev/null +++ b/docs/en-US/about.md @@ -0,0 +1,27 @@ +# About + +This manual documents aspects of Xorm. + +### New to Xorm? + +Read about the [Quick Start](docs/intro/quick_start.md). + +### Can't find what you're looking for? + +Search our [mailing list (xorm@googlegroups.com)](https://groups.google.com/forum/#!forum/xorm). + +### Need help? + +Send an email to the [xorm@googlegroups.com](mailto:xorm@googlegroups.com). + +### Find a bug? + +Open an [issue on github](https://github.com/go-xorm/xorm/issues). + +### Want to be a contributor? + +Fork the [documentation project](https://github.com/go-xorm/xorm/tree/master/docs), edit and pull request. + +### Source code of this website? + +Please visit [Xorm Web](https://github.com/go-xorm/website). \ No newline at end of file diff --git a/docs/en-US/donate.md b/docs/en-US/donate.md new file mode 100644 index 00000000..b6a278ef --- /dev/null +++ b/docs/en-US/donate.md @@ -0,0 +1,38 @@ +# Donation + +
+ +
+ + +### Your donation will be used as: + +- Supports the development of Beego +- Supports maintaining the communities +- Upgrade to better server +- Award the outstanding contributors +- Holds community activities and lectures + +### Donation Lists (descending by donating time) + +| Donated at | Donator | Amount | Contact | Comments | +| ---------------- |:---------:| --------:|:---------:| ----------------------- | +|2014-7-8 | Steven Wang | 100¥ | easykooc@gmail.com | xorm目前做得最好的orm for golang | +|2014-7-8 | 韩天峰 | 20¥ | apolov@vip.qq.com | xorm是Golang里最好用的DB库 | +|2014-7-8 | sunhongjian | 100¥ | shongjiang@gmail.com |支持开源,支持美好的事物! | +|2014-7-8 | Jimmy Kuu | 200¥ | jimmy.kuu@gmail.com |再接再厉,持续发展 | +|2014-7-8 | 张仲东 | 100¥ | GoCMS作者 |支持XORM!! | +|2014-7-8 | wangwei | 100¥ | iamjcww@gmail.com |鄙视楼下 | +|2014-7-8 | Jazz | 2¥ | 1002376560@qq.com |这个沙发必须抢 | \ No newline at end of file diff --git a/docs/AutoMap.md b/docs/en-US/intro/AutoMap.md similarity index 100% rename from docs/AutoMap.md rename to docs/en-US/intro/AutoMap.md diff --git a/docs/COLUMNTYPE.md b/docs/en-US/intro/COLUMNTYPE.md similarity index 100% rename from docs/COLUMNTYPE.md rename to docs/en-US/intro/COLUMNTYPE.md diff --git a/docs/en-US/intro/README.md b/docs/en-US/intro/README.md new file mode 100644 index 00000000..bcd0bc36 --- /dev/null +++ b/docs/en-US/intro/README.md @@ -0,0 +1,143 @@ +--- +root: true +name: Introduction +sort: 0 +--- + +[中文](https://github.com/go-xorm/xorm/blob/master/README_CN.md) + +Xorm is a simple and powerful ORM for Go. + +[](https://drone.io/github.com/go-xorm/tests/latest) [](http://gowalker.org/github.com/go-xorm/xorm) [](https://bitdeli.com/free "Bitdeli Badge") + +# Features + +* Struct <-> Table Mapping Support + +* Chainable APIs + +* Transaction Support + +* Both ORM and raw SQL operation Support + +* Sync database schema Support + +* Query Cache speed up + +* Database Reverse support, See [Xorm Tool README](https://github.com/go-xorm/cmd/blob/master/README.md) + +* Simple cascade loading support + +* Optimistic Locking support + + +# Drivers Support + +Drivers for Go's sql package which currently support database/sql includes: + +* Mysql: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) + +* MyMysql: [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql/godrv) + +* SQLite: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) + +* Postgres: [github.com/lib/pq](https://github.com/lib/pq) + +* MsSql: [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) + +* MsSql: [github.com/lunny/godbc](https://github.com/lunny/godbc) + + + +# Changelog + +* **v0.4.0 RC1** + Changes: + * moved xorm cmd to [github.com/go-xorm/cmd](github.com/go-xorm/cmd) + * refactored general DB operation a core lib at [github.com/go-xorm/core](https://github.com/go-xorm/core) + * moved tests to github.com/go-xorm/tests [github.com/go-xorm/tests](github.com/go-xorm/tests) + + Improvements: + * Prepared statement cache + * Add Incr API + * Specify Timezone Location + +* **v0.3.2** + Improvements: + * Add AllCols & MustCols function + * Add TableName for custom table name + + Bug Fixes: + * #46 + * #51 + * #53 + * #89 + * #86 + * #92 + +* **v0.3.1** + + Features: + * Support MSSQL DB via ODBC driver ([github.com/lunny/godbc](https://github.com/lunny/godbc)); + * Composite Key, using multiple pk xorm tag + * Added Row() API as alternative to Iterate() API for traversing result set, provide similar usages to sql.Rows type + * ORM struct allowed declaration of pointer builtin type as members to allow null DB fields + * Before and After Event processors + + Improvements: + * Allowed int/int32/int64/uint/uint32/uint64/string as Primary Key type + * Performance improvement for Get()/Find()/Iterate() + +[More changelogs ...](https://github.com/go-xorm/xorm/blob/master/docs/Changelog.md) + +# Installation + +If you have [gopm](https://github.com/gpmgo/gopm) installed, + + gopm get github.com/go-xorm/xorm + +Or + + go get github.com/go-xorm/xorm + +# Documents + +* [GoDoc](http://godoc.org/github.com/go-xorm/xorm) + +* [GoWalker](http://gowalker.org/github.com/go-xorm/xorm) + +* [Quick Start](https://github.com/go-xorm/xorm/blob/master/docs/QuickStart.md) + +# Cases + +* [Gorevel](http://http://gorevel.cn/) - [github.com/goofcc/gorevel](http://github.com/goofcc/gorevel) + +* [Gogs](http://try.gogits.org) - [github.com/gogits/gogs](http://github.com/gogits/gogs) + +* [Gowalker](http://gowalker.org) - [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker) + +* [Gobuild.io](http://gobuild.io) - [github.com/shxsun/gobuild](http://github.com/shxsun/gobuild) + +* [Sudo China](http://sudochina.com) - [github.com/insionng/toropress](http://github.com/insionng/toropress) + +* [Godaily](http://godaily.org) - [github.com/govc/godaily](http://github.com/govc/godaily) + +* [Very Hour](http://veryhour.com/) + +* [GoCMS - github.com/zzboy/GoCMS](https://github.com/zzdboy/GoCMS) + +* [GoBBS - gobbs.domolo.com](http://gobbs.domolo.com/) + + +# Discuss + +Please visit [Xorm on Google Groups](https://groups.google.com/forum/#!forum/xorm) + +# Contributing + +If you want to pull request, please see [CONTRIBUTING](https://github.com/go-xorm/xorm/blob/master/CONTRIBUTING.md) + +# LICENSE + + BSD License + [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) diff --git a/docs/en-US/intro/cases.md b/docs/en-US/intro/cases.md new file mode 100644 index 00000000..5d27f3c5 --- /dev/null +++ b/docs/en-US/intro/cases.md @@ -0,0 +1,12 @@ +--- +name: Cases +sort: 90 +--- + +* [Gowalker](http://gowalker.org),source [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker) + +* [GoDaily](http://godaily.org),source [github.com/govc/godaily](http://github.com/govc/godaily) + +* [Sudochina](http://sudochina.com) source [github.com/insionng/toropress](http://github.com/insionng/toropress) + +* [VeryHour](http://veryhour.com) \ No newline at end of file diff --git a/docs/Changelog.md b/docs/en-US/intro/changelog.md similarity index 98% rename from docs/Changelog.md rename to docs/en-US/intro/changelog.md index fb9b1ec3..3aa3c16b 100644 --- a/docs/Changelog.md +++ b/docs/en-US/intro/changelog.md @@ -1,3 +1,8 @@ +--- +name: Changelog +sort: 1 +--- + ## Changelog * **v0.4.0 RC1** @@ -52,3 +57,4 @@ * **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** : Initial release. + diff --git a/docs/en-US/intro/faq.md b/docs/en-US/intro/faq.md new file mode 100644 index 00000000..fee08ddf --- /dev/null +++ b/docs/en-US/intro/faq.md @@ -0,0 +1,51 @@ +--- +name: FAQ +sort: 100 +--- + +* How the xorm tag use both with json? + + Use space. + +```Go +type User struct { + Name string `json:"name" xorm:"name"` +} +``` + +* Does xorm support composite primary key? + + Yes. You can use pk tag. All fields have tag will as one primary key by fields order on struct. When use, you can use xorm.PK{1, 2}. For example: `Id(xorm.PK{1, 2})`. + +* How to use join? + + We can use Join() and extends tag to do join operation. For example: + + type Userinfo struct { + Id int64 + Name string + DetailId int64 + } + + type Userdetail struct { + Id int64 + Gender int + } + + type User struct { + Userinfo `xorm:"extends"` + Userdetail `xorm:"extends"` + } + + var users = make([]User, 0) + err := engine.Table(&Userinfo{}).Join("LEFT", "userdetail", "userinfo.detail_id = userdetail.id").Find(&users) + + //assert(User.Userinfo.Id != 0 && User.Userdetail.Id != 0) + +Please notice that Userinfo field on User should be before Userdetail because of the order on join SQL stsatement. If the order is wrong, the same name field may be set a wrong value. + +Of course, If join statment is very long, you could directly use Sql(): + + err := engine.Sql("select * from userinfo, userdetail where userinfo.detail_id = userdetail.id").Find(&users) + + //assert(User.Userinfo.Id != 0 && User.Userdetail.Id != 0) \ No newline at end of file diff --git a/docs/QuickStart.md b/docs/en-US/intro/quick_start.md similarity index 89% rename from docs/QuickStart.md rename to docs/en-US/intro/quick_start.md index a363fdf2..b8ffe69c 100644 --- a/docs/QuickStart.md +++ b/docs/en-US/intro/quick_start.md @@ -1,3 +1,8 @@ +--- +name: Quick Start +sort: 2 +--- + Quick Start ===== @@ -26,12 +31,7 @@ Quick Start * [9.Execute SQL query](#100) * [10.Transaction](#110) * [11.Cache](#120) -* [12.Xorm Tool](#130) - * [12.1.Reverse command](#131) * [13.Examples](#140) -* [14.Cases](#150) -* [15.FAQ](#160) -* [16.Discuss](#170) ## 1.Create ORM Engine @@ -54,7 +54,7 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/go-xorm/xorm" ) -engine, err := xorm.NewEngine("sqlite3", "./test.db") +engine, err = xorm.NewEngine("sqlite3", "./test.db") defer engine.Close() ``` @@ -346,6 +346,7 @@ Notice: If you want to use transaction on inserting, you should use session.Begi ### 5.1. Chainable APIs for Queries, Execusions and Aggregations Queries and Aggregations is basically formed by using `Get`, `Find`, `Count` methods, with conjunction of following chainable APIs to form conditions, grouping and ordering: +查询和统计主要使用`Get`, `Find`, `Count`三个方法。在进行查询时可以使用多个方法来形成查询条件,条件函数如下: * Id([]interface{}) Primary Key lookup @@ -537,12 +538,13 @@ affected, err := engine.Table(new(User)).Id(id).Update(map[string]interface{}{"a ### 6.1.Optimistic Lock To enable object optimistic lock, add 'version' tag value: +```Go type User struct { Id int64 Name string Version int `xorm:"version"` } - +``` The version starts with 1 when inserted to DB. For updating make sure originated version value is used for optimistic lock check. ```Go @@ -666,75 +668,8 @@ Cache implement theory below:  - -## 12.xorm tool -xorm commandl line tool - -### 12.1.Reverse command -Please visit [xorm tool](https://github.com/go-xorm/cmd) - ## 13.Examples Please visit [https://github.com/go-xorm/xorm/tree/master/examples](https://github.com/go-xorm/xorm/tree/master/examples) - -## 14.Cases - -* [Gowalker](http://gowalker.org),source [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker) - -* [GoDaily](http://godaily.org),source [github.com/govc/godaily](http://github.com/govc/godaily) - -* [Sudochina](http://sudochina.com) source [github.com/insionng/toropress](http://github.com/insionng/toropress) - -* [VeryHour](http://veryhour.com) - - -## 15.FAQ - -* How the xorm tag use both with json? - - Use space. - -```Go -type User struct { - Name string `json:"name" xorm:"name"` -} -``` - -* Does xorm support composite primary key? - - Yes. You can use pk tag. All fields have tag will as one primary key by fields order on struct. When use, you can use xorm.PK{1, 2}. For example: `Id(xorm.PK{1, 2})`. - -* How to use join? - - We can use Join() and extends tag to do join operation. For example: - - type Userinfo struct { - Id int64 - Name string - DetailId int64 - } - - type Userdetail struct { - Id int64 - Gender int - } - - type User struct { - Userinfo `xorm:"extends"` - Userdetail `xorm:"extends"` - } - - var users = make([]User, 0) - err := engine.Table(&Userinfo{}).Join("LEFT", "userdetail", "userinfo.detail_id = userdetail.id").Find(&users) - - //assert(User.Userinfo.Id != 0 && User.Userdetail.Id != 0) - -Please notice that Userinfo field on User should be before Userdetail because of the order on join SQL stsatement. If the order is wrong, the same name field may be set a wrong value. - -Of course, If join statment is very long, you could directly use Sql(): - - err := engine.Sql("select * from userinfo, userdetail where userinfo.detail_id = userdetail.id").Find(&users) - - //assert(User.Userinfo.Id != 0 && User.Userdetail.Id != 0) diff --git a/docs/en-US/intro/tools.md b/docs/en-US/intro/tools.md new file mode 100644 index 00000000..218360f5 --- /dev/null +++ b/docs/en-US/intro/tools.md @@ -0,0 +1,109 @@ +--- +root: false +name: Xorm Tools +sort: 3 +--- + +# xorm tools + +xorm tools is a set of tools for database operation. + +## Binary Install + +If you have [got](https://github.com/gobuild/got) installed, you can install by got + +``` +got go-xorm/cmd/xorm +``` + +or you can download from [gobuild](http://gobuild.io/download/github.com/lunny/got). + +## Source Install + +`go get github.com/go-xorm/cmd/xorm` + +and you should install the depends below: + +* github.com/go-xorm/xorm + +* Mysql: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) + +* MyMysql: [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql/godrv) + +* Postgres: [github.com/lib/pq](https://github.com/lib/pq) + +* SQLite: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) + +** For sqlite support, you need build via `go build -tags sqlite3` because of this driver ask cgo. + +## Commands + +All the commands below. + +* **reverse** reverse a db to codes +* **shell** a general shell to operate all kinds of database +* **dump** dump database all table struct's and data to standard output +* **source** execute a sql from std in +* **driver** list all supported drivers + +## Reverse + +Reverse command is a tool to convert your database struct to all kinds languages of structs or classes. After you installed the tool, you can type + +`xorm help reverse` + +to get help + +example: + +sqlite: +`xorm reverse sqite3 test.db templates/goxorm` + +mysql: +`xorm reverse mysql root:@/xorm_test?charset=utf8 templates/goxorm` + +mymysql: +`xorm reverse mymysql xorm_test2/root/ templates/goxorm` + +postgres: +`xorm reverse postgres "dbname=xorm_test sslmode=disable" templates/goxorm` + +will generated go files in `./model` directory + +### Template and Config + +Now, xorm tool supports go and c++ two languages and have go, goxorm, c++ three of default templates. In template directory, we can put a config file to control how to generating. + +```` +lang=go +genJson=1 +``` + +lang must be go or c++ now. +genJson can be 1 or 0, if 1 then the struct will have json tag. + +## Shell + +Shell command provides a tool to operate database. For example, you can create table, alter table, insert data, delete data and etc. + +`xorm shell sqlite3 test.db` will connect to the sqlite3 database and you can type `help` to list all the shell commands. + +## Dump + +Dump command provides a tool to dump all database structs and data as SQL to your standard output. + +`xorm dump sqlite3 test.db` could dump sqlite3 database test.db to standard output. If you want to save to file, just +type `xorm dump sqlite3 test.db > test.sql`. + +## Source + +`xorm source sqlite3 test.db < test.sql` will execute sql file on the test.db. + +## Driver + +List all supported drivers since default build will not include sqlite3. + +## LICENSE + + BSD License + [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) diff --git a/docs/en-US/team.md b/docs/en-US/team.md new file mode 100644 index 00000000..0b6ca359 --- /dev/null +++ b/docs/en-US/team.md @@ -0,0 +1,22 @@ +# Developer Team + +### Unknown + +- Team role: Project manager, back-end developer. +- Social network: [Sina Weibo](http://weibo.com/Obahua) [GitHub](https://github.com/Unknwon) [Twitter](https://twitter.com/joe2010xtmf) [Google+](https://plus.google.com/u/0/+JiahuaChen) + +### Lunny + +- Team role: Back-end Git and database developer. +- Social network: [Sina Weibo](http://weibo.com/xiaolunwen) [GitHub](https://github.com/lunny) [Twitter](https://twitter.com/lunny) + +### Fuxiaohei + +- Team role: Front-end developer. +- Social network: [Sina Weibo](http://weibo.com/fuxiaohei) [GitHub](https://github.com/fuxiaohei) + + +### Slene + +- Team role: Front and back-end developer. +- Social network: [Sina Weibo](http://weibo.com/slene) [GitHub](https://github.com/slene) [Twitter](https://twitter.com/slene) \ No newline at end of file diff --git a/docs/cache_design.graffle b/docs/images/cache_design.graffle similarity index 100% rename from docs/cache_design.graffle rename to docs/images/cache_design.graffle diff --git a/docs/cache_design.png b/docs/images/cache_design.png similarity index 100% rename from docs/cache_design.png rename to docs/images/cache_design.png diff --git a/docs/zh-CN/about.md b/docs/zh-CN/about.md new file mode 100644 index 00000000..6b0cf9f8 --- /dev/null +++ b/docs/zh-CN/about.md @@ -0,0 +1,27 @@ +# 关于 + +本网站文档页面详细描述了 Xorm 的各个方面。 + +### 新手指导 + +如果您是首次了解 Xorm,我们建议您先阅读 [快速入门](docs/intro/quick_start.md)。 + +### 其它资源 + +如果您无法找到相关问题的满意答案,可以在 [邮件列表 (xorm@googlegroups.com)](https://groups.google.com/forum/#!search/xorm) 中搜索。 + +### 寻求帮助 + +如果您遇到无法解决的问题,可以发送邮件到 [xorm@googlegroups.com](mailto:xorm@googlegroups.com) 提问。 + +### 问题提交 + +如果您在使用过程中发现 Xorm 有潜在的问题,请通过 [Xorm](https://github.com/go-xorm/xorm/issues) 上的问题列表提交。 + +### 完善文档 + +您可以通过派生 [文档项目](https://github.com/go-xorm/xorm/tree/master/docs)、编辑,然后提交合并请求。 + +### 网站源码 + +请移步 [Xorm Web](https://github.com/go-xorm/website)。 \ No newline at end of file diff --git a/docs/zh-CN/donate.md b/docs/zh-CN/donate.md new file mode 100644 index 00000000..998ac6cf --- /dev/null +++ b/docs/zh-CN/donate.md @@ -0,0 +1,44 @@ +# 捐赠我们 + ++ +
+ + +### 您的捐赠将被用于: + +- 持续和深入的开发 +- 维护社区的运行稳定 +- 租用更好的带宽 +- 奖励团队的杰出贡献者 +- 社区活动或讲座 + +### 捐赠列表(按照捐赠时间倒序) + +| 捐赠时间 | 捐赠人 | 金额 | 联系方式 | 附言 | +| ---------------- |:---------:| --------:|:---------:| ----------------------- | +|2014-7-8 | Steven Wang | 100¥ | easykooc@gmail.com | xorm目前做得最好的orm for golang | +|2014-7-8 | 韩天峰 | 20¥ | apolov@vip.qq.com | xorm是Golang里最好用的DB库 | +|2014-7-8 | sunhongjian | 100¥ | shongjiang@gmail.com |支持开源,支持美好的事物! | +|2014-7-8 | Jimmy Kuu | 200¥ | jimmy.kuu@gmail.com |再接再厉,持续发展 | +|2014-7-8 | 张仲东 | 100¥ | GoCMS作者 |支持XORM!! | +|2014-7-8 | wangwei | 100¥ | iamjcww@gmail.com |鄙视楼下 | +|2014-7-8 | Jazz | 2¥ | 1002376560@qq.com |这个沙发必须抢 | diff --git a/docs/zh-CN/intro/AutoMap.md b/docs/zh-CN/intro/AutoMap.md new file mode 100644 index 00000000..cae66209 --- /dev/null +++ b/docs/zh-CN/intro/AutoMap.md @@ -0,0 +1,65 @@ +When a struct auto mapping to a database's table, the below table describes how they change to each other: + +go type's kind + | +value method | +xorm type + | +
implemented Conversion | +Conversion.ToDB / Conversion.FromDB | +Text | +
int, int8, int16, int32, uint, uint8, uint16, uint32 | ++ | Int | +
int64, uint64 | BigInt | +|
float32 | Float | +|
float64 | Double | +|
complex64, complex128 | +json.Marshal / json.UnMarshal | +Varchar(64) | +
[]uint8 | Blob | +|
array, slice, map except []uint8 | +json.Marshal / json.UnMarshal | +Text | +
bool | 1 or 0 | Bool | +
string | Varchar(255) | +|
time.Time | DateTime | +|
cascade struct | primary key field value | BigInt | +
struct | json.Marshal / json.UnMarshal | Text | +
+ Others + | ++ | + Text + | +
xorm + | +mysql + | +sqlite3 + | +postgres + | +remark | +
BIT + | +BIT + | +INTEGER + | +BIT + | ++ |
TINYINT + | +TINYINT + | +INTEGER + | +SMALLINT + | ++ |
SMALLINT + | +SMALLINT + | +INTEGER + | +SMALLINT + | ++ |
MEDIUMINT + | +MEDIUMINT + | +INTEGER + | +INTEGER + | ++ |
INT + | +INT + | +INTEGER + | +INTEGER + | ++ |
INTEGER + | +INTEGER + | +INTEGER + | +INTEGER + | ++ |
BIGINT + | +BIGINT + | +INTEGER + | +BIGINT + | ++ |
CHAR + | +CHAR + | +TEXT + | +CHAR + | ++ |
VARCHAR + | +VARCHAR + | +TEXT + | +VARCHAR + | ++ |
TINYTEXT + | +TINYTEXT + | +TEXT + | +TEXT + | ++ |
TEXT + | +TEXT + | +TEXT + | +TEXT + | ++ |
MEDIUMTEXT + | +MEDIUMTEXT + | +TEXT + | +TEXT + | ++ |
LONGTEXT + | +LONGTEXT + | +TEXT + | +TEXT + | ++ |
BINARY + | +BINARY + | +BLOB + | +BYTEA + | ++ |
VARBINARY + | +VARBINARY + | +BLOB + | +BYTEA + | ++ |
DATE + | +DATE + | +NUMERIC + | +DATE + | ++ |
DATETIME + | +DATETIME + | +NUMERIC + | +TIMESTAMP + | ++ |
TIME + | +TIME + | +NUMERIC + | +TIME + | ++ |
TIMESTAMP + | +TIMESTAMP + | +NUMERIC + | +TIMESTAMP + | ++ |
TIMESTAMPZ + | +TEXT + | +TEXT + | +TIMESTAMP with zone + | +timestamp with zone info | +
REAL + | +REAL + | +REAL + | +REAL + | ++ |
FLOAT + | +FLOAT + | +REAL + | +REAL + | ++ |
DOUBLE + | +DOUBLE + | +REAL + | +DOUBLE PRECISION + | ++ |
DECIMAL + | +DECIMAL + | +NUMERIC + | +DECIMAL + | ++ |
NUMERIC + | +NUMERIC + | +NUMERIC + | +NUMERIC + | ++ |
TINYBLOB + | +TINYBLOB + | +BLOB + | +BYTEA + | ++ |
BLOB + | +BLOB + | +BLOB + | +BYTEA + | ++ |
MEDIUMBLOB + | +MEDIUMBLOB + | +BLOB + | +BYTEA + | ++ |
LONGBLOB + | +LONGBLOB + | +BLOB + | +BYTEA + | ++ |
BYTEA + | +BLOB + | +BLOB + | +BYTEA + | ++ |
BOOL + | +TINYINT + | +INTEGER + | +BOOLEAN + | ++ |
SERIAL + | +INT + | +INTEGER + | +SERIAL + | +auto increment | +
BIGSERIAL + | +BIGINT + | +INTEGER + | +BIGSERIAL + | +auto increment | +