I am trying to execute an upsert in the Database. I originally thought I may be able to pull this off using the Patch ability, but it seems that patch requires the document to already exist in the Database.
What I am trying to accomplish is to have two different processes each update a different property that may or may not exist yet.
TestClass
{
string Id{get; set;}
Guid OtherValue{get; set;}
int A {get; set;}
int B {get; set;}
}
Process one I want to increment A.
Process two I want to increment B.
The order in which this occurs is not guaranteed. There will be high volume of traffic and I am not sure that a transaction scope using:
var doc = session.Load<TestClass>("docs/id");
if(doc == null)
{
// insert
}
else
{
// update
}
Is there an accepted way of accomplishing this? Even better would to have the ability to upsert based on a query that wouldn't necessitate knowing the Id, but rather a value "OtherValue"
Cheers,
Ben