DittoSyncKit provides a robust query engine that supports different filter operations. At a high-level, all queries work on a specific collection and are used to filter the collection. In addition, since DittoSyncKit works with data represented in JSON-compatible documents, the query syntax offers dot notation to reference keys within the document tree as shown below:
Keys in the query syntax by default must be alphanumeric or include underscore (a-zA-Z0-9_). In addition, the key must start with an alpha characters first (a-zA-Z_). If your key uses another character, such as a hyphen, like full-names you must bracket it: @["full-names"] or outerKey["full-names"] when referencing it within a query.
Comparisons
Equality
==
Left hand expression is equal to right hand expression
find("books[0].title == 'Harry Potter'")
Greater Or Less Than
>= or >
Left hand expression is greater than or equal to right hand expression
find("age >= 18")
=< or <
Left hand expression is less than or equal to right hand expression
find("age <= 18")
Not Equal
!=
Left hand expression is not equal to right hand expression
find("age != 18")
Compound Predicates
And
&&
This is a Logical and Predicate; similar to SQLite's AND
find("theme == 'Dark' && name == 'Light'")
Or
||
This is a Logical or Predicate; similar to SQLite's Or
find("name == 'Tom' || name == 'Arthur'")
Not
!
This is a Logical Not Predicate; similar to SQLite's NOT
find("!(name == 'Hamilton' || name == 'Morten')")
Contains
contains(array, value)
Right hand parameter must appear in the array specified by left hand parameter.