Query With Exact Match
By default, the whereXXX()
methods in query
use a case-insensitive match.
To perform a case-sensitive match you should use the exact
parameter.
Syntax
query.whereEquals(fieldName, value, [exact]);
query.whereNotEquals(fieldName, value, [exact]);
// ... rest of where methods
Parameters | ||
---|---|---|
fieldName | string | Object field to use |
value | any | Predicate value |
exact | boolean | Indicates if predicate should be matched in case-sensitive manner |
Example I - Query With Exact Match
// load all entities from 'Employees' collection
// where firstName equals 'Robert' (case sensitive match)
const employees = await session.query({ collection: "Employees" })
.whereEquals("FirstName", "Robert", true)
.all();
from Employees where exact(FirstName == 'Robert')
Example II - Query With Inner Exact Match
// return all entities from 'Orders' collection
// which contain at least one order line with
// 'Singaporean Hokkien Fried Mee' product
// perform a case-sensitive match
const orders = await session.query({ collection: "Orders" })
.whereEquals("Lines[].ProductName", "Singaporean Hokkien Fried Mee", true)
.all();
from Orders
where exact(Lines[].ProductName == 'Singaporean Hokkien Fried Mee')