1234567891011121314151617181920 |
- package ldap
- import (
- "errors"
- "github.com/astaxie/beego/orm"
- )
- func InsertOrUpdate(o orm.Ormer, md interface{}, colConflitAndArgs ...string) (int64, error) {
- if o == nil {
- o = orm.NewOrm()
- }
- err := o.Read(md, colConflitAndArgs...)
- if err != nil && errors.Is(err, orm.ErrNoRows) {
- return o.Insert(md)
- } else if err != nil {
- return 0, err
- }
- return o.Update(md)
- }
|