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

modify: row id generation logic change

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