Hello - I'm rather new to Ohm and Redis, and am trying to grasp on how I might employ transactions to ensure that one object cannot be created without another. If this is the wrong way to approach things in this space, perhaps someone could suggest a different pattern.
My example is a simple multi-tenant app that has both Account and User objects. An account can have multiple users, a single user can belong to a single Account. This is all very easy to model in Ohm (thank you!), but my business logic requires that Accounts cannot exist without Users, and Users cannot exist without accounts. Basically, I don't want orphaned objects around.
On account signup for the first user, my plan was to try and use Ohm.redis.multi {} to create an Account and a User object together. If one of those events failed, I'd raise and exception and Redis will presumably act like nothing ever happened. However, when I try and do something like this, everything just blocks.
Ohm.redis.multi do
Account.create
User.create
end
I can do things like this without issue:
Ohm.redis.multi do
Ohm.redis.set "foo", "baz"
Ohm.redis.set "bar", "neato"
end
My guess is that these things can't work together.
Can you offer any suggestions?
All the Best,
Michael Gorsuch