How to get revision id for all documents with latest CBL 2.1?


#1

I need the revision id’s for my local caching mechanism, I am trying with select query which is not providing the revision id :-

QueryBuilder.select(SelectResult.expression(Meta.id),SelectResult.expression(Meta.sequence),
    SelectResult.all())

It seems that the latest CBL is not revealing the rev id ,is there a way to get it?
Can anyone please help?


#2

Yes, CBL is not revealing the revision ID in version 2. If it is just local caching that you need, the sequence number should serve the same purpose (it will change when a new revision overwrites the current one).


#3

Can you please share the link or reference to use sequence number?
Because every time whenever the data replication is happening the sequence number is getting changed And it doesn’t match with the sequence number on the of same remote doc,then how will i be able to know if the revision is updated or so?
Please check these screenshots :
CB server doc:

After fetching same doc locally:


#4

You said this was about local caching so I assumed you were disregarding what was in the server document. On the local side, any given revision is assigned a sequence number and if the revision of a document changes then so too will its sequence number. This metadata is local only and is not replicated to the server. Perhaps I don’t understand the goal you are after though.


#5

As per above, the same thing is happening with cashed data…After updating a document the sequence number does changes but we are saving multiple sequence numbers in cache , when the other local db syncs with the remote one and if the documents are updated then we are left with nothing to compare the the cached sequence numbers and updated docs sequence numbers. As there is no co-relation between the two.So is there a way to achieve this scenario?


#6

I don’t fully understand your situation but if it is a unique repeatable identifier for a revision that survives across multiple databases then no, there is no such information built into Couchbase. However, you could certainly add it into your object pretty easily I think.


#7

Thank you ,we have also thought of the same thing and integrating it in our project let see if this one works.