Thank you very much. Will try.

On Friday, April 7, 2017 at 3:09:28 AM UTC+8, Jens Alfke wrote:
>
>
> On Apr 4, 2017, at 9:27 PM, dyowee <csharpen...@gmail.com <javascript:>> 
> wrote:
>
> Like what is done in CouchDB to return all documents of the same type
> "all": {
>     
> <https://wiki.apache.org/couchdb/HTTP_view_API#CA-d9441d2b8848184b52055fd6f98fb96d93dcbb46_8>
> "map": "function(doc) { if (doc.type == 'customer')  emit(null, doc) }"
> }
>
>
> That key is a JavaScript `null` object, which is equivalent to a JSON 
> `null`. In Objective-C you would express that as an NSNull object, i.e. 
> `[NSNull null]`.
> JavaScript is weird: its `null` is a real value. It's *not* the same 
> thing as an Objective-C `nil` (or a Java or C# `null`, or a C `NULL`) — 
> those are all equivalent to JavaScript’s `undefined`.
>
> In this map function the `null` is just being used as a placeholder 
> because the developer doesn’t care what order the values should be in, so 
> it gives them all the same key. It actually doesn’t matter what key you use 
> here; you could put `0` or an empty string, or even 12345 or “foobar”.
>
> If you find yourself creating multiple views like this but with different 
> document type strings, a better way to do it is to emit doc.type as the 
> key, and emit it for all docs that have a `type` property. This gives you a 
> single view that can be used to find docs of all types, not just ‘customer’.
>
> —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-couchbase+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/e0048c1d-0465-4ecd-8cdc-35b1508b6fac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to