This file contains hidden or 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
| { | |
| "kv": { | |
| "total_count": 274, | |
| "top_requests": [{ | |
| "total_duration_us": 3285, | |
| "encode_duration_us": 405, | |
| "last_dispatch_duration_us": 2546, | |
| "total_dispatch_duration_us": 2546, | |
| "operation_name": "upsert", | |
| "last_local_id": "9a5a9b091772f0cd/cf34c54a544d0a9c", |
This file contains hidden or 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
| if (monsterNewHitPoints <= 0) | |
| { | |
| // Monster is killed. The remove is just for demoing, and a more realistic example would set a | |
| // "dead" flag or similar. | |
| await ctx.RemoveAsync(monster).ConfigureAwait(false); | |
| // The player earns experience for killing the monster | |
| var experienceForKillingMonster = | |
| monsterContent.GetValue("experienceWhenKilled").ToObject<int>(); |
This file contains hidden or 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
| var monster = await ctx.GetAsync(_gameSim, monsterId).ConfigureAwait(false); | |
| var player = await ctx.GetAsync(_gameSim, playerId).ConfigureAwait(false); |
This file contains hidden or 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
| await _transactions.RunAsync(async (ctx) => | |
| { | |
| ... | |
| } |
This file contains hidden or 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
| var transactions = Transactions.Create(cluster, config); |
This file contains hidden or 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
| var cluster = await Cluster.ConnectAsync(_options.Cluster, _options.UserName, _options.Password).ConfigureAwait(false); | |
| var bucket = await cluster.BucketAsync(_options.Bucket).ConfigureAwait(false); | |
| var collection = bucket.DefaultCollection(); |
This file contains hidden or 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
| { | |
| "name": "Emmy-lou Dickerson", | |
| "age": 26, | |
| "animals": ["cat", "dog", "parrot"], | |
| "attributes": { | |
| "hair": "brown", | |
| "dimensions": { | |
| "height": 67, | |
| "weight": 175 | |
| }, |
This file contains hidden or 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
| var mockBucket = new Mock<IBucket>(); | |
| var mockBinaryCollection = new Mock<IBinaryCollection>(); | |
| var collection = new CouchbaseCollection(mockBucket.Object, "0x0", "_default", mockBinaryCollection.Object); | |
| var binaryCollection = collection.Binary; | |
| var result = binaryCollection.Increment("someid"); | |
| //or | |
| var result1 = collection.Binary.Increment("someid"); |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Runtime.CompilerServices; | |
| using System.Threading.Tasks; | |
| using Moq; | |
| using Xunit; | |
| namespace Couchbase.UnitTests | |
| { | |
| public class CouchbaseCollectionsTests |
This file contains hidden or 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
| //On the document itself | |
| var results1 = doc.Mutate(mutator => | |
| { | |
| mutator.Insert("toes", 4); | |
| mutator.Replace("toes", 8); | |
| mutator.Upsert("eyes", "blue"); | |
| }); | |
| //On a collection | |
| var results2 = col.Mutate("theKey", mutator => |
NewerOlder