CouchbaseLite 2.0: Writing complex queries

16 views
Skip to first unread message

parvez....@decurtis.com

unread,
Jun 20, 2018, 10:51:00 AM6/20/18
to Couchbase Mobile
For the below query:
select * from myBucket where 
((A = "value1" and B = "value2") or (A = "value2" and B = "value1")) 
and  (ARRAY_CONTAINS(C,"value1") == false or C is missing) and type = "MyDocument" order by D desc limit 60;

Is it possible to convert the above N1QL query into CouchbaseLite 2.0's Query object using select/from/where/order by expression? 
Here 'A', 'B','C' and 'D' are properties of a document with type "MyDocument"
Field A,B are of type string. C is an array fo type string and D is a date field.

How we can nest expressions from above query to properly generate a where clause in CouchbaseLite query?

Jens Alfke

unread,
Jun 20, 2018, 6:59:47 PM6/20/18
to mobile-c...@googlegroups.com


On Jun 20, 2018, at 7:51 AM, parvez....@decurtis.com wrote:

Is it possible to convert the above N1QL query into CouchbaseLite 2.0's Query object using select/from/where/order by expression? 

Yes, although I don't have time to write out the source code.
What part is giving you trouble? Instead of the ARRAY_CONTAINS() function, use an "any…in…satisfies" expression.

—Jens
Privacy Policy | Update Marketing Preferences
Reply all
Reply to author
Forward
0 new messages