Commit 7bd94106 by Yuchao Shen

修改firstOrCreate返回值

parent e036f9c7
......@@ -14,14 +14,14 @@ func (m *default{{.upperStartCamelObject}}Model) FirstOrCreate(ctx context.Conte
}, {{.keyValues}}){{else}}var resp {{.upperStartCamelObject}}
err := m.conn.WithContext(ctx).First(&resp, where).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
err = m.conn.WithContext(ctx).Create(data).Error
return err
}
return err
}
if errors.Is(err, gorm.ErrRecordNotFound) {
err = m.conn.WithContext(ctx).Create(data).Error
return err
}
return err{{end}}
return nil{{end}}
}
func (m *default{{.upperStartCamelObject}}Model) UpdateOrCreate(ctx context.Context, where interface{}, data *{{.upperStartCamelObject}}) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment