How does one query a couchbase view that contains two keys; the first an NSNumber type (called created in the example below) and an NSString type (called username).
CBLView* view = [database viewNamed:@"by_username"];
if (!view.mapBlock)
{
[view setMapBlock: MAPBLOCK({
if ( [doc[@"type"] isEqualToString:@"user"] )
{
emit(@[doc[@"created"],doc[@"username"]], nil);
};
}) version: @"2"];
}
CBLQuery* q = [view createQuery];
q.keys = @[ @[ @{}, @"john" ] ];
// run query
With the query above, I'm expecting to have all documents with a doc[@"username"] == @"john" matched, regardless of the value of doc[@"created"] (i.e. I'm assuming @{} is the equivalent of a wildcard).
However, the query returns 0 matches despite the presence of many documents with username @"john". I must be doing something wrong so any insight is greatly appreciated!