Skip to content

Commit

Permalink
database: Add FindKeyValue function wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyboardNerd committed Oct 23, 2018
1 parent c3904c9 commit a3f7387
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions database/dbutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ func ConvertFeatureSetToFeatures(features mapset.Set) []Feature {
return uniqueFeatures
}

// FindKeyValueAndRollback wraps session FindKeyValue function with begin and
// roll back.
func FindKeyValueAndRollback(datastore Datastore, key string) (value string, ok bool, err error) {
var tx Session
tx, err = datastore.Begin()
if err != nil {
return
}
defer tx.Rollback()

value, ok, err = tx.FindKeyValue(key)
return
}

// PersistPartialLayerAndCommit wraps session PersistLayer function with begin and
// commit.
func PersistPartialLayerAndCommit(datastore Datastore, layer *Layer) error {
Expand Down

0 comments on commit a3f7387

Please sign in to comment.