-
Notifications
You must be signed in to change notification settings - Fork 52
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);
Alternatively, gt
, gtEq
, lt
and ltEq
methods can be used.
Dart does not allow ==
and !=
operators. So we have to use eq
and eq
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.eq('Harry'));
Find('people').selAll().where(name % 'Harry%');
Alternatively, like
method can be used.
TODO
&
and |
operators can be used to build nested conditions.
Find('people').selAll().where((firstName.eq('Harry') | lastName.eq('Harry')) & age > 25);
TODO