Basic insert operation.
I am trying to populate the database with data and the following .NET code always returns false (fails)
if (client.Store(StoreMode.Add, destination.SKU, destination
Should destination be a JSON serialized object or will Couchbase serialize it? destination.SKU is a string that is unique.
Also the following fails also:
string jsonDestination = JsonConvert.SerializeObject(destination);
if (!client.StoreJson(StoreMode.Add, destination.SKU, jsonDestination))
Ideas as to why these fail?
If Couchbase Server doesn't serialize anything then the only correct call would be the last call to 'StoreJson'. But, it also always returns false. There is no error message that is what is in part so frustrating. The method call just returns false. I will try replacing Add with Set and see what happens. I am possitive that the key doesn't already exist in the database. This is a "clean" database. I can confirm this by using the console and seeing that there are no documents in the database.
Hello,
Couchbase server does not serialize anything, the server just check of the value is JSON or not, if this is JSON it will type it.
The client API/SDKs are serializing the value to send them into Couchbase server, the default serializer of your platform is used. I can't remember what the default serialization format for C# - I am not a .net person.. yet ;) -, but it is not JSON.
So you have to serialize it to JSON yourself
So you are saying that your Add operation fails:
- what is the exact error message you have?
- If you replace the Add by a Set what is the behavior?
You are positive on the fact that the key does exist already in the DB? (As you know the Add operation will fail if the key is alread present)
Regards
Tug
@tgrall