使用 mongocxx 驱动程序,我需要在 mongodb 中查询某个日期范围内的文档(股票数据)。
考虑以下文档格式:
{
date : ISODate("2010-01-01T00:00:00Z"),
open : 12.00,
high : 13.00,
low : 11.00,
close : 12.50,
volume : 100000
}
假设我每个库存有一个集合,每个集合有数百个这样的文档,每个文档都有不同的日期。
如果用户提供两个日期格式为字符串 (yyyy-mm-dd):
std::string start_date = "2010-01-01";
std::string end_date = "2010-02-05";
如何查询 mongo 以获取日期在“start_date”和“end_date”之间(包括)的所有文件?
注意:我使用的是mongodb 3.2.12,mongocxx驱动版本3.0.2
谢谢,