Skip to content

feat: extend TypeORM with ViewEntity and ViewColumn - #18

Merged
festo merged 5 commits into
mainfrom
feat-extend-typeorm
Jul 17, 2026
Merged

feat: extend TypeORM with ViewEntity and ViewColumn#18
festo merged 5 commits into
mainfrom
feat-extend-typeorm

Conversation

@festo

@festo festo commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description of change

  • ViewEntity(options?) - derives the view name from the class name in snake_case (CatBreedStatscat_breed_stats) unless name is set.
  • ViewColumn(options?) - derives the column name from the property key in snake_case (catCountcat_count) unless name is set.

This keeps database views consistent with the library's convention: camelCase in TypeScript, snake_case in the database.

Pull-Request Checklist

  • Code is up-to-date with the main branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions outlined in the conventional commit spec

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?) and ViewColumn(options?) wrappers that default names to snake_case (class name / property key) unless name is 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.

Comment thread README.md
festo and others added 3 commits July 15, 2026 15:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@festo

festo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@dstockhammer I'm wondering, shall I add the v_ prefix to all ViewEntity by default?

@dstockhammer

Copy link
Copy Markdown
Member

@dstockhammer I'm wondering, shall I add the v_ prefix to all ViewEntity by default?

Yeah, probably for our convenience I would say it worth adding ViewEntityOptions & { prefix?: string } and defaulting to v_. That's arguably a bit too opinionated for a public library, but at this point the code here is already tailored to our usage. I think it's ok.

@festo
festo merged commit 8d1df1d into main Jul 17, 2026
5 checks passed
@festo
festo deleted the feat-extend-typeorm branch July 17, 2026 07:58
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

Successfully merging this pull request may close these issues.

3 participants