Skip to content

Condition Syntax

Real-Time API to register listeners for the create, update and delete events use a special argument called whereClause. The argument is a string value which sets a condition which the created, updated or deleted objects must match for the real-time event to be delivered to the listeners. The Backendless Real-Time Database supports a subset of the general where clause syntax:

Condition
Sample where clause
Value in a column equals a string literal.
columnName = 'foo'
Value in a column does not equal a string literal.
columnName != 'foo'
Value in a column is not assigned
columnName is null
Value in a column is assigned
not(columnName is null)
Value in a column of the Boolean type equals true
boolColumnName = true
Value in a column of the Boolean type equals false
boolColumnName = false
Value in a column of the Boolean type is null
boolColumnName = null
Value in a column contains a substring literal
columnName LIKE '%foo%'
Value in a column ends with a substring literal
columnName LIKE '%foo'
Value in a column starts with a substring literal
columnName LIKE 'foo%'
Value in a column is one of enumerated string literals.
columnName IN ('value1', 'value2', 'value3)

or

columnName = 'value1' OR columnName = 'value2' or columnName = 'value3'
Value in a column equals a numeric literal
intColumnName = 21

doubleColumnName = 123.456
Value in a column does not equal a numeric literal
intColumnName != 21

doubleColumnName != 123.456
Value in a column is greater than a numeric literal
intColumnName > 21
Value in a column is greater than or equal a numeric literal
intColumnName >= 21
Value in a column is less than a numeric literal
intColumnName < 21
Value in a column is less than or equal a numeric literal
intColumnName <= 21

Multiple expressions referencing same or different columns in the same table can be grouped using the AND and OR operators:

Condition
Sample where clause
Value in the columnX equals a string literal OR value in the columnY equals a number literal.
columnNameX = 'foo' OR columnNameY = 21
Value in the columnX equals a string literal AND value in the columnY equals a string literal.
columnNameX = 'foo' AND columnNameY = 'bar'

The evaluation priority of multiple expressions grouped with the AND and OR operators can be controlled with parenthesis. For example:

column1 = 'bar' OR (column1 = 'foo' AND column2 = 123) OR (column1 = 'abc' AND column3 = 777)

The syntax in the real-time system excludes the following, more complex scenarios:

It is however possible to architect a solution to enable more complex whereClause conditions using the following approach:

  1. For a complex whereClause scenario identify a smaller condition would be supported per the table above.
  2. Add a conditional listener using the smaller whereClause.
  3. When an object is delivered for the create or update events, run an API request with the following whereClause:
    complex-whereClause-from-step-1 AND receivedObject.objectId = 'objectId value of the received object'
  4. If the query above returns the same object, it satisfies the more complex query.