jsoncouchbasesql++couchbase-sync-gateway

How can I see the tree of a document in couchbase server in N1QL?


My platform is Couchbase Server on version: 4.6.1-3652 Enterprise Edition (build-3652).

I have seen that in every document there is the history with the list of revisions. In N1QL, does anyone know how to get all the different bodies of each revision back?

For example, in this document I came to revision 4:

{
    "id": 123,
    "_deleted": true,
    "_rev": "4-54gtrg",
    // ... body ...
}

I am interested in returning to the "3-dsada" revision, can it be done?


Solution

  • My answer applies to Couchbase Server, which I assume you're asking about. When using Couchbase Mobile, there might be a different answer.

    Short answer: it can't be done.

    Longer answer: (I might be wrong or oversimplying here), but in Couchbase, the old revisions are tombstoned (marked for deletion). When cleanup occurs, these old documents will be purged permanently. So, the old document might not be actually deleted for a period of time, but (by design) there is no way to access those old revisions: only the latest.