Got unauthorized error when renaming mongodb collection -


i using mongohq sandbox plan. in command prompt,

db["oldcollectionname"].renamecollection("newcollectionname", true) 

works fine without using admin database.

however, got "unauthorized" exception when in java:

oldcollection.rename(newcollectionname); 

since using mongohq sandbox plan, don't have access admin database. there way rename collection without creating new collection, copying on documents, , dropping old collection?

in java , using jongo can following:

mongocollection col = new jongo(dbconfigurer.getdb()).getcollection("code"); col.getdbcollection().rename("code45", true); 

i've tested , works.

now using 'runcommand' (same using db.command) in following example:

db db = ....getdb(); jongo jongo = new jongo(db); jongo.runcommand("{ renamecollection : 'old_name', to: 'new_name', droptarget: true}"); 

i obtain same error have.

i read documentation have connect first admin database process of command not allowed, did same "admin" db, , obtain following error stack:

{ "serverused" : "localhost/127.0.0.1:27017" ,  "errmsg" : "exception: invalid collection name: new_name" , "code" : 15967 , "ok" : 0.0} 

strange have such different behaviors...


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -