theconductor
09/05/2024, 7:49 PM# 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:
with db.transaction():
userA.bestFriend = userB # line 1
userA.bestFriend = userC # line 2
userA.bestFriend = userB # line 3