Add playerId to team.playerIds AND teamId to player.teamIds in a single atomic transaction.
playerId
team.playerIds
teamId
player.teamIds
Safe to call when the relationship already exists — idempotent.
Add
playerIdtoteam.playerIdsANDteamIdtoplayer.teamIdsin a single atomic transaction.Safe to call when the relationship already exists — idempotent.