【发布时间】:2021-03-24 13:54:05
【问题描述】:
我想从 2 个日期范围内的集合中过滤值:
const filterPattern = {
createdAt: {
'>e': 2020-10-09T14:18:07.240Z,
'<e': 2020-12-09T14:26:49.544Z
}
};
CollectionName.find(filterPattern);
但是得到一个错误:
CastError: Cast to date failed for value "{ '>e': 2020-10-09T, '<e': 2020-12-09T14:26:49.544Z }" at path "createdAt" for...
'>e' 和 '<e' 这两个值都是我由 new Date() 创建的,它们返回 true 在 instanceof Date 之后。
那里有什么问题?
【问题讨论】: