
Anonymous
Not applicable
2015-11-06
01:08 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to rename a MongoDB collection
Hello everybody,
I am trying to do something very simple; using Talend Open Studio for Big Data to rename a MongoDB collection. But I have some issues and I can not execute it successfully.
First, I use a tMongoDBRow component where I have configured everything about the connection. Then in Function field I wrote this:
"db.dim_division.renameCollection('dim_division_old',true);"
And when I execute it, this is the error:
connecting to socket on port 3695
connected
{ "serverUsed" : "xxxx:27017" , "ok" : 0.0 , "errmsg" : "not authorized on DATABASE to execute command { $eval: \"db.dim_division.renameCollection('dim_division_old',true);\", args: [] }" , "code" : 13}
disconnected
My server is a remote server. I read Mongodb docs and it says that user needs to have all privileges due to the fact Talend is using $eval behind the scenes.
Some questions:
1) $eval is deprecated in MongoDB 3.0. Is Talend going to change the way it executes theses functions?
2) Should I now give all privileges to the user in order to be able to execute $eval?
3) There is another way to do such simple action as renaming a collection?
4) Where can I found further documentation about executing commands (execute command option) and functions with tMongoDBRow?
Thank you in advanced
Regards
I am trying to do something very simple; using Talend Open Studio for Big Data to rename a MongoDB collection. But I have some issues and I can not execute it successfully.
First, I use a tMongoDBRow component where I have configured everything about the connection. Then in Function field I wrote this:
"db.dim_division.renameCollection('dim_division_old',true);"
And when I execute it, this is the error:
connecting to socket on port 3695
connected
{ "serverUsed" : "xxxx:27017" , "ok" : 0.0 , "errmsg" : "not authorized on DATABASE to execute command { $eval: \"db.dim_division.renameCollection('dim_division_old',true);\", args: [] }" , "code" : 13}
disconnected
My server is a remote server. I read Mongodb docs and it says that user needs to have all privileges due to the fact Talend is using $eval behind the scenes.
Some questions:
1) $eval is deprecated in MongoDB 3.0. Is Talend going to change the way it executes theses functions?
2) Should I now give all privileges to the user in order to be able to execute $eval?
3) There is another way to do such simple action as renaming a collection?
4) Where can I found further documentation about executing commands (execute command option) and functions with tMongoDBRow?
Thank you in advanced
Regards
534 Views
6 Replies

Anonymous
Not applicable
2015-11-09
04:22 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I made a testing on version 5.6.2 and it works, tMongoDBRow uses mongo-2.8.0.jar in this version. Uncheck the 'Execute command' box and type in the command as below:
Best regards
Shong
I made a testing on version 5.6.2 and it works, tMongoDBRow uses mongo-2.8.0.jar in this version. Uncheck the 'Execute command' box and type in the command as below:
"db.oldname.renameCollection('newName')"
Best regards
Shong
534 Views

Contributor
2015-11-09
05:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello jmartinez,
1- The $eval and $doEval functions are not deprecated as of Mongo 3.0 Java API () which we use behind the scenes. They are deprecated on the mongoshell and will be deprecated soon in the Java API.
2- If you're planning to execute arbitrary code on your mongodb instance (using eval) you should, from a security perspective, have the full privileges on the database.
3- 4- In the next version of the tMongoDBRow we're moving from eval to command (runCommand) (-). Note that renaming a collection using the command (runCommand) requires access to the admin database.
By the way, the call should succeed on non-secure MongoDB instance. What type of authentication you're using ?
Thanks,
1- The $eval and $doEval functions are not deprecated as of Mongo 3.0 Java API () which we use behind the scenes. They are deprecated on the mongoshell and will be deprecated soon in the Java API.
2- If you're planning to execute arbitrary code on your mongodb instance (using eval) you should, from a security perspective, have the full privileges on the database.
3- 4- In the next version of the tMongoDBRow we're moving from eval to command (runCommand) (-). Note that renaming a collection using the command (runCommand) requires access to the admin database.
By the way, the call should succeed on non-secure MongoDB instance. What type of authentication you're using ?
Thanks,
534 Views

Anonymous
Not applicable
2015-11-16
03:47 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards shongHi
I made a testing on version 5.6.2 and it works, tMongoDBRow uses mongo-2.8.0.jar in this version. Uncheck the 'Execute command' box and type in the command as below:
Best regards
Shong
Hello shong:
Thank you for your answer. Yes, it works properly this way when I configure the security for using $eval.
Regards
I made a testing on version 5.6.2 and it works, tMongoDBRow uses mongo-2.8.0.jar in this version. Uncheck the 'Execute command' box and type in the command as below:
"db.oldname.renameCollection('newName')"
Best regards
Shong
Hello shong:
Thank you for your answer. Yes, it works properly this way when I configure the security for using $eval.
Regards
534 Views

Anonymous
Not applicable
2015-11-16
03:55 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello jmartinez,
1- The $eval and $doEval functions are not deprecated as of Mongo 3.0 Java API () which we use behind the scenes. They are deprecated on the mongoshell and will be deprecated soon in the Java API.
2- If you're planning to execute arbitrary code on your mongodb instance (using eval) you should, from a security perspective, have the full privileges on the database.
3- 4- In the next version of the tMongoDBRow we're moving from eval to command (runCommand) (-). Note that renaming a collection using the command (runCommand) requires access to the admin database.
By the way, the call should succeed on non-secure MongoDB instance. What type of authentication you're using ?
Thanks,
Hello amarouni:
Thank you for your answer too.
1- Thank you for the info. Certainly I checked mongoshell not Java API.
2- I don't want to execute arbitrary code, just collection rename. But as far as I know, this is the only way, right?.
3 & 4- Good news

I am using MongoDB authentication and it works properly now after giving to the user a special role like all privileges for all actions.
Regards
534 Views

Contributor
2015-11-17
06:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The new changes should be available in Talend 6.1.1. I'll be working on this feature so I'll keep you update on the progress.
Best Regrads,
Best Regrads,
534 Views

Anonymous
Not applicable
2015-11-18
09:57 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The new changes should be available in Talend 6.1.1. I'll be working on this feature so I'll keep you update on the progress.
Best Regrads,
Hello amarouni:
Thank you for your efforts.
Regards
534 Views
