lucid icon indicating copy to clipboard operation
lucid copied to clipboard

Stream query result

Open Xstoudi opened this issue 2 years ago • 1 comments

Why this feature is required ?

When fetching a lots of data that need to be parsed to CSV and redirected to a download stream for client. Handling lots of data while preserving memory.

Have you tried any other work arounds?

I tried to use .knexQuery.stream() but calling it ignore where clauses because https://github.com/adonisjs/lucid/blob/develop/src/Database/QueryBuilder/Chainable.ts#L76 is never called, thus :

query.where('foo', 'bar')
return response.stream(query.knexQuery.stream().pipe(csv)) // execute the query WITHOUT the where clause

Calling toSQL before force the call of applyWhere and make it works :

query.where('foo', 'bar')
query.toSQL() // apply where and query now includes the where clause(s)
return response.stream(query.knexQuery.stream().pipe(csv))

But it would be better to directly be able to do

return response.stream(query.stream().pipe(csv))

Are you willing to work on it with little guidance?

Yes, I just need to know exactly where do I need to add it, and how to test it.

Xstoudi avatar Aug 12 '22 16:08 Xstoudi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 14 '22 07:10 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 20 '22 23:12 stale[bot]

Please don't stale :c

Xstoudi avatar Dec 22 '22 13:12 Xstoudi

This is something in my pipeline, but will be addressed post v6 release

thetutlage avatar Dec 22 '22 13:12 thetutlage

Yeah I guessed that Adonis v6 is your main focus right now, I was just trying to make the bot understand that is should stay alive

Xstoudi avatar Dec 25 '22 00:12 Xstoudi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 18 '23 07:03 stale[bot]