Comparing CBLQuery objects

7 views
Skip to first unread message

Jordan Wood

unread,
Nov 16, 2015, 11:40:05 AM11/16/15
to Couchbase Mobile

I would like to take two CBLQuery objects and find out if they represent the same query on a view. I can compare the parameters that are important to me (startKey, endKey, groupLevel, mapOnly), but I can't check that the two queries actually reference the same view, since I see no way to find out what view created a query from the query object.

Is there a better way for me to compare two queries that have been created with separate calls to [myView createQuery]? Can I get the name of the view that created a CBLQuery? I am using this to update a set of CBLLiveQuery objects that my app keeps.

Jens Alfke

unread,
Nov 16, 2015, 11:46:53 AM11/16/15
to mobile-c...@googlegroups.com

> On Nov 16, 2015, at 6:25 AM, Jordan Wood <wood.p...@gmail.com> wrote:
>
> Is there a better way for me to compare two queries that have been created with separate calls to [myView createQuery]? Can I get the name of the view that created a CBLQuery? I am using this to update a set of CBLLiveQuery objects that my app keeps.

No, there isn’t an accessor for that. It seems like a reasonable thing to add, so you can file an issue on Github to request it.
As a workaround, you can make a data structure that maps query objects to views, for instance a custom class that has a query property and a view property, or an NSMapTable whose keys are query objects.

—Jens

Reply all
Reply to author
Forward
0 new messages