Hello,
   I appreciate your help to understand and implement liveQueries in iOS. 
I've read couch base documentation and made the below piece of code, but 
I'm getting "*Assertion failed: Cannot reindex view 'tableChange' which has 
no map block set'"*
   Would you tell me what I'm doing wrong?
   I have some more questions:
1) Is there something like CBLUITableSource  but for collections? 
2) I also tried to set a start key and end key in my query with no success. 
I want to filter by tableId which is numeric, so let's say I'd like to read 
documents between tableId = 5 and 10. How can this be done?
3) I need to use this live query in only one of several UIViewControllers. 
Shall I turn off the live query each time this view is closed and re-opened 
when the view is loaded again? 

Any info is very well appreciated, thanks.
Sandra


- (void) initializeQuery {

    // Set up my live query during view initialization:

    CBLQuery* query = [[database viewNamed: @"tableChange"] createQuery];

    query.limit = 100;

    liveQuery = query.asLiveQuery;

    [liveQuery addObserver: self forKeyPath: @"rows"

                        options: 0 context: NULL];

    [liveQuery start];

}

- (void)observeValueForKeyPath:(NSString *)keyPath

                      ofObject:(id)object

                        change:(NSDictionary *)change

                       context:(void *)context

{

    if (object == liveQuery) {

        NSLog(@"%@",@"Rows have changed");

       

        // update the UI

        

    }

}



- (void)tablesCBView {

    NSString *table = @"table";

    [[database viewNamed: @"tableChange"] setMapBlock: MAPBLOCK({

        id DocType = [doc objectForKey: @"docType"];

        if ([DocType isEqualToString:table])

            emit (doc,nil);

    }) version: @"1"];

}


-- 
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/9c6263f9-1999-4d96-92e3-7088f21ab13e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to