2013-05-16 06:12:27 +00:00
|
|
|
|
# xorm
|
2014-01-07 09:21:02 +00:00
|
|
|
|
|
|
|
|
|
[English](https://github.com/lunny/xorm/blob/master/README.md)
|
|
|
|
|
|
2013-07-03 03:49:29 +00:00
|
|
|
|
xorm是一个简单而强大的Go语言ORM库. 通过它可以使数据库操作非常简便。
|
2013-05-08 13:42:22 +00:00
|
|
|
|
|
2013-10-07 00:56:16 +00:00
|
|
|
|
[](https://drone.io/github.com/lunny/xorm/latest) [](http://gowalker.org/github.com/lunny/xorm)
|
2013-06-08 04:47:28 +00:00
|
|
|
|
|
2013-11-26 03:27:29 +00:00
|
|
|
|
## 特性
|
2013-09-24 17:31:25 +00:00
|
|
|
|
|
2013-11-26 03:27:29 +00:00
|
|
|
|
* 支持Struct和数据库表之间的灵活映射,并支持自动同步
|
|
|
|
|
|
|
|
|
|
* 事务支持
|
|
|
|
|
|
|
|
|
|
* 同时支持原始SQL语句和ORM操作的混合执行
|
|
|
|
|
|
|
|
|
|
* 使用连写来简化调用
|
|
|
|
|
|
|
|
|
|
* 支持使用Id, In, Where, Limit, Join, Having, Table, Sql, Cols等函数和结构体等方式作为条件
|
|
|
|
|
|
|
|
|
|
* 支持级联加载Struct
|
|
|
|
|
|
|
|
|
|
* 支持缓存
|
|
|
|
|
|
|
|
|
|
* 支持根据数据库自动生成xorm的结构体
|
2013-09-11 08:30:17 +00:00
|
|
|
|
|
2013-11-29 03:50:28 +00:00
|
|
|
|
* 支持记录版本(即乐观锁)
|
|
|
|
|
|
2013-05-16 06:12:27 +00:00
|
|
|
|
## 驱动支持
|
2014-01-07 09:21:02 +00:00
|
|
|
|
|
|
|
|
|
目前支持的Go数据库驱动和对应的数据库如下:
|
|
|
|
|
|
|
|
|
|
* Mysql: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql)
|
|
|
|
|
|
2013-08-08 05:24:38 +00:00
|
|
|
|
* MyMysql: [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql/godrv)
|
|
|
|
|
|
2013-05-11 10:38:43 +00:00
|
|
|
|
* SQLite: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)
|
|
|
|
|
|
2013-11-06 07:43:30 +00:00
|
|
|
|
* Postgres: [github.com/lib/pq](https://github.com/lib/pq)
|
|
|
|
|
|
2013-12-31 06:33:02 +00:00
|
|
|
|
* MsSql: [github.com/lunny/godbc](https://github.com/lunny/godbc)
|
2013-08-08 05:24:38 +00:00
|
|
|
|
|
2013-05-11 10:38:43 +00:00
|
|
|
|
## 更新日志
|
2014-01-02 09:48:57 +00:00
|
|
|
|
|
2014-01-07 09:21:02 +00:00
|
|
|
|
* **v0.3.1**
|
2014-01-02 09:48:57 +00:00
|
|
|
|
|
|
|
|
|
新特性:
|
|
|
|
|
* 支持 MSSQL DB 通过 ODBC 驱动 ([github.com/lunny/godbc](https://github.com/lunny/godbc));
|
|
|
|
|
* 通过多个pk标记支持联合主键;
|
|
|
|
|
* 新增 Rows() API 用来遍历查询结果,该函数提供了类似sql.Rows的相似用法,可作为 Iterate() API 的可选替代;
|
|
|
|
|
* ORM 结构体现在允许内建类型的指针作为成员,使得数据库为null成为可能;
|
|
|
|
|
* Before 和 After 支持
|
|
|
|
|
|
|
|
|
|
改进:
|
|
|
|
|
* 允许 int/int32/int64/uint/uint32/uint64/string 作为主键类型
|
2014-01-07 09:21:02 +00:00
|
|
|
|
* 查询函数 Get()/Find()/Iterate() 在性能上的改进
|
2014-01-02 09:48:57 +00:00
|
|
|
|
|
2013-10-15 02:40:21 +00:00
|
|
|
|
|
2013-11-26 03:27:29 +00:00
|
|
|
|
[更多更新日志...](https://github.com/lunny/xorm/blob/master/docs/ChangelogCN.md)
|
2014-01-07 09:21:02 +00:00
|
|
|
|
|
2013-05-08 13:42:22 +00:00
|
|
|
|
## 安装
|
|
|
|
|
|
2013-12-01 03:08:17 +00:00
|
|
|
|
推荐使用 [gopm](https://github.com/gpmgo/gopm) 进行安装:
|
|
|
|
|
|
|
|
|
|
gopm get github.com/lunny/xorm
|
|
|
|
|
|
|
|
|
|
或者您也可以使用go工具进行安装:
|
|
|
|
|
|
2014-01-07 09:21:02 +00:00
|
|
|
|
go get github.com/lunny/xorm
|
|
|
|
|
|
2013-09-24 17:31:25 +00:00
|
|
|
|
## 文档
|
2014-01-07 09:21:02 +00:00
|
|
|
|
|
2013-09-30 00:50:56 +00:00
|
|
|
|
* [快速开始](https://github.com/lunny/xorm/blob/master/docs/QuickStart.md)
|
2013-05-11 10:38:43 +00:00
|
|
|
|
|
2013-09-24 17:31:25 +00:00
|
|
|
|
* [GoWalker代码文档](http://gowalker.org/github.com/lunny/xorm)
|
|
|
|
|
|
2013-11-26 03:27:29 +00:00
|
|
|
|
* [Godoc代码文档](http://godoc.org/github.com/lunny/xorm)
|
|
|
|
|
|
|
|
|
|
|
2013-09-24 17:31:25 +00:00
|
|
|
|
## 案例
|
2013-05-16 06:12:27 +00:00
|
|
|
|
|
2013-11-15 03:04:48 +00:00
|
|
|
|
* [Gowalker](http://gowalker.org) - [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker)
|
|
|
|
|
|
2014-02-12 07:10:37 +00:00
|
|
|
|
* [Gobuild.io](http://gobuild.io) - [github.com/shxsun/gobuild](http://github.com/shxsun/gobuild)
|
|
|
|
|
|
2013-10-15 02:40:21 +00:00
|
|
|
|
* [Sudo China](http://sudochina.com) - [github.com/insionng/toropress](http://github.com/insionng/toropress)
|
|
|
|
|
|
2013-09-29 08:43:10 +00:00
|
|
|
|
* [Godaily](http://godaily.org) - [github.com/govc/godaily](http://github.com/govc/godaily)
|
|
|
|
|
|
2014-01-07 09:21:02 +00:00
|
|
|
|
* [Very Hour](http://veryhour.com/)
|
|
|
|
|
|
2014-01-21 15:23:53 +00:00
|
|
|
|
* [GoCMS](https://github.com/zzdboy/GoCMS)
|
|
|
|
|
|
|
|
|
|
|
2013-12-25 10:11:28 +00:00
|
|
|
|
## Todo
|
|
|
|
|
|
|
|
|
|
[开发计划](https://trello.com/b/IHsuAnhk/xorm)
|
2013-09-29 08:43:10 +00:00
|
|
|
|
|
2013-11-26 03:27:29 +00:00
|
|
|
|
## 讨论
|
2013-05-08 13:42:22 +00:00
|
|
|
|
|
2013-11-26 03:27:29 +00:00
|
|
|
|
请加入QQ群:280360085 进行讨论。
|
2013-05-08 13:42:22 +00:00
|
|
|
|
|
2013-12-08 13:40:58 +00:00
|
|
|
|
# 贡献者
|
|
|
|
|
|
2013-12-31 06:33:02 +00:00
|
|
|
|
如果您也想为Xorm贡献您的力量,请查看 [CONTRIBUTING](https://github.com/lunny/xorm/blob/master/CONTRIBUTING.md)
|
|
|
|
|
|
2013-12-08 13:40:58 +00:00
|
|
|
|
* [Lunny](https://github.com/lunny)
|
|
|
|
|
* [Nashtsai](https://github.com/nashtsai)
|
2014-01-07 09:21:02 +00:00
|
|
|
|
|
|
|
|
|
## LICENSE
|
|
|
|
|
|
|
|
|
|
BSD License
|
|
|
|
|
[http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/)
|