Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created June 22, 2016 15:32
Show Gist options
  • Save mgroves/014b9baac5c532d8cd50b9e39caa7b22 to your computer and use it in GitHub Desktop.
Save mgroves/014b9baac5c532d8cd50b9e39caa7b22 to your computer and use it in GitHub Desktop.
RequestPlusExample
private static void RequestPlusExample()
{
Console.WriteLine("========= RequestPlus");
// 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"
}
};
_bucket.Insert(doc);
// get the count again
var request =
QueryRequest.Create("SELECT COUNT(1) as airportCount FROM `travel-sample` WHERE type='airport'");
request.ScanConsistency(ScanConsistency.RequestPlus);
var result2 = _bucket.Query<dynamic>(request).Rows.First();
Console.WriteLine($"Count after insert with RequestPlus: {result2.airportCount}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment