How can I define multiple subdocument types to a single field in Nestjs mongoose?

Viewed 183

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 assume that A, B, and C are different subdocument schema. but I will have data of type A, B, or C anyone of them while inserting the record. how can I define this?

I can not define a 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 an error.

0 Answers
Related