Skip to content

Conditional expression

Ravi Teja Gudapati edited this page Jan 24, 2019 · 6 revisions

The most common case of conditional expression is comparing against a column/field in the table.

Note: Jaguar ORM generates Field elements in the bean for all columns in the table.

Lets consider the following two fields:

final name = StringField('name');
final age= IntField('age');
// Retrieve all rows where age is greater than 25
Find('people').selAll().where(age > 25);

// Retrieve all rows where age is greater than or equal to 25
Find('people').selAll().where(age >= 25);  

// Retrieve all rows where age is less than 25
Find('people').selAll().where(age < 25);

// Retrieve all rows where age is less than or equal to 25
Find('people').selAll().where(age <= 25);

Dart does not allow == and != operators. So we have to use eq and neq methods:

// Retrieve all rows where age is greater than 25
Find('people').selAll().where(name.eq('Teja'));

// Retrieve all rows where age is greater than or equal to 25
Find('people').selAll().where(name.neq('Harry'));

Conditional expressions let us filter rows in 'Find', 'Update' and 'Delete' statements. Jaguar ORM supports a very powerful fluent DSL to write SQL WHERE clauses.

The backbone of a WHERE clause are Field, Cond (Condition), Expression.

{{ TODO }}

Clone this wiki locally