I need to query a MongoDB database from NestJs to retrieve an object with the specific structure outlined below:
{
"_id": "64b89403e704cb73a2d42140",
"programs": [64b075f35742e25803cd2357, 64b075f35742e25803cd2357],
}
I have attempted the following methods:
async getInstructors(): Promise<NotFoundException | Instructor[]> {
const response = await this.instructorModel.find().populate('campus').populate({path: 'programs'}).exec();
However, both attempts resulted in an empty array being returned.
Is there a correct way to achieve this?
I am looking for the request to return an array containing the actual document data, rather than just the ObjectId.