Star

Created With

linkWhere

QueryBuilderParameters['MergeI']

linkWhere using a literal string

A literal string will be used as is.

1linkconst queryBuilder = new QueryBuilder()

2link .where('a.id = 5'); /* --> literal string to use */

3link

4linkconsole.log(queryBuilder.getStatement()); // WHERE a.id = 5

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

linkWhere using a parameters object

An object of the type WhereParamsByIdentifierI can be used.

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

2link identifier1: {

3link id: '20'

4link },

5link identifier2: {

6link id: '21',

7link age: 28

8link }

9link});

10link

11linkconsole.log(queryBuilder.getStatement()); // WHERE identifier1.id = $id AND identifier2.id = $id__aaaa AND identifier2.age = $age

12linkconsole.log(queryBuilder.getBindParam().get()); // { id: '20', id__aaaa: '21', age: 28 }

linkWhere using an instance of the Where class

A Where instance can be used. In this case, the return value of its .getStatement('text') method will be used.

1linkconst existingWhereInstance = new Where({

2link identifier1: {

3link id: '20'

4link },

5link identifier2: {

6link id: '21',

7link age: 28

8link }

9link});

10linkconst queryBuilder = new QueryBuilder(

11link /* --> for expected behavior, the Where instance and the QueryBuilder instance should use the same BindParam */

12link existingWhereInstance.getBindParam()

13link).where(existingWhereInstance);

14link

15linkconsole.log(queryBuilder.getStatement()); // WHERE identifier1.id = $id AND identifier2.id = $id__aaaa AND identifier2.age = $age

16linkconsole.log(queryBuilder.getBindParam().get()); // { id: '20', id__aaaa: '21', age: 28 }

linkUsing a literal string

A Literal String can be used at Where conditions, when the typing supports it.

WhereWhere using a literal stringWhere using a parameters objectWhere using an instance of the Where classUsing a literal string

Introduction Getting Started

Modelschevron_right

Sessions and Transactions

Query Builderchevron_right
Query Runnerchevron_right

Bind Parameters

Where Parameters