Support and Documentation

Using positional binding

If a .where method has more than one placeholder, Dari substitutes the placeholders for the parameters in the order they appear.

List<ToolUser> toolUser = Query.from(ToolUser.class)
                               .where("name = ? OR email = ?", "worf", "worf@klingon.com")
                               .selectAll();

Referring to the previous snippet, at runtime Dari creates the following where clause:

WHERE name = 'worf' OR email = 'worf@klingon.com'

You can indicate the value for a placeholder by specifying a position—a useful technique to avoid repeating the same value in a long list of parameters.

List<Author> authors = Query.from(Author.class)
                             .where("firstName = ?0 OR lastName = ?0 OR email contains ?1", "rand", "brightspot.com").selectAll();

Referring to the previous snippet, at runtime Dari creates the following where clause:

WHERE firstName = 'rand'
OR lastName = 'rand'
OR email LIKE '%brightspot.com%'