MongoDB call stats() from C++

MongoDB call stats() from C++

本文关键字:from C++ call stats MongoDB      更新时间:2023-10-16

我可能错过了一些非常明显的东西,但现在无法弄清楚-如何从c++驱动程序中查询MongoDB中的"db.collectionname.stats()" ?

您将需要使用该命令的MongoDB runCommand版本,collStats:

{ collStats: "collection" , scale : 1024 }

在集合"collection"上运行stats(),以千字节为单位显示结果。

http://docs.mongodb.org/manual/reference/command/collStats/

要使用c++驱动程序发出runCommands,您需要使用DBClientWithCommands::runCommand():

http://api.mongodb.org/cxx/current/classmongo_1_1_d_b_client_with_commands.html a06c157017a74badc8831e2f66a34cc2a