Problem in retrieving documents

I am getting problems in retrieving documents from cbl. i’m able to add documents successfully. it returns id of newly created doc properly. (that’s how you get confirmation of successful addition. right?) but when i run my getAllDoc query, it always returns old data. ( meaning it gives some days old data. not the newly added docs). and this happens only in some devices. what could be the reason?

Hi @ankitsaliya,

Which platform are you using (iOS, Android, Windows?) and which version of Couchbase Lite? That might help find if there’s a related issue on GitHub.


Hi @jamiltz
It’s Android. Version i’m using is 1.3.1 currently.

@ankitsaliya can you post code snippets? You talk about creating new docs, but getting old data. Maybe there’s some confusion between updating existing docs and creating new ones?

When you say this happens on some devices, but not others, can you list some of the platforms and versions?


Oh wait. maybe I was not clear. let me describe situation again. I didnt say old data of same document. I said old data of db. (so no issue with updation) meaning, When I run my allDoc query, it is only returning data upto some specific all docs added after that point are gone. I tried adding more docs, it added successfuly but on fetching it will return only upto that specific point

My create doc code:

if (database != null && database.isOpen()) {
Document doc = database.createDocument();
return doc.getId();

My getAllDoc query:

Query query = database.getView(VIEW_TIMESTAMP).createQuery();
            QueryEnumerator result = null;
            try {
                result =;
            } catch (CouchbaseLiteException e) {
            Iterator<QueryRow> it = result;

            if (it != null) {
                for (it = result; it.hasNext(); ) {
                    QueryRow row =;
                    Document doc = row.getDocument();

And yes. I noticed this on couple of samsung devices. (One with adnroid 4.1 and one with 5.0) also on one Yureka device ( with android 6.0)

@ankitsaliya Ah, I think I see the problem. You want to start with an allDocs query. I don’t believe taking a VIew and setting the allDocsMode on it works.

Take a look at how the query is done here:

@hideki is seems like an issue that you can call setAllDocsMode on a query obtained from a View. What do you think?


I get your point. but then how do i get all documents on a particular view? documentation (the one in given link ) says it runs on imaginary view. but i want to run query on my view assuming it will be faster than imaginary view. please throw some light if i’m wrong.
And also, then how that snippet works fine in majority of devices?


A Query returns all documents from a View by default. See this for more details (the beginning of the paragraph tells you what the default order is):

I don’t know why this would work on most devices.

Views are static indexes created by processing documents through the associated map/reduce functions. The only way you should get all documents once you’ve restricted your query to a view is if all the docs have some output from the map function for that View. But since it wasn’t built to work the way you were using it, there may be some unexpected interaction going on. Hard to say.


Just take out the call to query.setAllDocsMode.