Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question with InjectorToken #3

Open
pmc-sstaehle opened this issue Feb 19, 2018 · 0 comments
Open

Question with InjectorToken #3

pmc-sstaehle opened this issue Feb 19, 2018 · 0 comments

Comments

@pmc-sstaehle
Copy link

Hey guys, I have a question regarding the creation of new (business-)objects and the usage of them in within a service.
I have created a new Type "MonthView". Therefore I have an existing colleciton in my mongoDB which is called "monthviews". Now I want to do a simple .find operation in my service. I have created the model like that:
`import { InjectorService, JsonProperty } from 'ts-express-decorators';
import { prop, Typegoose, InstanceType, ModelType } from 'typegoose';
import { MonthViewRepoToken } from '../token-constants';

export class MonthView extends Typegoose {

@prop()
@JsonProperty()
year: string;

@prop()
@JsonProperty()
month: string;

@prop()
@JsonProperty()
day: string;

@prop()
@JsonProperty()
amount: string;

}

export type MonthViewInstance = InstanceType;
export type MonthViewRepo = ModelType;
InjectorService.factory(MonthViewRepoToken, new MonthView().getModelForClass(MonthView));
`

I am a little confused about the last line of code because this crashes my whole application. The login doesn't work any more, the same on signup route. When I comment the line out, then it starts to work again. It seems that the Collection "user" gets overwritten in some strange way. Can you maybe help me to figure that out?

Thanks!

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

No branches or pull requests

1 participant