Created
June 22, 2016 15:32
-
-
Save mgroves/014b9baac5c532d8cd50b9e39caa7b22 to your computer and use it in GitHub Desktop.
RequestPlusExample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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