WriteRelationships

Atomically writes and/or deletes a set of specified relationships, with optional preconditions.

Parameters

  • relationships - A list of relationship updates to apply.
  • optionalPreconditions (optional) - An optional list of preconditions that must be satisfied for the operation to commit.

Returns

  • A task representing the asynchronous operation, with a ZedToken? indicating the version of the data after the write operation.

Example

var client = new SpiceDbClient("your_token", "your_schema_prefix");
var relationships = new List<RelationshipUpdate>
{
    new RelationshipUpdate
    {
        Operation = RelationshipUpdateOperation.Create,
        Relationship = new Relationship("document:firstdoc", "reader", "user:bob")
    }
};

// Atomically writes the specified relationships.
var resultToken = await client.WriteRelationshipsAsync(relationships);
Console.WriteLine($"Operation written at: {resultToken?.Token}");