Skip to content

Rename a collection in MongoDB

Renaming a collection in MongoDB is quite simple. When you rename a collection, it obtains a lock on the collection till the rename process is complete.





> db.poopcode_users.renameCollection("users")
{ "ok" : 1 }

Here the collection ‘poopcode_users‘ is renamed to ‘users‘.

See also  Get data from MongoDB in Cypress API testing

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.