Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created June 22, 2016 15:33
Show Gist options
  • Save mgroves/2862af631d6f876bf136f571aafb7630 to your computer and use it in GitHub Desktop.
Save mgroves/2862af631d6f876bf136f571aafb7630 to your computer and use it in GitHub Desktop.
AtPlusExample
private static void AtPlusExample()
{
Console.WriteLine("========= AtPlus");
// get the current count
var result1 = _bucket.Query<dynamic>("SELECT COUNT(1) as airportCount FROM `travel-sample` WHERE type='airport'")
.Rows.First();
Console.WriteLine($"Initial count: {result1.airportCount}");
// insert a new airport
var doc = new Document<dynamic>
{
Id = "ScanConsistency::airport::" + _random.Next(10000),
Content = new
{
type = "airport"
}
};
var insertResult = _bucket.Insert(doc);
// get the count again
var state = MutationState.From(insertResult.Document);
var request = new QueryRequest("SELECT COUNT(1) as airportCount FROM `travel-sample` WHERE type='airport'");
var t = request.ConsistentWith(state);
var result2 = _bucket.Query<dynamic>(t).Rows.First();
Console.WriteLine($"Count after insert with AtPlus: {result2.airportCount}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment