squid
squid copied to clipboard
Feature Request: auto generate schema.ts
just like https://github.com/sweetiq/schemats or just use it.
// main.ts
import pg_promise from 'pg-promise';
import {sql} from 'squid';
import * as schema from './schema';
const pgp = pg_promise()(`postgres://username:password@host:port/database`);
(async () => {
let persons: schema.person[] = await pgp.manyOrNone(sql`select * from person`);
console.log(persons);
})();
// package.json
"scripts": {
"schemats": "schemats generate -c 'postgres://xxxx' -o src/schema.ts",
"postguard": "postguard -c 'postgres://xxxx'",
"build": "yarn schemats & yarn postguard & tsc"
}
Hope One day we can write code like this.
Maybe just use explain is ok.
Hey @xialvjun!
Sorry, that issue completely slipped my attention. Sorry for that. Yeah, that would make a lot of sense and is definitely feasible, it's just a bunch of work.
Thanks for sharing.