File tree Expand file tree Collapse file tree 4 files changed +17
-8
lines changed
generators/with-postgres-typeorm
templates/<%= compNameParamCasePlural %> Expand file tree Collapse file tree 4 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,21 @@ module.exports = class extends Generator {
2222 return this . prompt ( prompts ) . then ( ( props ) => {
2323 const compNameParamCase = changeCase . paramCase ( props . compName ) ;
2424 const compNamePascalCase = changeCase . pascalCase ( props . compName ) ;
25+ const compNameCamelCase = changeCase . camelCase ( props . compName ) ;
2526
2627 this . props = {
27- ... props ,
28+ // param-case
2829 compNameParamCase,
29- compNamePascalCase ,
30+ // param-cases
3031 compNameParamCasePlural : pluralize ( compNameParamCase ) ,
32+ // PascalCase
33+ compNamePascalCase,
34+ // PasCalCases
35+ compNamePascalCasePlural : pluralize ( compNamePascalCase ) ,
36+ // camelCase
37+ compNameCamelCase,
38+ // camelCases
39+ compNameCamelCasePlural : pluralize ( compNameCamelCase ) ,
3140 } ;
3241 } ) ;
3342 }
Original file line number Diff line number Diff line change 1+ import pluralize from 'pluralize' ;
2+
13const ENTITY = '<%= compNameParamCase %>' ;
2- const RESOURCE = '<%= compNameParamCasePlural %>' ;
4+ const RESOURCE = pluralize ( ENTITY ) ;
35
46export { ENTITY , RESOURCE } ;
Original file line number Diff line number Diff line change 11import { Entity , PrimaryGeneratedColumn , Column } from 'typeorm' ;
2+ import pluralize from 'pluralize' ;
23
34import { < %= compNamePascalCase % > } from './types' ;
45import { ENTITY } from './constants' ;
56
6- @Entity ( ENTITY )
7+ @Entity ( pluralize ( ENTITY ) )
78class Model implements < %= compNamePascalCase % > {
89 @PrimaryGeneratedColumn ( )
910 id ! : number ;
Original file line number Diff line number Diff line change @@ -25,10 +25,7 @@ const get = async (id: number): Promise<<%= compNamePascalCase %>> => {
2525 return document ;
2626} ;
2727
28- const update = async (
29- id : number ,
30- data : Omit < < %= compNamePascalCase % > , 'id' > ,
31- ) : Promise < < %= compNamePascalCase % >> => {
28+ const update = async ( id : number , data : Omit < < %= compNamePascalCase % > , 'id' > ) : Promise < < %= compNamePascalCase % >> => {
3229 // get document
3330 const document = await getRepository ( Model ) . findOne ( id ) ;
3431 if ( document === undefined ) {
You can’t perform that action at this time.
0 commit comments