Commit e0c87429 authored by Vivek Naik's avatar Vivek Naik
Browse files

use of existing row id

parent be800ea9
Branches
Tags
2 merge requests!134Mep release271219,!133Add: Asset FDB and merged bucket type
Showing with 9 additions and 3 deletions
......@@ -551,12 +551,18 @@ func SaveMediaInFDB(dbName string, indexID string, mediaData []byte, rs *gjson.R
loggermdl.LogError(err)
return recordPath, err
}
rowID := guidmdl.GetGUID()
json, _ = sjson.Set(json, "rowID", rowID)
rowID := ""
// path = path + ".json"
err = index.indexObj.Update(func(tx *buntdb.Tx) error {
// optimization : if data not changed then dont update
_, _, err := tx.Set(path, json, nil)
prevVal, err := tx.Get(path, false)
rowID = gjson.Parse(prevVal).Get("rowID").String()
if rowID == "" {
rowID = guidmdl.GetGUID()
}
json, _ = sjson.Set(json, "rowID", rowID)
_, _, err = tx.Set(path, json, nil)
if err != nil {
loggermdl.LogError(err)
return err
......
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