mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-10-25 10:59:13 +08:00
fix(models): use client/orm instead of adapter/orm
- using new orm api, change some related logics
- newer orm api has the concept of TxOrmer, for purpose of transaction
handling. A transaction ormer in v2 is a stateful object, it should be
dropped after using. A Ormer object is stateless and thread(routine)
safe, and should not be used for transaction handling. More details
count be found at official doc:
https://beego.me/docs/mvc/model/orm.md, and pr note: https://github.com/mindoc-org/mindoc/pull/662#issuecomment-807040262
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/adapter/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/mindoc-org/mindoc/conf"
|
||||
"github.com/mindoc-org/mindoc/utils"
|
||||
@@ -112,8 +112,9 @@ func (item *Itemsets) Delete(itemId int) (err error) {
|
||||
if !item.Exist(itemId) {
|
||||
return errors.New("项目空间不存在")
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
if err := o.Begin(); err != nil {
|
||||
ormer := orm.NewOrm()
|
||||
o, err := ormer.Begin()
|
||||
if err != nil {
|
||||
logs.Error("开启事物失败 ->", err)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user