0

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?

Community
  • 1
  • 1
user1255410
  • 856
  • 1
  • 9
  • 15
  • 1
    if you want ACID semantics, then don't use a nosql database. – Marc B Jul 05 '16 at 17:03
  • Then how do you handle...any data for that matter? There needs to be some way to make sure it's not corrupted. Unless you take availability for granted and just let it go. – user1255410 Jul 05 '16 at 17:12
  • 1
    nosql throws that in your face and makes it a client responsibility. you can be reasonably sure that whatever you send into a nosql will be what's stored, but the db doesn't make any effort to guarantee it's actually consistent with everything else. – Marc B Jul 05 '16 at 17:18

0 Answers0