I have a nested object like this votingPeriod: {startDate: ISOdate(), endDate: ISOdate()}. I am using the following query but still I am receiving an empty object from mongo. const organizations = await this.organizationRepository.find({ votingPeriod: { "endDate": { $gte: new Date()}}});
I have even tried it with .toISOString() but it's not helping.
I finally found answer to my own question and it worked out well. I changed my query from this:
const organizations = await this.organizationRepository.find({ votingPeriod: { "endDate": { $gte: new Date()}}});
to this:
const organizations = await this.organizationRepository.find({ 'votingPeriod.endDate': { $gte: new Date()}});