Skip to content
This repository was archived by the owner on Jan 14, 2021. It is now read-only.
This repository was archived by the owner on Jan 14, 2021. It is now read-only.

Query batching & transactions support #667

@schickling

Description

@schickling

Problem

It's a common use case to send multiple queries at once. However, right now this is not possible yet with Prisma Client.

Note: Theoretically this should also already be possible by doing the following by leveraging the built-in dataloader functionality, however the currently implemented optimizations only work for queries with the same pattern/selection set.

Promise.all([
  prisma.a.findMany(),
  prisma.b.findOne({ where: { id: 42 } }),
  prisma.c.count()
])

Solution

I suggest to introduce an explicit batching API:

prisma.batch([
  prisma.a.findMany(),
  prisma.b.findOne({ where: { id: 42 } }),
  prisma.c.count()
])

Additionally I also suggest to add support for executing all queries in a single transaction:

prisma.batch([
  prisma.a.findMany(),
  prisma.b.findOne({ where: { id: 42 } }),
  prisma.c.count()
], { transaction: true })

Related: prisma/specs#356 and https://github.com/prisma/prisma-client-js/issues/349 and #667

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions