first
method.
find
method. This will return the first record matching the criteria.
find
and get
methods can take a list of columns to limit down to, you can always explicitly call select
.
join
method needs the table you are joining, and a clause to match up the data. If for example you are wanting to join all of a users order data, you could do the following:
leftJoin
, rightJoin
and crossJoin
that you can use that take the same basic parameters.
where
method. You can add as many where clauses to your query to continually filter down as far as needed. The simplest usage is to construct a WhereValue
clause using some of the common operators. To do this, you would pass a column, the operator and then the value. For example if you wanted to get all users over 20 years old, you could do so as follows:
WhereValue
in this way: ==
, !=
, <
, >
, <=
, >=
, ~=
.
Alternatively you can manually create a WhereValue
clause manually:
and
operator. If you ever need to switch the operator to or
you can do so by using the orWhere
method.
or
method as well.
whereNull
method ensures that the given column is not null.
where(key: String, in values [Parameter])
method lets you pass an array of values to match the column against.
groupBy
method:
having
method which performs similar to a where
clause.
orderBy
method.
orderBy
as many times as needed. Sorting is based on call order.
forPage
method. It will automatically set the limits and offsets appropriate for a page size you define.
delete
method works similar to how update
did. It uses the query builder chain to determine what records match, but then instead of updating them, it deletes them. If you wanted to delete all users whose name is Peter, you could do that as so:
count
method.