在 Prisma ORM 文档中,我们可以找到以下将几个数据库调用分组到一个事务中的示例。我想知道如何实施以下内容。 $transactions() (prisma.post...) 中使用的方法与我们可以使用“独立”的方法相同。
const [posts, totalPosts] = await prisma.$transaction([
prisma.post.findMany({ where: { title: { contains: 'prisma' } } }),
prisma.post.count(),
])
我想知道如何实现这样的方法($transation())。
我唯一的想法是检查“上下文”(this),但不确定这是否是最干净的想法。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号