A TypeScript code generator that produces table mapper classes for ts-sql-query by inspecting database schemas via tbls YAML output. Version 3.23.1 is current. It eliminates manual mapping and ensures type safety declaratively. Compared to manual mapping, it reduces errors and automates field type detection, documentation propagation, and naming conventions. Integrates with tbls and supports PostgreSQL, MySQL, SQLite, and more. Designed for build-time code generation with high customizability.
npm install ts-sql-codegenNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use the Generator class programmatically with a connection source path, then consume the generated DB mapper.
Update to use the new options interface; see GeneratorOpts documentation.
Install tbls via npm i -g tbls or download from https://github.com/k1LoW/tbls#install.
Replace 'removeExtraneous: true' with 'clearOutputDir: true' in Generator options.
Customize naming with the 'tableNameMapping' and 'columnNameMapping' options in GeneratorOpts.
Add "esModuleInterop": true to tsconfig.json.
Run 'npm install ts-sql-query' (version compatible with ^1.29.0).
Use 'const { Generator } = require('ts-sql-codegen')' or switch to ES module import.Install tbls globally via 'npm i -g tbls' or ensure its location is in PATH.
Double-check the path; ensure you have run 'tbls out ...' to generate the YAML file.