First of all, sorry about my english.
I have a Schema inside my Model depending her, this is how my model is, im using nestjs:
export class Component {
@Prop({ required: true })
name: string;
@Prop({
type: String,
enum: ComponentTypesEnum,
required: true,
})
type: ComponentTypesEnum;
@Prop()
label?: string;
@Prop()
placeholder?: string;
@Prop({ required: true })
help: string;
@Prop([ComponentValues])
componentValues: Array<ComponentValues>;
@Prop({ required: true, default: false })
hasValidators: boolean;
@Prop({
type: ComponentValidator,
default: {
required: false,
minLength: 0,
maxLength: 0,
numberMinLength: 0,
numberMaxLength: 0,
},
})
validators: ComponentValidator;
}
ComponentValues:
export class ComponentValues {
// @Prop({ required: true, unique: true })
// id: string;
@Prop({ required: true, type: mongoose.Schema.Types.Mixed })
value: string | number | boolean;
@Prop({ type: mongoose.Schema.Types.ObjectId, ref: "File", autopopulate: autopopulateOptions })
image?: string;
@Prop({ ref: "Component", default: [] })
options: Array<Component>;
}
And in this options who reference to Componet I need to populate data , but using autopopulate plugin will not work.