squid icon indicating copy to clipboard operation
squid copied to clipboard

Feature Request: auto generate schema.ts

Open xialvjun opened this issue 6 years ago • 2 comments

just like https://github.com/sweetiq/schemats or just use it.

xialvjun avatar May 08 '19 07:05 xialvjun

// 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.

xialvjun avatar May 08 '19 08:05 xialvjun

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.

andywer avatar Aug 08 '19 08:08 andywer