Replies: 2 comments 1 reply
-
Hi @tetthys 👋 Thank you for raising this question. Does doing something like this work for you const Paginate = async (currentPage: number, take: number, model: string) => {
const modelType: PrismaClient[typeof modelName] = prisma[modelName];
const record = await modelType.findMany({
//
});
} If this answers your question, it would be great if you could mark this Discussion as answered to indicate that it has been resolved. Otherwise please let us know how else we can help you further or close the Discussion if it was resolved in some other way 🙏 |
Beta Was this translation helpful? Give feedback.
-
this is working for me: export async function getTable(tableName: string) { where "prisma" is a new PrismaClient query object exported from another file |
Beta Was this translation helpful? Give feedback.
-
Question
For example, I assume that I am defining Paginate funciton.
const result = await Paginate(currentPage, take, 'user');
How to reproduce (optional)
Expected behavior (optional)
I expect this...
But there are still type problems...
Information about Prisma Schema, Client Queries and Environment (optional)
// Add your schema.prisma
// Add any relevant Prisma Client queries here
OS:
Database:
Node.js version:
Run
prisma -v
to see your Prisma version and paste itBeta Was this translation helpful? Give feedback.
All reactions