Is there a way to store an _id to snapshot name via api?
I'm wanting to make a list where organizations can download their own data. Is there a way to customize a snapshot export name and call the export snapshot via api?
5 Replies
There's a CLI command to generate a snapshot export where you can define the output file name, but it downloads all of the data, not just specific to certain records (assuming you have multiple orgs in your database).
To do a custom export I would write a client that calls a query which paginates the data, after check auth. Then they can stream out the data and be able to resume if there was a network issue (holding onto the cursor). You can also change the format of the data along the way - looking up associated records, etc.
Thank you @ian will definitely take a look.
Are you talking about
npx convex export
?
And yes it would be multiple orgs.Yes that's the one - to run something from a website you'd want to use the query / pagination approach. You could also do it all in an action - read a bunch of pages and write them to a file in storage and give them a download link, maybe that link is to an httpAction where you can enforce some expiration / etc. before streaming the response back
Thanks for the advice, I found it a bit easier to create a file, zip it and store it into a separate table (exports) then ref with orgId
Ill create a cron to delete the file after 14 days or so
if you're not using it already, file storage would be a cheaper option than bytes in a table