Hi ,

I have a collection of documents where each document has the fields 
(besides others):  parent_project_number and project number.  Documents 
which have the same parent_project_number, are sub projects of the document 
with the parent_project_number. So e.g.

parent_project_number   project_number
------------------------------    ---------------------
5                                         1
5                                         2
5                                         3
6                                         4
6                                         8

I would like to order the document collection so that I get a list of 
project_numbers for each parent_project_number (as shown above)  using a 
compound key of [main_project_number, project_number].  Would I need to use 
group_level, in order to achieve this order? Does using group_level need a 
reduce block? What would the reduce block contain? Can you please give me a 
code example? I am using the following query but I am only getting nulls:

    [projectsView setMapBlock: MAPBLOCK({

        if ([doc[@"type"] isEqualToString: @"projects"]) {            

            id main_project_numberid = doc[@"main_project_number"];

            id project_numberid = doc[@"project_numberid"];

            emit(@[main_project_numberid, project_numberid],  doc[@"
project_numberid" );

        }

    }) version: @"1"];

    CBLQuery *query = [projectsView createQuery];

    query.grouplevel = 2;

   CBLQueryEnumerator* result = [query run: &error];
Thanks

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/c215df3b-87fb-4924-b6e3-b6efbc39b840%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to