You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating several classes with the same name AND applying typegoose's modelOptions for them this way:
// ----// a.ts// ----
@modelOptions({options: {customName: 'A'},schemaOptions: {collection: 'a'}})exportclassSchema{}// ----// b.ts// ----
@modelOptions({options: {customName: 'B'},schemaOptions: {collection: 'b'}})exportclassSchema{}// --------------// some.module.ts// --------------import*asAfrom'./a';import*asBfrom'./b';
@Module({imports: [TypegooseModule.forFeature([A.Schema,B.Schema])]})exportclassSomeModule{}// ---------------// some.service.ts// ---------------import*asAfrom'./a';import*asBfrom'./b';
@Injectable()exportclassSomeService{constructor(// Skipping some types to make this example simpler
@InjectModel(A.Schema)privateaModel: any,
@InjectModel(B.Schema)privatebModel: any,){}onModuleInit(){// Both output either 'A' or 'B'console.log(this.aModel.modelName);console.log(this.bModel.modelName);}}
nestjs-typegoose injects the same model twice, seems like it ignores options.customName value for some reason.
Are there any plans to support this case? Thank you.
The text was updated successfully, but these errors were encountered:
Yeah, you are correct. The current implementation does not honor the customName from typegoose. It internally uses the class name, and thus you get a naming collision.
Are there any plans to support this case?
I think that honoring typegoose's customName is important (I did not know about it until now). But I am quite busy at the moment with classes. So a PR would be much appreciated!
When creating several classes with the same name AND applying typegoose's
modelOptions
for them this way:nestjs-typegoose
injects the same model twice, seems like it ignoresoptions.customName
value for some reason.Are there any plans to support this case? Thank you.
The text was updated successfully, but these errors were encountered: