我目前正在使用Riak数据库。我在C#中使用IRepository模式实现了一个抽象级别。
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);
}
然后我实现了一个连接到Riak db的RiakRepository,并在Add / Get / etc上进行实际操作。但是我遇到了一个问题:如果我想创建新的Player文档和新的Player of Player文档,并且第一个Add在下一个失败的情况下解决了怎么办?我可以创建某种接口来添加所有操作,然后将更改提交到数据库。但如果还原(删除在这里)失败怎么办?
人们如何在nosql环境中处理?