auction key iterator
parent
d6b4b51ca6
commit
05144c4e06
|
@ -152,3 +152,23 @@ func (b *bidDB) ClearAuction(auctionId string) error {
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iterate over all auction keys in memory. VIEW-ONLY.
|
||||||
|
func (b *bidDB) ForEachAuction(viewFunc func(string) error) error {
|
||||||
|
err := b.db.View(func(txn *badger.Txn) error {
|
||||||
|
opts := badger.DefaultIteratorOptions
|
||||||
|
// can customize options down here if we want
|
||||||
|
iter := txn.NewIterator(opts)
|
||||||
|
defer iter.Close()
|
||||||
|
for iter.Rewind(); iter.Valid(); iter.Next() {
|
||||||
|
item := iter.Item()
|
||||||
|
key := string(item.Key())
|
||||||
|
err := viewFunc(key)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue