data
Is there a good way to check in something to load a starter set of data, and a good way to reset all the data to run from scratch.
4 Replies
You can:
- Run a function, like the init function here: https://github.com/get-convex/convex-tour-chat/blob/main/convex/init.ts#L24 which gets run via
npx convex run init
or npx convex dev --run init
(see the package.json)
- Export and import a snapshot of the data in the database https://docs.convex.dev/database/import-export/Import & Export | Convex Developer Hub
If you're bootstrapping your app from existing data, Convex provides three ways
GitHub
convex-tour-chat/convex/init.ts at main · get-convex/convex-tour-chat
Chat app for use during Convex tutorial (found at https://convex.dev/start) - get-convex/convex-tour-chat
Search stack.convex.dev for “seed data” - I wrote an article on it recently
Also just wrote this to help out https://stack.convex.dev/npm-run-dev-with-package-scripts
Supercharge
npm run dev
with package.json scriptsWith a simple
npm run dev
we can sign up a user for Convex, add seed data, and run the frontend and backend (including database) in parallel. Here's...thank you