You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: Querying: How to 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')