True, so here's an example more illustrative. Mayb...
# spicedb
t
True, so here's an example more illustrative. Maybe not the best operation, but again I'm trying to build something general purpose my peers can use without friction.
Copy code
# user.bestFriend = null at first
userA.bestFriend = userB # line 1
userA.bestFriend = userC # line 2
userA.bestFriend = userB # line 3
which results in 1. touch
user:A#bestFriend@user:B
and with precondition DOES_NOT_MATCH
user:A#bestFriend
2. touch
user:A#bestFriend@user:C
and delete
user:A#bestFriend@user:B
with precondition MATCH
user:A#bestFriend@user:B
3. touch
user:A#bestFriend@user:B
and delete
user:A#bestFriend@user:C
with precondition MATCH
user:A#bestFriend@user:C
In one
WriteRelationships
, this requires deduplicating. In a remote transaction, spicedb could rollback if anything happened, but it would otherwise handle it:
Copy code
with db.transaction():
    userA.bestFriend = userB # line 1
    userA.bestFriend = userC # line 2
    userA.bestFriend = userB # line 3