Retrieve all Document's revision for audit purpose

query
java
n1ql

#1

Hello Team,

Note - CouchBaseEnterprise Edition 5.1.0 build 5552)

My use case have below sample document
{

“geolocmfyts”: 1434528647755,
“geopreclat”: 9.9165452,
“geopreclong”: -84.1014639,
“isoalpha2ctrycd”: “CR”,
“listMember”: [
{
“auditId”: 1234,
“updtts”: 1530398288828,
“reason”: “test”
},{
“auditId”: 6789,
“updtts”: 1530398288828,
“reason”: “test2”
}
],
“mapid”: “0013567”
}

What I’m trying here as follows

  1. Upsert the Subdocument Array (ListMember[n]) with a TTL

Code:
mps.forEach(profile -> {
MutateInBuilder mib = mfRepo.getCouchbaseOperations()
.getCouchbaseBucket()
.mutateIn(profile.getId());
mib = mib.upsert(“listMember”, list[0]).withExpiry(expiry);
mib.execute();
});

  1. Update some other parts of the document as delta updates. Not the Array.

My Questions :slight_smile:

  1. At any given time is there any way I could retrieve all the revisions available for that document via N1QL or any other ?
    ex :“rev”: “57-153e9a099b4f00000000000002000000” .

I tried search everywhere couldn’t find a solid explanation

  1. If above 1 st approach is not feasible I’d like to maintain a history of the updates.
    Any pointers/best practices would be greatly appreciate it.

Thanks for the support.