Filtered collection queries
Retrieve a collection matching criteria such as status, owner, or a field comparison.
Prisma · Function
findMany retrieves multiple records for a Prisma model. Query arguments can filter, shape, sort, and paginate the returned list.
Call the generated model delegate's findMany method with optional query arguments to retrieve multiple records. Filtering, field selection, relation inclusion, ordering, pagination, and other options shape the returned list.
prisma.<model>.findMany(args?)| Name | Type | Description |
|---|---|---|
args | Prisma.ModelFindManyArgs | Optional arguments that filter, select, include, order, and paginate the records returned by the model delegate. |
A Promise resolving to an array of records matching the query.
findMany when the result should contain multiple records.prisma.user.findMany(...).where option applies filtering conditions to the records returned.const users = await prisma.user.findMany({
where: { email: { endsWith: "@example.com" } },
select: { id: true, name: true },
orderBy: { name: "asc" },
take: 10,
});Fetches up to ten matching users, returning only their IDs and names in ascending name order.
Retrieve a collection matching criteria such as status, owner, or a field comparison.
Return only selected fields or include related records for list views and API responses.
Build bounded pages by combining ordering with take and skip.
findMany return, and what are its main uses?findMany returns a list of records for a model. Its arguments can constrain which records are returned and shape each record, such as with where and select.
Follow-up: How would you return only recent records? Add an orderBy on the timestamp field and use take to limit the result, optionally filtering with where.
findMany query?Use where to filter records, select to choose scalar fields, and include to load related records. Ordering and pagination can be applied with orderBy, take, and skip.
Follow-up: How would you avoid returning unnecessary columns while loading a relation? Use select and nest a relation selection rather than requesting the complete record with include.
findMany query?findMany is appropriate when multiple records are expected; it always produces a list, including when no records match. A single-record query should use an appropriate single-result operation instead.
Follow-up: Why should code not access a property such as user.email directly on the result? Because the result is an array; iterate it or deliberately choose a single-record query.
findFirst()findUnique()findFirstOrThrow()count()aggregate()groupBy()