I have a schema like this
const Schema1 = new Schema({
field11: String,
field12: [
{ _id: Schema.Types.ObjectId,
title: String
}
]
})
and another schema which has a field to reference to filed of the first collection as below
const Schema2 = new Schema({
field21: String,
field22: [
{_id: {type: Schema.Types.ObjectId},
{ref: 'Schema1.filed12'}
]
})
I need to populate field22 in schema2. How do I need to do it.
The below query doesn't work for me.
Schema2.find(field21).populate('Schema1.field12')