nestjs / mongoose

Mongoose module for Nest framework (node.js) 🍸
https://nestjs.com
MIT License
528 stars 118 forks source link

How can we define multiple types for a one field #767

Closed vimox-shah closed 3 years ago

vimox-shah commented 3 years ago

How can I define multiple subdocument types to a single field in nestjs mongoose? e.g

export class Tracking extends BaseSchema { @Prop({ required: true, index: true }) referenceNumber: string;

@Prop({ type: A.schema | B.schema | C.schema}) data: A | B | C } here A, B, and C are different subdocument schema. but I will have data of type A, B or C while inserting the record. how can I achieve this.?

I can not define type like type: A.schema | B.schema | C.schema this. and even I can't define like data: A | B | C this also..It is giving error.

kamilmysliwiec commented 3 years ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

vimox-shah commented 3 years ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

Hey I have already posted the same question in your discord channel. But didn't get any response.