如何使用条件操作符在mongodb查询在c++

How to use conditional operators in mongodb queries in c++

本文关键字:mongodb c++ 查询 操作符 何使用 条件      更新时间:2023-10-16

当使用MongoDB c++ 驱动程序时,我找不到如何在查询中使用条件运算符("$in", "$gt", "$lt"...) ?

javascript实现示例:

db.collection.find( { field : { $in : array } } );
db.collection.find( { "field" : { $gt: value1, $lt: value2 } } );

编辑:c++文档回答了$gt/$lt操作符,但没有提到$in:

也许我误解了,但你问题中的链接实际上确实给出了一个例子。表中的第六个条目显示了javascript和c++驱动程序之间的以下关系:

Javascript

db.users.find({'age':{$gt:33},{$lte:40}})
c++

auto_ptr<DBClientCursor> cursor = 
  c.query("mydb.users", QUERY("age"<<GT<<33<<LTE<<40));