How can I get a Document from local CBLite by rev id?

Afternoon,

I’m working with the Phonegap plugin for couchbase lite and I need to be able to get a document from couch with the same document id just earlier revision. In postman I’m using: http://xxxx:4984/bucket/documentName?rev=2-838d21726d73d9f894a1ab581bc7825b and i’m able to get that specific revision. In JS I’m trying to use:

var doc_name = documentName?rev=2-838d21726d73d9f894a1ab581bc7825b; couchbase.db(doc_name, function(err, document) {})

But it thinks I’m looking for a document named “documentName?rev=2-838d21726d73d9f894a1ab581bc7825b” not that revision of that document. Please help!

It depends on what JS glue library you’re using. I’m not very familiar with any of them, but I believe their functions tend to take an “options” parameter that’s a map you can put REST query params like rev into.

Hey Jens!

I’m not the most familiar with the Cordova/Couchbase bridge but what I believe your asking is what library I’m using to talk to cblite is that correct? If so I know i am using coax which in turn then uses pax and hoax. I followed the phonegap todolite example provided by couchbase. Is there a different path i should be going?

I have tried:

var map = { _rev: '1-9967a49b28fd7f4b0fd96a6284ddbf32'}; couchbase.db("documentName", map ,function(err, doc){})

As well as ‘rev’ and just passing the revision number. Is there something wrong with my syntax?

I don’t know. Hopefully someone who’s familiar with coax can chime in.

Have you tried looking at the source code of coax?