Inclusive numeric minimum
Select posts with at least a required number of likes.
Prisma · Const
gte filters Prisma Client query results to values greater than or equal to a supplied threshold. It is used inside a field condition in a where clause.
Use gte inside a Prisma Client field filter to keep records whose value is greater than or equal to the supplied value. It works with orderable scalar values, including numbers and dates, and is typically placed within a model query's where object.
{ field: { gte: value } }| Name | Type | Description |
|---|---|---|
x | A value compatible with the filtered field, such as a number or Date | The comparison value x; records are retained when the selected field is greater than or equal to it. |
A Prisma Client query result containing records whose selected field value is greater than or equal to the supplied comparison value.
gte includes records whose field value equals the threshold as well as records above it.where object to apply an inclusive minimum.gte to select records from a specified point in time onward.const posts = await prisma.post.findMany({
where: {
likes: {
gte: 9,
},
},
});Returns posts whose likes value is at least 9.
Select posts with at least a required number of likes.
Retrieve records created on or after a timestamp.
Build an inclusive range by pairing a lower bound with lte.
gte filter do?gte means greater than or equal to. In a where filter, it keeps records whose field value meets or exceeds the comparison value.
Follow-up: How would you express an inclusive date range? Use gte for the lower bound and combine it with lte for the upper bound.
gte written in a Prisma where clause?Place gte under the field being filtered, for example likes: { gte: 9 }. The comparison value must be compatible with that field's type.
Follow-up: What should be used for a strict lower bound? Use gt, which excludes records equal to the comparison value.
gte?The operator can compare orderable values such as numeric fields and dates. A date filter supplies a JavaScript Date, allowing the query to select records on or after that timestamp.
Follow-up: How can the upper boundary also be inclusive? Add lte with the desired ending date in the same field filter.
gtlteltwherefindMany