启用分片 mongocxx

Enable sharding mongocxx

我想知道如何使用 mongocxx 3.1.3(Mongo C++ 驱动程序)执行这些命令:

sh.enableSharding("YourDB")
sh.shardCollection("YourDB.YourCollection", {field:hashed})

找了3个小时,还是没找到路。有什么想法吗?

驱动程序不为此提供帮助程序,但您可以使用 mongocxx::database::run_command with arguments as specified in the manual for the enableSharding command.

在服务器上调用命令