feat: extend TypeORM with ViewEntity and ViewColumn - #18
Conversation
There was a problem hiding this comment.
Pull request overview
Adds TypeORM view support to the @metapic/nestjs-utils/typeorm decorator wrappers, extending the existing camelCase-in-TS / snake_case-in-DB convention to view entities and view columns.
Changes:
- Introduces
ViewEntity(options?)andViewColumn(options?)wrappers that default names tosnake_case(class name / property key) unlessnameis provided. - Updates the README with a new “TypeORM views” section and usage example.
- Extends the example app with a view (
CatBreedStats) and adds e2e tests validating both raw SQL access and repository mapping.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/typeorm/index.ts | Adds ViewEntity / ViewColumn wrappers that apply the snake_case naming convention. |
| README.md | Documents the new view decorators with a usage example. |
| package-lock.json | Lockfile updates from dependency/install state changes. |
| example/test/typeorm.e2e-spec.ts | Adds e2e coverage for the new view naming/mapping behavior. |
| example/src/cats.module.ts | Registers the new view entity with TypeORM feature module for repository access. |
| example/src/cat-breed-stats.view.ts | Adds a concrete view entity used by the example app/tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@dstockhammer I'm wondering, shall I add the |
Yeah, probably for our convenience I would say it worth adding |
Description of change
ViewEntity(options?)- derives the view name from the class name in snake_case (CatBreedStats→cat_breed_stats) unlessnameis set.ViewColumn(options?)- derives the column name from the property key in snake_case (catCount→cat_count) unlessnameis set.This keeps database views consistent with the library's convention: camelCase in TypeScript, snake_case in the database.
Pull-Request Checklist
mainbranchnpm run lintpasses with this changenpm run testpasses with this changeFixes #0000