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
Eh, not exactly what your looking for but I'd use something like https://fakerjs.dev/
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.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
That zapatos looks handy!