做下笔记,mongdb忽略大小写询查方法
mongdb js 写法:
db.getCollection('user').find({ "account" : { "$regex" : "yhzCAIabc", "$options" : "i" }, "orderid" : 123456789 });
c++ 版代码写法:
int32_t orderid = 123456789;
string dbaccount = "yhzCAIabc";
bsoncxx::document::value findValue = make_document(kvp("account", bsoncxx::types::b_regex{dbaccount,"i"}),kvp("ordereid", orderid));
LOG_DEBUG << bsoncxx::to_json(findValue.view());
auto result = coll.find_one(findValue.view());
if(result )
{
//do some
}
正则匹配查询更多方法参考: