目的
本项目主要针对平时使用的xorm、beego orm做了简单封装
- 对复杂操作进行包装
- 简化代码复杂度,提高代码重用率
- 增加分页功能,更贴切实际项目使用
beego orm
Insert
Query
Query by page
Delete
Update
Update with map
xorm
gorm
beego orm
Insert
添加记录并返回持久化的记录
Insert(v interface)
Query
根据指定字段进行查询
Read(v interface, cols ...string)
Query By Page
分页查询
// condition eg:map[string]interface{}{"age__gt":1, "name__icontains":"mojo", "sex":1} 查找age大于1 & name包含mojo & sex为1的记录
QueryElement(page *pagination.Pagination, condition map[string]interface{}, table interface{})
Delete
删除指定的记录
// 根据指定cols作为条件进行删除
Delete(v interface, cols ...string)
Update
更新记录
// 更新指定字段
Update(v interface, cols ...string)
Update with map
以map作为对象来更新
// condition 为条件 m为将要更新的值 table为指定表对应的实体类 调用该方法后持久化后的对象将会赋值给table
UpdateWithMap(condition, m map[string]interface{}, table interface{})