Mongo has deprecated some convenience methods in favor of raw commands, as can be seen here:
http://ift.tt/17UIXqV(java.lang.String, char[])
When trying to update code for this, after verifying that DB#addUser correctly adds a user, I cannot get this to work with #command:
DB db = mongoClient.getDB("admin");
db.command("db.createUser( { user: \"" + DatastoreFactory.DEFAULT_MONGO_DB_USERNAME + "\", pwd: \"" + DatastoreFactory.DEFAULT_MONGO_DB_PASSWORD + "\", roles: [] } )");
This results in the following response:
{ "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "no such cmd: db.createUser( { user: \"my_username\", pwd: \"my_password\", roles: [] } )" , "code" : 59 , "bad cmd" : { "db.createUser( { user: \"my_username\", pwd: \"my_password\", roles: [] } )" : true}}
What's the correct syntax for #command?
Aucun commentaire:
Enregistrer un commentaire