2017-01-02 110 views
0

如何使用新的Mongocxx驱动程序执行批量操作?司机手册是可怕的。而且没有任何地方的例子!Mongo C++批量操作

相关类:http://mongodb.github.io/mongo-cxx-driver/api/mongocxx-3.1.1/classmongocxx_1_1bulk__write.html

我可以使用bulk_write::bulk_write()创建的操作和使用bulk_write::append()添加查询。但是我对如何执行它感到困惑。

这很可怕,他们不提供类似mongo shell的功能。 例如:https://docs.mongodb.com/manual/reference/method/Bulk/

+1

有示例代码整个目录的位置:HTTPS: //github.com/mongodb/mongo-cxx-driver/tree/releases/stable/examples,其中一个用于批量写入。 – acm

+0

哇!非常感谢!希望我以前见过:) – xcorat

回答

0

创建bulk_write实例,然后用写操作填充它,最后用这种方法将其提交给蒙戈集合:

collection::bulk_write(const bulk_write& bulk_write)