lucid
lucid copied to clipboard
Stream query result
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.
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.
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.
Please don't stale :c
This is something in my pipeline, but will be addressed post v6 release
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
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.