There's a new higher-level query API available on the master branch of the 
Couchbase Lite/iOS repo, targeted at the 1.1 release: the CBLQueryPlanner 
class. (An earlier version of this was provided as an unsupported extra in 
1.0.3.) It's something like Core Data's NSFetchRequest: you use Cocoa classes 
NSPredicate and NSExpression to specify what you want to find, and 
CBLQueryPlanner creates a view, sets its map and reduce functions, and 
configures the CBLQuery.

I've written documentation 
<https://github.com/couchbase/couchbase-lite-ios/wiki/Query-Builder>, and tried 
to make it polished so you can get up to speed easily.

Here's an example taken from the docs:
    self.tagQueryBuilder = [[CBLQueryBuilder alloc]
            initWithDatabase: self.database
                      select: @[@"title", @"body", @"author", @"date"]
                       where: @"type == 'post' and tags contains $TAG"
                     orderBy: @[@"-date"]
                       error: &error];
Then to run the query you just do:
    CBLQueryEnumerator* e = [self.tagQueryBuilder runQueryWithContext: 
@{@"TAG": tag}
                                                                error: &error];

CBLQueryPlanner can't do everything you can do with map/reduce, and there's no 
reason to stop using map/reduce if you like it; this is just a convenient 
higher-level interface that should be more familiar to many developers.

If you're willing to build from the master branch, we'd really appreciate it if 
you could try this out and give feedback.

—Jens

PS: This API is very platform-specific because it's based on Cocoa classes. We 
plan to support the same functionality on other platforms, using their idioms — 
on .NET we'll base it on LINQ, for example.

-- 
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/CE881090-DA4B-4439-A30D-456F16E40746%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to