On Wed, 01 Jul 2015 03:19:46 GMT, Etienne Cimon wrote:

You can serialize the update to a Json object, and deserialize the record to a Json object, and strip the Json object to a partial of the record, and do the merge using a recursive algorithm.

Hi Etienne,

Yes this is exactly how I stated my current solution. I already have a json merge function that works satisfactorily. My big issue is that in deserialising the resulting Json, my class is overwritten, losing program state that is not serialized or written to the database.

Some theoretical code below:

// Take note, that this code wasn't written to compile. Just to illustrate a point.
Graph graph;

// The returned user is now a member of the graph
auto user = graph.find!User("email", "testuser@test.com");

Json updates = ...;

auto serializedUser = user.serializeToJson;
serializedUser.mergeInPlace(updates);

user.deserializeJson(serializedUser); // At this point "user" is now a new instance of User and the graph holds the original unmodified user;

graph.sync; // Would usually write the changed object to the database, but the object in the graph has not been changed

What I would like to see in the real world:

auto user = graph.find!User("email", "testuser@test.com");
user.mergeWithJson(updates);
graph.sync; 

I point this out, not because I am looking for somebody to code me a solution, as I can do that. But vibe.d becomes a bit of a hard sell when updating a model from an API call is such a headache.