97 lines
3.3 KiB
Markdown
97 lines
3.3 KiB
Markdown
# xorm
|
||
|
||
[English](https://github.com/lunny/xorm/blob/master/README.md)
|
||
|
||
xorm是一个简单而强大的Go语言ORM库. 通过它可以使数据库操作非常简便。
|
||
|
||
[](https://drone.io/github.com/lunny/xorm/latest) [](http://gowalker.org/github.com/lunny/xorm)
|
||
|
||
## 特性
|
||
|
||
* 支持Struct和数据库表之间的灵活映射,并支持自动同步
|
||
|
||
* 事务支持
|
||
|
||
* 同时支持原始SQL语句和ORM操作的混合执行
|
||
|
||
* 使用连写来简化调用
|
||
|
||
* 支持使用Id, In, Where, Limit, Join, Having, Table, Sql, Cols等函数和结构体等方式作为条件
|
||
|
||
* 支持级联加载Struct
|
||
|
||
* 支持缓存
|
||
|
||
* 支持根据数据库自动生成xorm的结构体
|
||
|
||
* 支持记录版本(即乐观锁)
|
||
|
||
## 驱动支持
|
||
|
||
目前支持的Go数据库驱动如下:
|
||
|
||
* 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)
|
||
|
||
* Postgres: [github.com/bylevel/pq](https://github.com/bylevel/pq)
|
||
|
||
## 更新日志
|
||
* **v0.2.3** : 改善了文档;提供了乐观锁支持;添加了带时区时间字段支持;Mapper现在分成表名Mapper和字段名Mapper,同时实现了表或字段的自定义前缀后缀;Insert方法的返回值含义从id, err更改为 affected, err,请大家注意;添加了UseBool 和 Distinct函数。
|
||
* **v0.2.2** : Postgres驱动新增了对lib/pq的支持;新增了逐条遍历方法Iterate;新增了SetMaxConns(go1.2+)支持,修复了bug若干;
|
||
* **v0.2.1** : 新增数据库反转工具,当前支持go和c++代码的生成,详见 [Xorm Tool README](https://github.com/lunny/xorm/blob/master/xorm/README.md); 修复了一些bug.
|
||
* **v0.2.0** : 新增 [缓存](https://github.com/lunny/xorm/blob/master/docs/QuickStart.md#120)支持,查询速度提升3-5倍; 新增数据库表和Struct同名的映射方式; 新增Sync同步表结构;
|
||
|
||
[更多更新日志...](https://github.com/lunny/xorm/blob/master/docs/ChangelogCN.md)
|
||
|
||
## 安装
|
||
|
||
推荐使用 [gopm](https://github.com/gpmgo/gopm) 进行安装:
|
||
|
||
gopm get github.com/lunny/xorm
|
||
|
||
或者您也可以使用go工具进行安装:
|
||
|
||
go get github.com/lunny/xorm
|
||
|
||
## 文档
|
||
|
||
* [快速开始](https://github.com/lunny/xorm/blob/master/docs/QuickStart.md)
|
||
|
||
* [GoWalker代码文档](http://gowalker.org/github.com/lunny/xorm)
|
||
|
||
* [Godoc代码文档](http://godoc.org/github.com/lunny/xorm)
|
||
|
||
|
||
## 案例
|
||
|
||
* [Gowalker](http://gowalker.org) - [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker)
|
||
|
||
* [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/)
|
||
|
||
## Todo
|
||
|
||
[开发计划](https://trello.com/b/IHsuAnhk/xorm)
|
||
|
||
## 讨论
|
||
|
||
请加入QQ群:280360085 进行讨论。
|
||
|
||
# 贡献者
|
||
|
||
* [Lunny](https://github.com/lunny)
|
||
* [Nashtsai](https://github.com/nashtsai)
|
||
|
||
## LICENSE
|
||
|
||
BSD License
|
||
[http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/)
|