Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGeorge Akinian
17,615 PointsNot able to rename with db.rename()
Hi,
I'm having a bit hard time renaming the databse using db.rename() method.
Perhaps someone can supply an appropriate way of doing so. Thanks
2 Answers
Ken Alger
Treehouse TeacherPaul;
Thanks for pointing this out and hopefully the discussion in the post that Robert Komaromi mentioned answered your question. Please post back if you have additional questions on the matter.
I have contacted Treehouse support as well as the course instructor in the hopes that this particular quiz question will be corrected in a timely manner.
Happy coding,
Ken
Huston Hedinger
Treehouse Guest TeacherHey guys - you are right - db.rename
does not come packaged with the mongo shell. It does come with Mongo Hacker!
To tell you the truth, I did not realize that when I was creating the course and I apologize for the confusion.
In case you are interested, here is the mongo-hacker code that adds the rename method.
DB.prototype.rename = function(newName) {
if(newName == this.getName() || newName.length === 0)
return;
this.copyDatabase(this.getName(), newName, "localhost");
this.dropDatabase();
db = this.getSiblingDB(newName);
};
As Ken Alger pointed out, it uses the copyDatabase
and dropDatabase
.
Ken Alger
Treehouse TeacherHuston;
Thanks for the clarification on this and for correcting the quiz!
Happy coding,
Ken
Robert Komaromi
11,927 PointsRobert Komaromi
11,927 PointsTake a look here: https://teamtreehouse.com/community/cant-run-dbrename-on-mongodb
Someone on the team should address this; I'm sure people will continue to post questions about it.