Prefix-based title search
Find posts whose titles begin with a known prefix.
Prisma · Const
startsWith is a Prisma Client string filter that selects records whose field value begins with a specified prefix. Use it inside a string field’s where condition.
Use startsWith inside a string field's where filter to match records whose value begins with a specified prefix. It is applied through Prisma Client query methods such as findMany, and can be combined with other filtering operators.
{ field: { startsWith: string } }| Name | Type | Description |
|---|---|---|
startsWith | string | The string prefix that the field value must begin with. |
A Prisma Client query result containing records whose selected string field starts with the supplied prefix.
where query option.mode property when you need explicit case-insensitive matching.const result = await prisma.post.findMany({
where: {
title: {
startsWith: "Pr",
},
},
});Returns posts whose title begins with the specified string.
Find posts whose titles begin with a known prefix.
Build alternative filters for different initial characters or prefixes.
Apply prefix matching while respecting database-specific case rules.
startsWith do in Prisma Client?startsWith is a Prisma Client string filter used inside a field's where condition. For example, { title: { startsWith: "Pr" } } selects records whose title begins with Pr.
Follow-up: How would you combine it with another condition? Use logical operators such as OR, AND, or NOT around the field filters.
startsWith placed in a Prisma query?Place the operator under the string field in the where object, then execute a query such as findMany. The operator accepts the prefix string to match.
Follow-up: How can matching behavior vary across databases? Case sensitivity is determined by the provider and collation, so inspect those settings or use a supported case-insensitive mode.
startsWith always case-sensitive?The result is affected by database case-sensitivity rules rather than by a universal Prisma default. PostgreSQL supports mode for specific case-insensitive filters.
Follow-up: What broader filtering capability does Prisma provide? Filters can target model fields and related record fields and can be composed with logical operators.
containsendsWithmodeORANDNOT