Skip to content

Instantly share code, notes, and snippets.

View jeffrymorris's full-sized avatar

Jeffry Morris jeffrymorris

View GitHub Profile
{
"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",
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>();
var monster = await ctx.GetAsync(_gameSim, monsterId).ConfigureAwait(false);
var player = await ctx.GetAsync(_gameSim, playerId).ConfigureAwait(false);
@jeffrymorris
jeffrymorris / gist:29168eaa974f12a9d9ba4a571ea51383
Created December 4, 2020 05:23
couchbase-net-txn-runasync
await _transactions.RunAsync(async (ctx) =>
{
...
}
@jeffrymorris
jeffrymorris / couchbase-txn-create
Created December 4, 2020 04:49
Create a Transaction object
var transactions = Transactions.Create(cluster, config);
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();
@jeffrymorris
jeffrymorris / example.json
Created February 7, 2019 16:58
Example JSON for path/projections
{
"name": "Emmy-lou Dickerson",
"age": 26,
"animals": ["cat", "dog", "parrot"],
"attributes": {
"hair": "brown",
"dimensions": {
"height": 67,
"weight": 175
},
@jeffrymorris
jeffrymorris / binary.cs
Created December 22, 2018 00:30
BinaryCollection for non-JSON ops
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");
@jeffrymorris
jeffrymorris / c-sharp-prototype.cs
Last active December 13, 2018 05:19
C# SDK3 prototype
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Moq;
using Xunit;
namespace Couchbase.UnitTests
{
public class CouchbaseCollectionsTests
@jeffrymorris
jeffrymorris / wee
Last active November 16, 2018 02:43
C# delegates example of sub-doc
//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 =>