How to rename database name or collections name in azure document Db? We have set of collections in our documentdb database. Is it possible to change the collection name for other purposes
You can use the renameCollection function of MongoDB to change the collection name.
There is no way to rename a sharded collection. You can copy all the docs to a new collection. Or create multiple collections based on a weekly/period date, and use as the current one. Then have your application always use the current one by name and change the name at each period break.
In MongoDB, you can rename a field when updating documents in a collection. To rename a field, call the $rename operator with the current name of the field and the new name. This renames the field in all matching documents that have a field with that name.
renameCollection() method is used to rename a collection. The new name of the collection. Enclose the string in quotes. If true, mongod drops the target of renameCollection prior to renaming the collection.
You cannot rename a database or collection. If you must have a different collection name, you'll need to create a new collection and copy your data over.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With