Reputation: 301
I want to be able to increment a property (a counter if you like) on a document directly inside the document store without having to load the document, increment the property and then save it again because I'll end up with race conditions that way.
You appear to be able to do this with the likes of Redis, and I just wondered if there was some advanced command tucked away in Raven to achieve this?
If there isn't can anyone think of an eloquent way of achieving this? Bearing in mind this counter has the potential to be incremented multiple times in the same second, and it can't be done in memory and then periodically flushed as we're in a web-farm scenario (well I suppose it could - but it would be pretty nasty).
Upvotes: 3
Views: 497
Reputation: 22956
You can do that through the PATCH api:
See here for client code:
http://ravendb.net/docs/client-api/partial-document-updates
And for the HTTP on wire representation:
http://ravendb.net/docs/http-api/singledocumentoperations/http-api-patch
Upvotes: 6