Read pg db types and constraints automatically?

Is there way to read postgres database for it's types and constraints, so I could mock up some functions to fill out with fake data for testing?
4 Replies
Josh
Josh12mo ago
Eh, not exactly what your looking for but I'd use something like https://fakerjs.dev/
Generate massive amounts of fake (but reasonable) data for testing and development.
Etan
Etan12mo ago
i use https://www.npmjs.com/package/zapatos allows you to generate types from a postgres db. It's not the best tool but it's nice so far
npm
zapatos
Zero-Abstraction Postgres for TypeScript. Latest version: 6.1.4, last published: 5 months ago. Start using zapatos in your project by running npm i zapatos. There are 5 other projects in the npm registry using zapatos.
Etan
Etan12mo ago
I also know Drizzle has a db inspector that generates types as well, but it's incredibly new and still lacking quite a few features
Massukka
Massukka12mo ago
That zapatos looks handy!
Want results from more Discord servers?
Add your server
More Posts