MongoDB.Rename
--------------

This function is a helper to rename an existing collection on a MongoDB server.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MongoDB](component_MongoDB.md) | [12.4](newinversion124.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "MongoDB.Rename"; MongoDBRef; NewDatabase; NewCollectionName { ; DropTargetBeforeRename } ) 

**MBS**( **"MongoDB.Rename";** /\* This function is a helper to rename an existing collection on a MongoDB server. \*/  
**$MongoDBRef**; /\* The reference number for the mongo connection.e.g. $MongoDB \*/   
**$NewDatabase**; /\* The new name for the database. \*/   
**$NewCollectionName**; /\* The new name of the collection. \*/   
**$DropTargetBeforeRename**) /\* Optional; If an existing collection matches the new name, drop it before the rename.  
Pass 1 to drop or 0 to not drop and return an error in case of a name collision. Default is 0.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |  |
| NewDatabase | The new name for the database. |  |  |
| NewCollectionName | The new name of the collection. |  |  |
| DropTargetBeforeRename | If an existing collection matches the new name, drop it before the rename.   Pass 1 to drop or 0 to not drop and return an error in case of a name collision. Default is 0. | 0 | Optional |

### Result

Returns OK or error.

### Description

This function is a helper to rename an existing collection on a MongoDB server.  
The name of the collection will also be updated internally so it is safe to continue using this collection after the rename. Additional operations will occur on renamed collection.  
### See also

- [MongoDB.Release](MongoDBRelease.md)

### Release notes

- **Version 12.4**
    - Added [MongoDB.FindIndexes](https://www.mbsplugins.eu/MongoDBFindIndexes.shtml) and [MongoDB.Rename](https://www.mbsplugins.eu/MongoDBRename.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin 12.4](https://www.mbsplugins.de/archive/2022-09-27/MBS_FileMaker_Plugin_124/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 12.4 für Claris FileMaker](https://www.mbsplugins.de/archive/2022-09-06/Neues_MBS_Plugin_124_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 12.4 for Claris FileMaker](https://www.mbsplugins.de/archive/2022-09-06/MBS_Plugin_124_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.4pr1](https://www.mbsplugins.de/archive/2022-08-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 27th July 2022 , last changed 27th July 2022

  
[MongoDB.ReleaseAll](MongoDBReleaseAll.md) - [MongoDB.ReplaceOne](MongoDBReplaceOne.md)

[HTML Version](MongoDBRename.shtml)