Skip to content

Commit

Permalink
Map classes in nest-server template
Browse files Browse the repository at this point in the history
  • Loading branch information
kaihaase committed Jun 23, 2022
1 parent 3d6622b commit 70987f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lenne.tech/cli",
"version": "0.0.72",
"version": "0.0.73",
"description": "lenne.Tech CLI: lt",
"keywords": [
"lenne.Tech",
Expand Down
12 changes: 11 additions & 1 deletion src/templates/nest-server-module/template.model.ts.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Restricted, RoleEnum } from '@lenne.tech/nest-server';
import { mapClasses, Restricted, RoleEnum } from '@lenne.tech/nest-server';
import { Field, ObjectType } from '@nestjs/graphql';
import { Prop, Schema as MongooseSchema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema } from 'mongoose';
Expand Down Expand Up @@ -48,6 +48,16 @@ export class <%= props.namePascal %> extends PersistenceModel {
this.properties = [];
return this;
}

/**
* Map input
*
* Hint: Non-primitive variables should always be mapped (see mapClasses / mapClassesAsync in ModelHelper)
*/
map(input) {
super.map(input);
return mapClasses(input, {user: User}, this);
}
}

export const <%= props.namePascal %>Schema = SchemaFactory.createForClass(<%= props.namePascal %>);

0 comments on commit 70987f3

Please sign in to comment.