Using the MongoDB server 3.4.4 on Windows 10, the following command works just fine:
db.createUser(
{
user: "Billy",
pwd : "123456",
roles :
[
{ role: "userAdmin", db : "biolomics_index" },
{ role: "dbAdmin", db : "biolomics_index" },
{ role: "readWrite", db : "biolomics_index" }
]
}
Running the same command with the mongocxx 3.1.1 C++ drivers fails:
db.run_command(document{} << "createUser" << open_document <<
"user" << "Billy" <<
"pwd" << "123456" <<
"roles" << open_array <<
open_document << "role" << "userAdmin" << "db" << "biolomics_index" << close_document <<
open_document << "role" << "dbAdmin" << "db" << "biolomics_index" << close_document <<
open_document << "role" << "readWrite" << "db" << "biolomics_index" << close_document <<
close_array << close_document <<
finalize);
with the error:
"createUser" had the wrong type. Expected string, found object: generic server error.
I can't find the syntax to generate the correct document. Any idea?