timshannon / badgerhold

BadgerHold is an embeddable NoSQL store for querying Go types built on Badger
MIT License
517 stars 51 forks source link

Implement Subqueries in Update and Delete transactions #1

Closed timshannon closed 5 years ago

timshannon commented 5 years ago

Right now running subqueries via a MatchFunc call isn't supported in Update or Delete queries. This is due to the fact that Badger only allows one iterator on Read/Write transactions.

I have a couple options to allow this:

  1. Start a new transaction for subqueries: I don't like this, because it breaks the isolation level. You'd be reading the previously committed version of records and using that information to update or delete data inside of a transaction. Not really safe IMO.
  2. When a new subquery starts, store the current iterators location, run the subquery, and seek back to that location when the subquery finishes.

1 is obviously easier, but not really an option in my opinion. Currently I'm simple throwing an error if a subquery is attempted in a RW transaction.