Exporting component-specific data from production to development
Hi, right now I am using
ConvexHttpClient
to query specific documents from production and subsequently use npx convex import
to import them into my development deployment.
I would also like to copy over specific documents like this for data stored inside non-app components. Is it possible to do this right now? I do see that npx convex import
has an option to specify a --component
path, but I don't know if it's possible to programmatically query specific documents from a non-app component.
I know it's possible to export all data using npx convex export
, but I'd like to only export specific documents since exporting the full production database can take a long time.8 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I would suggest:
- Make queries for a subset of documents in the component- as an internalQuery if you want extra isolation / ensure no one else uses them
- Run
npx convex run --component <path> myFile:getRepresentativeTestData
from the shell, saving the output as json
- Import the data either with a mutation you pass the data to, or via import, provided the output json is in the right formatIs it possible to add custom queries to components that you've added through a npm package? For instance, we have subscription data stored in the
polar
component (which is imported from @convex-dev/polar
). I suppose we could fork the package and add it to our own repository, but that feels like overkill just to add support for exporting component data.ah gotcha- have you considered manually curating your dev data? Might be a good idea to avoid putting prod payment metadata in dev.
Also have you experimented with
npx convex data
? I believe you can fetch component data directly
Also not unreasonable for components to expose more data.Might be a good idea to avoid putting prod payment metadata in dev.I agree. The main reason we want to have this ability is to debug user-specific errors, for which it does help to have the most representative copy of their data for debugging. Ideally we add a feature for seeding (part of) the data in the copy script. I just looked at
npx convex data
, thanks for mentioning it. Unfortunately this command doesn't have support for providing a --component
name. Also, the outputted data is in a pretty-printed table, which doesn't easily allow for converting the data to a JSONL file.npx convex data --component agent messages
works for me.
However yes that format is not very friendly to parsing. I just put up a PR to do json, but I imagine it's still not there since you'd want some custom filter..
The best option right now feels like doing it in a customQuery
in the dashboard, then copying those results into json and pasting them in the dashboard in dev.
Or if it's a reasonable API for general purpose we can add it to the componentnpx convex data --component agent messages
works for me.
Ah interesting. Then a heads up that the flag isn't present in the help output (version 1.25.4
):
(and on that note, the --local
flag also isn't present in the help output of the npx convex dev
command)
I just put up a PR to do json, but I imagine it's still not there since you'd want some custom filter..That's great, thank you. Yes, ideally we want to filter the data by a specific user id.
Or if it's a reasonable API for general purpose we can add it to the componentRight, we’ll think about what API would best meet our requirements.
good catch - I'm updating the
data
command and will un-hide the arg