input parameter of emit in couchbase Lite by REST API?

21 views
Skip to first unread message

atom992

unread,
Jul 1, 2015, 11:56:33 PM7/1/15
to mobile-c...@googlegroups.com


I am using PhoneGap to develop a android app, and I wrote a view like this:

        db.put(design, {
            views
: {
                getIDByKey
: {
                    map
: function (doc) {
                       
if(doc.type && doc.key){
                           emit
([doc.key,doc.type],doc.id);
                       
}
                   
}.toString()
               
}


but It not works (It shows "null" in the response that [doc.id] should be show), not like the couchbase server's view, It can take (doc,meta) two parameter, How can I emit doc.id in couchbase Lite's view, such as be part of key(emit([doc.type,doc.id],[doc.value]) I want to use doc.type and doc.id to get doc.value)?

Jens Alfke

unread,
Jul 2, 2015, 12:14:06 AM7/2/15
to mobile-c...@googlegroups.com
Use doc._id, not doc.id.

—Jens 
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/94da15b0-b4ae-4894-9491-cd972ead6aec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

atom992

unread,
Jul 2, 2015, 12:41:32 AM7/2/15
to mobile-c...@googlegroups.com
Thanks, It works.
and How can I use other values in meta object? such as rev,expiration,flags.

Jens Alfke

unread,
Jul 2, 2015, 1:20:45 AM7/2/15
to mobile-c...@googlegroups.com
That's Couchbase Server, not Couchbase Lite. The rev ID is _rev. There are no expiration or flags.

--Jens     [via iPhone]
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.

atom992

unread,
Jul 2, 2015, 2:38:39 AM7/2/15
to mobile-c...@googlegroups.com
Thank you very much.


On Thursday, July 2, 2015 at 11:56:33 AM UTC+8, atom992 wrote:
Reply all
Reply to author
Forward
0 new messages