I have a mongoose model that has a field called timeLimit which is an Object
timeLimit: {
type: Object,
// of: Date,
},
If I try to find documents in this collection using the following query
const docs = await Model.find({
'timeLimit.end': {
$gt: moment().utc(),
},
});
I get no result, despite the fact that there are valid values to be returned. However, if I change the field in the model to match a Map of Dates...
timeLimit: {
type: Map,
of: Date,
},
The query returns the valid values of this query.
My question is, why is the query invalid when using the Object mongoose type if MongoDB doesn't even have the Map type, only the Object type?