Document Revisions

Hi,

I am running CBL verion 3 on android, sync gateway version 2.8 and couchbase server enterprise version 6.6.
My sync gateway replicates json documents to/from bucket app-bucket. Few of the documents in this bucket have an unexpected structure! Although the document json is valid the hierarchy of some nodes is messed up.

I want to understand how the documentw became so messed up, so I am wondering if it is possible to get the document in each revision. As you can see below the document has 3 revisions. Is it possible to get the document json for each revision?

Regards,
Faris Ahmed

{
“meta”: {
“id”: “dff676a2-d7c2-41c1-a4f2-4d0d74b3a5d3”,
“rev”: “799871-17426eccffd000000000000000000000”,
“expiration”: 0,
“flags”: 0,
“type”: “json”
},
“xattrs”: {
“_sync”: {
“rev”: “3-d84af2e6af70dc79e5984d2cc9ce1b4cc28fb0a0”,
“sequence”: 951663952,
“recent_sequences”: [
951663760,
951663829,
951663952
],
“history”: {
“revs”: [
“1-f1bbbbf7c0d4c9739bdb7f4de4bd4843d69a61c5”,
“3-d84af2e6af70dc79e5984d2cc9ce1b4cc28fb0a0”,
“2-6e9ac131677c8b12d4696b70784d1558”
],
“parents”: [
-1,
2,
0
],
“channels”: [
[
“20191105_0000435839”
],
[
“20191105_0000435839”
],
[
“20191105_0000435839”
]
]
},
“channels”: {
“20191105_0000435839”: null
},
“cas”: “0x0000d0ffcc6e4217”,
“value_crc32c”: “0x95d079a5”,
“time_saved”: “2023-02-10T10:10:38.078290408Z”
}
}
}

Sync Gateway does not retain document bodies of previous revisions, with the exception of temporary backups for in-flight replications and delta sync purposes.

Can you elaborate on how the JSON document structure is unexpected?

The structure of some documents cannot be explained by the UPDATE statements performed by our services. Example we have two json attributes in the first level A and B like
{
A: {…}
B: {…}
}

some documents looke like this:
{
A: {
B: {…}
}
}

Our services never change documents nor create documents in which B is a child of A