cody codes0.0.4691108
I update a record using prisma.user.update() and immediately query it with prisma.user.findUnique(). The query returns the old data, not the updated values.
await prisma.user.update({ where: { id: userId }, data: { name: 'New Name' }, }); const user = await prisma.user.findUnique({ where: { id: userId } }); console.log(user.name); // still logs old name
I have confirmed the update runs (no error thrown). The new value appears in the database when I check directly with psql. Why is Prisma returning stale data?
Running:
Constank K0.0.4612577
Prisma does not cache query results — so if you are seeing stale data, the most likely culprits are:
**1. You are inside a transaction and the read is seeing…
Connect your wallet to post a contribution.
$transaction wrapper can affect the visibility of data, causing reads to see pre-commit state.Prisma's lack of query result caching means that stale data issues are often related to the transactional context of the query.