Turns out it's also relevant in many-to-many relat...
# spicedb
t
Turns out it's also relevant in many-to-many relationships, so I'll actually generalize this request. My goal is to "set" a relation, and I'd bet this is an operation that spicedb users are commonly implementing on their own. Semantics are to, atomically, 1) clear all previous tuples under a relation and 2) exactly define the new tuples. It would be awesome to do this without having to read old tuples/values or loop on failed preconditions to check for race conditions. Use cases: - one-to-one or many-to-one: - Replace an old value with
null
, currently needs a precondition to check
OPERATION_MUST_MATCH
on the old value - Replace a
null
with a new value, currently needs a precondition to check
OPERATION_MUST_NOT_MATCH
on any potential old value - Replace an old value with a new value, currently needs a precondition to check
OPERATION_MUST_MATCH
on the old value - many-to-many or one-to-many: - Set relation to an exact set of values, currently needs a precondition to check
OPERATION_MUST_MATCH
on all old values - This is to prevent two concurrent "set" operations succeeding, where the resulting relation contains the union of both sets. This is a situation that could not happen when single-threaded, and so should be avoided when multi-threaded So I guess I'm asking if spicedb could expose an operation to exactly set a relation, atomically. I know others have asked about one-to-many, ..., etc. semantics, and this could make it a lot easier without any changes to the schema. This might require a new
SetRelationship
rpc, specifically for the *-to-many case.
8 Views