Filtering

Fields can be filtered by using query conditions

[GET] /...?cond=[{"type":"<OPTIONAL:and|or>","field":"<REQUIRED>","operator":"<REQUIRED>","value":<OPTIONAL>,"values":[<OPTIONAL>]}]

Note: the whole condition string should be url encoded to avoid of passing restricted symbols.

Allowed operators are:

  • Equality operators ( >, <, =, !=, >=, <= ) - applicable for text and for numbers as well
  • Comparison with NULL ( is null, is not null ) - value[s] should be omitted - ...&cond=[{"field":"some_field","operator":"is_null"}] or ...&cond=[{"field":"some_field","operator":"is_not_null"}]
  • Range operators ( between ) - range filtering, numbers and dates only
  • Array operators ( in, not_in ) - filters from array of values. Applicable for text and for numbers as well
  • Simple pattern matching ( like )
  • Regex operators ( regexp ) - regexp filtering


Examples:

Find any post that has category_id or its ID equals 1 or 2: 

[GET] http://<your-project-id>/rest/posts?cond=[{"field":"category_id","operator":"is_not_null"},{"type":"or","field":"id","operator":"in","values":["9e2eabf5-8a2b-4ffa-bb9f-566ab1e2b514","04bca006-cde8-47bc-a8eb-03c982e400de"]}]


Find any profile where firstname starts with letter "A" and age > 21: 

[GET] http://<your-project-id>/rest/profiles?cond=[{"field":"firstname","operator":"regexp","value":"^M"},{"field":"age","operator":">","value":21}]


Find a record by nested field (where field some.field exists and is not null): 

[GET] http://<your-project-id>/rest/profiles?cond=[{"field":"some.field","operator":"is_not_null"}]