Fetch multiple records
Load a collection for a list or dashboard.
Prisma · Module
findMany retrieves a list of records for a Prisma model. Use query arguments to filter, sort, paginate, or shape the returned data.
Call a model's findMany method to retrieve multiple records. Supply optional query arguments such as filters, ordering, pagination, and field selection; the result is an array, including an empty array when no records match.
prisma.<model>.findMany(args?)| Name | Type | Description |
|---|---|---|
args | FindManyArgs | Optional query arguments controlling filtering, ordering, pagination, selected fields, and related data. |
A promise resolving to a list of records for the selected model.
prisma.user.findMany().findMany result is not a single object, so single-object chaining patterns do not apply.import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
async function main() {
const users = await prisma.user.findMany({
where: { email: { endsWith: "@example.com" } },
orderBy: { email: "asc" },
take: 10,
});
console.log(users);
}
main().finally(() => prisma.$disconnect());Queries up to ten users whose email addresses end with the specified domain, ordered alphabetically.
Load a collection for a list or dashboard.
Apply conditions before returning data.
Control result order and quantity.
findMany return?findMany retrieves multiple records and returns them as a list. Query arguments can constrain which records are returned and how they are shaped.
Follow-up: How would you retrieve one record instead? Use a single-record operation such as findUnique or findFirst, depending on whether the lookup uses a unique field.
findMany query?Pass filtering and result-shaping options in the argument object, then await the returned promise. For example, where restricts records, while orderBy and take control ordering and quantity.
Follow-up: How can related records be included? Add relation selections through the query's supported relation-selection arguments, while choosing the appropriate result shape.
findMany be used instead of a single-record query?The operation is appropriate when the application expects zero or more records. It returns a list even when there is only one match, unlike operations designed to return a single object.
Follow-up: Why does this matter for chaining? Operations requiring a single object cannot chain directly from a list-producing findMany call.
findUniquefindFirstwhereorderBytakeselectinclude