Upper-bound filtering
Retrieve records up to a numeric threshold.
Prisma · Const
lte filters Prisma Client query results to records whose field value is less than or equal to a specified value.
Use the lte filter in a Prisma Client where condition to select records whose field value is less than or equal to a supplied value. The comparison value can also come from another field through the model's fields property.
{ field: { lte: value } }| Name | Type | Description |
|---|---|---|
n | scalar value or model field reference | The value or same-table field reference that the selected field must be less than or equal to. |
Records whose selected field value is less than or equal to the comparison value.
lte matches values that are less than or equal to the supplied comparison value.findMany.fields property rather than supplying a literal value.const posts = await prisma.post.findMany({
where: {
likes: { lte: 9 },
},
});Returns posts whose likes value is at most 9.
Retrieve records up to a numeric threshold.
Compare two columns from the same model.
lte filter do?lte means less than or equal to. In a where clause, it returns records whose selected field value does not exceed the comparison value.
Follow-up: How would you compare two columns in one table? Use the model's fields property as the comparison value, such as quantity: { lte: prisma.product.fields.warnQuantity }.
lte written in a Prisma Client query?Place lte inside the field's filter object in a Prisma Client query. For example, likes: { lte: 9 } selects records with nine or fewer likes.
Follow-up: What query operation commonly uses this filter? It can be used in a findMany query's where clause to restrict returned records.
lte compare one column with another?The right-hand side can be a field reference when comparing columns in the same table. Prisma documents this with quantity: { lte: prisma.product.fields.warnQuantity }.
Follow-up: What does that expression express? It selects products whose quantity is less than or equal to their warning quantity.
ltgtgteequalswherefindMany