Reputation: 1026
I am using Prisma Middleware to add caching using redis. As part of this I want to be able to set a specific key and TTL on some queries, however I am getting errors thanks to typescript being unable to find them on the query function.
I was hoping to be able to do something like this
const user = await prisma.user.findUnique({
where: { id: userId },
select: {
permissions: { select: { permission: { select: { name: true } } } },
groups: {
select: {
group: {
select: {
permissions: {
select: { permission: { select: { name: true } } },
},
},
},
},
},
},
cacheTTL: 60 * 10,
cacheKey: `user_${userId}_permissions`,
});
so I could later invalidate that cache if needed. However I just get the following:
TSError: ⨯ Unable to compile TypeScript: src/auth/permissions.ts:23:5 - error TS2353: Object literal may only specify known properties, and 'cacheTTL' does not exist in type 'UserFindUniqueArgs<InternalArgs & { result: {}; model: {}; query: {}; client: {}; }>'.
Upvotes: 1
Views: 18