Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate full DB schema file #30

Open
AviDuda opened this issue Jun 19, 2024 · 0 comments
Open

Generate full DB schema file #30

AviDuda opened this issue Jun 19, 2024 · 0 comments

Comments

@AviDuda
Copy link

AviDuda commented Jun 19, 2024

The Go version of sqlc generates the models.go file which includes structs for all tables, which later get referenced in specific queries.
Would it be possible to generate a type per table also in TS?

My use case: I'm in a codebase which is using raw SQL via mysql2. I didn't decide yet if I'll move everything to sqlc, but I'd really like to at least use correct values from the DB schema (currently, there may be some lies about fields being/not being nullable all over the code).
Generated sqlc queries could then also reference the model if possible, just like it's done in Go.

For now, I'm generating types like this for all tables which works, but I'd appreciate if it was auto-generated (as I may forget to add a new query when creating a new table).

-- name: User :one
SELECT * FROM user LIMIT 1;

-- name: SomeOtherTable :one
SELECT * FROM some_other_table LIMIT 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant