Hi, how can I stream data using Prisma?
# orm-help
v
Hi, how can I stream data using Prisma?
r
If you’re using GraphQL, you can use Subscriptions to stream data. If not, a combination of Prisma’s middleware and a PubSub mechanism should work as well.
v
I mean streaming data from database.
r
Could you elaborate on this?
v
Let's say I have big table that I need to stream from database to somewhere (client, file whatever). I don't want to fetch all the data into memory before processing it. Instead I want stream it from the database using node streams https://nodejs.org/api/stream.html . In similar manner to what Knex does: http://knexjs.org/#Interfaces-Streams
r
Unfortunately this isn’t supported. I would suggest creating a feature request here for the same with the above use case 🙂
v
Oh.. 😬
How are you supposed to handle large amounts of data with prisma currently then?
r
Cursor based pagination currently. That’s I think a workaround for not loading all data into memory.
v
Seems that there is already related issue: https://github.com/prisma/prisma/issues/5055 Streaming would be much smoother than cursor based pagination. The cursor example looks pretty cumbersome.
👍 1