I am having trouble trying to use the map in IBucket. I can connect to the bucket and I have beem able to insert/upsert with documents. Right now, I’m trying to create map and id/content to it if the id didn’t exsist in the bucket. If the same id exsists, I want to add the new id/content previous document.
example:
ClusterHelper.Initialize(new ClientConfiguration
{
Servers = new List<Uri> { new Uri("couchbase://localhost") }
}
);
var bucket = ClusterHelper.GetBucket("something");
string stringExample = "some strings";
if (!bucket.Exists("SerialNumber"))
{
bucket.MapAdd("SerialNumber", "mapKey", stringExample, true);
var insert = bucket.MapGet<string>("SerialNumber", "mapKey"); //I tried<dynamic> as well
bucket.Insert(beacon.SerialNumber, insert);
}
else
{
bucket.MapAdd("SerialNumber", "mapKey", stringExample, false);
var upsert = bucket.MapGet<dynamic>("SerialNumber", "mapKey");
bucket.Upsert("SerialNumber", upsert);
}
it’s throwing exception at the MapGet statement, "‘System.NullReferenceException’ occurred in Couchbase.NetClient.dll ".
The MapAdd has “Info = ‘((Couchbase.Cluster)((Couchbase.CouchbaseBucket)bucket).Cluster).Info’ threw an exception of type ‘System.InvalidOperationException’”