Star

Created With

linkOrder By

linkOrder by, by using a literal string

A literal string will be used as is.

1linkconst queryBuilder = new QueryBuilder()

2link .orderBy('a ASC, b'); /* --> literal string to use */

3link

4linkconsole.log(queryBuilder.getStatement()); // ORDER BY a ASC, b

5linkconsole.log(queryBuilder.getBindParam().get()); // {}

linkOrder by, by using an array of literal strings

The literal strings will be joined with a comma.

1linkconst queryBuilder = new QueryBuilder()

2link .orderBy(['a ASC', 'b']); /* --> literal strings to use */

3link

4linkconsole.log(queryBuilder.getStatement()); // ORDER BY a ASC, b

5linkconsole.log(queryBuilder.getBindParam().get()); // {}

linkOrder by, by using an object

An object with an identifier, and an optional property and direction can be used.

1linkconst queryBuilder = new QueryBuilder().orderBy({

2link /* --> identifier/name to use for ordering */

3link identifier: 'a',

4link /* --> (optional) the property of the identifier to order by */

5link property: 'name',

6link /* --> (optional) the direction to orde by */

7link direction: 'DESC', // --> 'ASC' or 'DESC'

8link});

9link

10linkconsole.log(queryBuilder.getStatement()); // ORDER BY a.name DESC

11linkconsole.log(queryBuilder.getBindParam().get()); // {}

linkOrder by, by using an array of anything

An array can be used with any combination of: a string literal, an array with identifier/direction, and an object.

1linkconst queryBuilder = new QueryBuilder().orderBy([

2link /* --> literal string */

3link 'a',

4link /* --> identifier/direction tuple */

5link ['b', 'DESC'], // -> 'ASC' or 'DESC',

6link {

7link /* --> an object, as defined above */

8link identifier: 'c',

9link property: 'age',

10link }

11link]);

12link

13linkconsole.log(queryBuilder.getStatement()); // ORDER BY a, b DESC, c.age

14linkconsole.log(queryBuilder.getBindParam().get()); // {}

Order ByOrder by, by using a literal stringOrder by, by using an array of literal stringsOrder by, by using an objectOrder by, by using an array of anything

Introduction Getting Started

Modelschevron_right

Sessions and Transactions

Query Builderchevron_right
Query Runnerchevron_right

Bind Parameters

Where Parameters