mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
add id field to update (#159)
This commit is contained in:
@@ -133,9 +133,15 @@ func (e *Db) Update(ctx context.Context, req *db.UpdateRequest, rsp *db.UpdateRe
|
||||
m := req.Record.AsMap()
|
||||
|
||||
// where ID is specified do a single update record update
|
||||
id, ok := m[idKey].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("update failed: missing id")
|
||||
id := req.Id
|
||||
|
||||
// if the id is blank then check the data
|
||||
if len(req.Id) == 0 {
|
||||
var ok bool
|
||||
id, ok = m[idKey].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("update failed: missing id")
|
||||
}
|
||||
}
|
||||
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
|
||||
Reference in New Issue
Block a user