Hack for preinserting `_id` and `_creationTime`?
@allen asks: Are there any hacks to inserting data and specifying the _id and _creationTime values? My use case is seed data. I'd like a static set of IDs for my fixtures to make creating relationships easier, and would like to create historical entries of data, as some features of my application are time-sensitive, and I'm unable to to fully test things without records being timestamped > 30 days ago.
5 Replies
There might be a way to get this to work via Snapshot Import. @lee may have some thoughts.
yes you can do this with snapshot import
npx convex import
For clarity, as the docs are pretty thin on this, does this overwrite all data in the db across all tables? Or what is the behavior exactly?
npx convex import --replace --table <table> file.jsonl
(or csv or json) overwrites just that one table. npx convex import --replace snapshot.zip
overwrites the tables that appear in snapshot.zip. you can also omit the --replace
flag and it will throw an error if the tables exist and are nonempty.
agreed docs are thin on this, i should update themgot it, thanks!