Indy
Indy12mo ago

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
Indy
IndyOP12mo ago
There might be a way to get this to work via Snapshot Import. @lee may have some thoughts.
lee
lee12mo ago
yes you can do this with snapshot import npx convex import
allen
allen12mo ago
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?
lee
lee12mo ago
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 them
allen
allen12mo ago
got it, thanks!