I have created a schema in nodejs which structure is
enum ReportType {
USER = 'user',
POST = 'post',
}
const ReportTargetSchema = new Schema<IReportTarget>({
comment: {
type: Schema.Types.ObjectId,
ref: Comments
},
report_type_id: {
type: Schema.Types.ObjectId,
},
report_type: {
type: String,
enum: ReportType
}
}, {
timestamps: true
});
I want to perform a lookup based on the report_type. If the report_type value is ‘user’, then I want to fetch data from the users collection, and if it is ‘post’, then I want to fetch data from the posts collection.