-
Notifications
You must be signed in to change notification settings - Fork 52
Find statement
Find
statement builder in Jaguar is equivalent to SQL's SELECT
statement. It can be used to fetch one or multiple records from the database.
The table is selected when a new Find
builder is instantiated. In the example below, find statement will be executed on "people" table.
var find = Find("people");
The alias
parameter lets us pick an alias for the main table we are selecting on. This alias can be later used in column selection and where clauses in place of the original table name.
var find = Find("people", alias: 'p');
The above statement is equivalent to:
SELECT * FROM people as p;
selAll
method can be used to request fetching of all columns from the database.
var find = Find("people").selAll();
The above statement is equivalent to:
SELECT * FROM people AS p;
Use table
optional parameter of selAll
method to specify all columns of which table shall be fetched.
var find = Find("people").selAll('address');
The above statement is equivalent to:
SELECT address.* FROM people AS p ...;
Individual columns can be selected using sel
method.
var find = Find("people").sel('name').sel('age');
The above statement is equivalent to:
SELECT name, age FROM people;
Use alias
optional parameter of sel
method to select with what key the column will be returned as in the result.
var find = Find("people").sel('name', alias: 'n').sel('age', alias: 'a');
The above statement is equivalent to:
SELECT name AS n, age AS a FROM people;
The matching rows will be returned as:
{
'n': 'Teja',
'a': 29,
}
TODO
TODO
TODO
Person person = await find.exec(adapter).oneTo(Person.from);