I have a CBLModel that has a property of another CBLModel. Similar to:
@interface CommentModel : CBLModel
@property NSString *comment;
@property UserModel *user;
@end
@interface UserModel : CBLModel
@property NSString *username;
@end
This all works magnificently within the model instance. However, I'm trying to
build a view of the comments + the user name. Like so:
CBLView* allCommentsView = [db viewNamed:allComments];
[allCommentsView setMapBlock: MAPBLOCK({
id type = [doc objectForKey: @"type"];
if ([type isEqualToString:@"comment"] ) {
NSString *comment = [doc objectForKey:@"comment"];
UserModel *user = [doc objectForKey:@"user"];
NSString *name = user.username;
emit(@[comment, name], nil);
}
}) version: @"1"];
But this doesn't work. The [doc objectForKey:@"user"] returns the internal id,
not the usermodel. This makes sense if you understand that you are being passed
the dictionary of the document properties, but it's a problem for my needs.
Reading the docs, I shouldn't reach out into the database to look up
information about the user. Is there any way to do this without looking it up
when I read the related query?
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/5AE49DF3-A346-4C9B-91F8-A9C801894FEB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.