I have two databases, 1 cosmos DB core, 2 cosmos gremlin. I perform an action of creating a new user (or updating or deleting) and I want to make sure that Atomicity guarantees that all the operations done inside a transaction are treated as a single unit, and either all of them are committed or none of them are. Now, making sure a transaction only on the cosmosDb core does not suffice me. Because it does not include the gremlin db. How to make a full transaction on both cosmos db core and cosmos db gremlin
for example
public async Task CreateInstitute(Institute institute)
{
if (string.IsNullOrEmpty(institute.Id))
{
institute.Id = Helper.NewId();
}
// TODO: transaction
var batch = _coreDb.Institutes.CreateTransactionalBatch(new Microsoft.Azure.Cosmos.PartitionKey(CORE_PARTITION));
JObject coreInstitute = JsonHelper.CombineObjects(institute, new CreationSystemProperties(CORE_PARTITION));
batch.CreateItem(coreInstitute);
var results = await batch.ExecuteAsync();
if (results.IsSuccessStatusCode)
{
JObject graphInstitute = JsonHelper.CombineObjects(new InstituteSummary(institute), new SummaryCreationSystemProperties(institute.Id));
JObject graphYear = JsonHelper.ToJObject(new Year(Helper.GetSchoolYear(DateTime.Now)));
var bindings = new Dictionary<string, object>();
string gremlin = Functions.FinalizeQuery(WriteQueries.AddVertex("Institute", graphInstitute, institute.Id, bindings), WriteQueries.AddChildVertex("Period", "Year", graphYear, institute.Id, bindings));
await _graphDb.GremlinClient.SubmitAsync(gremlin, bindings);
// if this action is bad => how to roll back cosmos db core
}
}