Querying local CBLite via REST API returns all doc revisions (not just current rev)

I have a Cordova app on Android, it uses the Couchbase Lite Phonegap plugin 1.2.0 https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin

When I use the REST API to query a view from the local CBL instance, it returns not only the current revision of a document, but also all prior revisions.
Is that by-design ?

I could implement logic in the map/reduce functions to exclude old revisions, but I’d like to avoid that if possible.

My map function looks like this:
function (doc)
{
if (doc.DocType == “SettingRecord”)
{
emit(doc.TimeStamp === undefined ? 0 : doc.TimeStamp, doc)
}
}

The REST call looks like this: http://localhost:5984/btlelog1/_design/btlelog/_view/SettingRecord

It returns all prior revision for each _id:
{“total_rows”:50,“offset”:0,“rows”:[
{“doc”:null,“id”:“04d4aa85-d71c-4122-b06d-ba2baad01c4f”,“key”:1457654740211,“value”:{“DocName”:“ScanInterval”,“SettingValue”:10000,“DocType”:“SettingRecord”,“TimeStamp”:1457654740211,"_id":“04d4aa85-d71c-4122-b06d-ba2baad01c4f”,"_rev":“1-a7798efb9b48868f1829ae9ca5a13b36”,"_local_seq":40}},
{“doc”:null,“id”:“04d4aa85-d71c-4122-b06d-ba2baad01c4f”,“key”:1457654758047,“value”:{“DocName”:“ScanInterval”,“SettingValue”:5000, “DocType”:“SettingRecord”,“TimeStamp”:1457654758047,"_id":“04d4aa85-d71c-4122-b06d-ba2baad01c4f”,"_rev":“2-5feb92ddd1ab8cbf23a5d1656791a756”,"_local_seq":41}},
{“doc”:null,“id”:“04d4aa85-d71c-4122-b06d-ba2baad01c4f”,“key”:1457654807592,“value”:{“DocName”:“ScanInterval”,“SettingValue”:10000,“DocType”:“SettingRecord”,“TimeStamp”:1457654807592,"_id":“04d4aa85-d71c-4122-b06d-ba2baad01c4f”,"_rev":“3-df59f8da6eae37dc35712c25a444639f”,"_local_seq":42}},

No, it’s not supposed to do that. And the “doc” and “id” properties for each row shouldn’t be there either, unless I’m misremembering. @hideki?

BTW, it’s usually a bad idea to emit “doc” as the value. It makes the view index a lot larger than it needs to be. Just emit the properties you need, or null if you don’t need any.

Thanks, Jens. I’ll wait for a fix.
Rainer.

The chances of it getting fixed are higher if you file a bug report :slight_smile:

Done. https://github.com/couchbase/couchbase-lite-java-core/issues/1098

When I changed storeType from SQLite to ForestDB,This issue is gone.