Export table to csv #4121
Answered
by
McSneaky
dmeinke-etc
asked this question in
Help
Export table to csv
#4121
-
Is there a best practices way in Adonis to export a database table to a csv or should I just do it how I would do it in node without a framework? |
Beta Was this translation helpful? Give feedback.
Answered by
McSneaky
Apr 27, 2023
Replies: 1 comment
-
Just as with Node import Userfrom 'App/Models/User'
...
const users = await User.all()
// Manually create CSV with your favourite CSV package
await arrayToCSV('./test.csv', users) // `arrayToCSV()` is just example, not real built-in function |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RomainLanz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just as with Node
You can use Lucid for fetching all rows from db, something like: