Reputation: 35
I am currently making a database program using couchbase on android. After I replicating the data, how can I get the document ID so I can list down all the things in database.
Upvotes: 2
Views: 345
Reputation: 5162
You need to make use of Queries!
If you would like to retrieve all the documents (or their IDs), you could use All-documents query.
Query query = database.createAllDocumentsQuery();
QueryEnumerator result = query.run();
for (Iterator<QueryRow> it = result; it.hasNext(); ) {
QueryRow row = it.next();
Log.w("MYAPP", "document ID: %s", row.getDocumentId()); // or QueryRow also has a way to get its source document.
}
You could write your own Views as per your need and later query them for results.
Also look at how to deal with document(s) in a database over here. In fact, I recommend going through entire guide.
Upvotes: 1