Having installed and configured PgTyped it is now time to write some queries.
Lets create our first query in
Notice the comment above the SQL query. PgTyped uses such comments to give generated query functions meaningful names.
If PgTyped is running in watch mode, it will automatically parse the SQL file on each change, extracting all queries and generating strictly typed TS queries in
findBookById is now statically typed, with types inferred from the PostgreSQL schema.
This generated query can be imported and executed as follows:
For more information on writing queries in SQL files check out the Annotated SQL guide.