For example, if I have a document with that ID, and another document with that ID is trying to insert, it will add it’s information to the existing document.
var config = new ClientConfiguration
{
Servers = new List<Uri>
{
new Uri("couchbase://localhost/"),
}
};
using (var cluster = new Cluster(config))
{
using (var bucket = cluster.OpenBucket("BeaconListN1ql"))
{
string id = beacon.SerialNumber;
//Attributes = new Dictionary<string, object>
// {
// {"BluetoothAddress", beacon.BluetoothAddress},
// {"BluetoothName", beacon.BluetoothName},
// {"Id1", beacon.Id1},
// {"Id2", beacon.Id2},
// {"Id3", beacon.Id3},
// {"SerialNumber", beacon.SerialNumber },
// {"ReceiverId", beacon.ReceiverId },
// {"Manufacturer", beacon.Manufacturer },
// {"ServiceUuid", beacon.ServiceUuid }
// }
var doc = new
{
BluetoothAddress = beacon.BluetoothAddress,
BluetoothName = beacon.BluetoothName,
Id1 = beacon.Id1,
Id2 = beacon.Id2,
Id3 = beacon.Id3,
SerialNumber = beacon.SerialNumber,
ReceiverId = beacon.ReceiverId,
Manufacturer = beacon.Manufacturer,
ServiceUuid = beacon.ServiceUuid,
};
if (!bucket.Exists(beacon.SerialNumber))
{
bucket.Insert(new Document<dynamic>
{
Id = id,
Content = doc
});
}
else
{
//InsertExample(IBucket bucket, string id, string path, string value)
bucket.MutateIn<dynamic>(id).Insert(id, doc, true).Execute();
}
}
}
This does not work as it will try add to the id and obviously won’t insert after the second input. I want it so all that information regarding the beacon entries can be in one document with the id of beacon serial number.
edit- I believe the document id and key(IOperationResult Insert(string key, T value); ) are the same thing? which means you can’t append the items like I want to since you can’t have duplicate keys?