Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
虽然正在查询两个日期之间的文档(字段类型为日期),例如 -
db.getCollection('ledgers').find({ created: { $gt: ISODate("2019-01-19"), $lt: ISODate("2019-02-19") } }).sort({'created':-1})
它还返回了 2018 年的文件。
MongoDB 存储时间,而不是日期。您需要在应用程序中将日期转换为时间并按时间范围查询。