Skip to content

Commit 13d017e

Browse files
committed
feat(generators/with-mongo): pluralize RESOURCE const & model name
1 parent 2cd0c11 commit 13d017e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import pluralize from 'pluralize';
2+
13
const ENTITY = '<%= compNameParamCase %>';
2-
const RESOURCE = '<%= compNameParamCasePlural %>';
4+
const RESOURCE = pluralize(ENTITY);
35

46
export { ENTITY, RESOURCE };

generators/with-mongo/templates/<%= compNameParamCasePlural %>/model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import {
33
Document as MongooseDocument,
44
Model as MongooseModel,
55
} from 'mongoose';
6+
import pluralize from 'pluralize';
67

78
import { <%= compNamePascalCase %> } from './types';
89
import { ENTITY } from './constants';
910

1011
interface Document extends MongooseDocument, Omit<<%= compNamePascalCase %>, 'id'> {}
1112
interface Model extends MongooseModel<Document> {}
1213

13-
const name = ENTITY;
14+
const name = pluralize(ENTITY);
1415

1516
const schema = new Schema<Document>({
1617
name: String,

generators/with-mongo/templates/<%= compNameParamCasePlural %>/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interface <%= compNamePascalCase %> {
22
readonly id: string;
3-
readonly name: string;
3+
readonly name?: string;
44
// TODO: add more props
55
}
66

0 commit comments

Comments
 (0)