I’m appending strings using Append()
When data is saved it is in binary form in the doc’s value.
It happens that the length of the binary doc is longer than the length of it represented as plain text.
Given that it is illegible and longer, Is there a better way to use Append to append strings ?
If the string represent indexes, can I append integers ?
Can I append to create a HashSet ? HashSet ?
Append is fairly rudimentary op. There are only two flavors supported: appending strings or bytes. You may have better luck with bytes, because you have a bit more control.
The Console only allows valid JSON to be viewed; anything else is stored as binary on the server and the UI wouldn’t know how to represent it (i.e. is it a string or int or something else?).
CB doesn’t support a data structure like storage, for example, an integrated hash set. We have talked about adding this, but we don’t having anything yet. Note you can store stuff in JSON this way, though.
I think that the console shows Base 64 encoded strings in the documents view:
But in a document view:
In this example, QSxBLEIsQyw= is 12 bytes long
where the original string is A,A,B,C, only 8 bytes long (50% longer)
So, my question was whether I can append a string rather than its coded representation so that I’ll benefit from a readable text and a less memory and I guess that the answer is no.
Non-JSON values will be stored as binary blob (as you have seen) and you cannot view them from the document editor in the Management Console. The console tries to display the document as JSON, if it cannot it encodes it as base64 to display in the UI.
So, the answer is no, you cannot append two valid JSON objects as a string. However, in future CB versions this will likely change when there is support for modifications to individual elements of a document.
Have a look at the “cbc” utility installed with libcouchbase. The console renders the data as views provides it, and that’s only as base64, even though it’s not stored as base64.