// plain
MongoDB collections can be renamed using the renameCollection()
method.
db.collection.renameCollection("newCollectionName")
This method takes two parameters:
- The current collection name
- The new collection name
The output of the above example code will be:
{ "ok" : 1 }
This indicates that the collection has been successfully renamed.
onelinerhub: How to rename a MongoDB collection?