I'm currently working with a Riak database. I've implemented a level of abstraction with IRepository pattern in C#.
public interface IRepository<T> where T : EntityBaseModel
{
/// <summary>
/// Returns a GetRequest with later on deserialized T object, found via id.
/// </summary>
/// <param name="id">object's id</param>
IPromise<T> GetById(string id);
/// <summary>
/// Lists all objects in a repository.
/// </summary>
IPromise<IEnumerable<T>> List();
/// <summary>
/// Adds an object to a repository.
/// </summary>
/// <param name="entityModel">object to add</param>
IPromise Add(T entityModel);
/// <summary>
/// Updates object in a repository.
/// </summary>
/// <param name="entityModel">object to update</param>
IPromise Update(T entityModel);
/// <summary>
/// Deletes an object from a repository
/// </summary>
/// <param name="entityModel">object to delete</param>
IPromise Delete(T entityModel);
}
I then implemented a RiakRepository which connects to Riak db and does the actual operations there on Add/Get/etc. But I've ran into a problem: what if I want to create new Player document and new Messages of Player document and the first Add works out while the next one fails? I could create some sort of interface to add all the operations and then commit the changes to the database. But what if reverting (deleting that is here) fails?
How do people handle that in nosql environment?