[GODRIVER-892] Is there a way to rename a collection ? Created: 21/Mar/19 Updated: 11/Sep/19 Resolved: 21/Mar/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Administrative Commands, API, Command & Dispatch, Documentation |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Romain Masclef | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | renameCollection | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
I'm not sure but it seems that there is no actual way to rename a collection nor run an admin command. `db.getCollection('my-col').renameCollection("my-col-renamed")` )` I can't find any `RunAdminCommand` in the Go-Driver code. Can someone confirm that this feature is not available yet ? |
| Comments |
| Comment by Romain Masclef [ 26/Mar/19 ] |
|
Hi @ian.whalen, I already tried to rename a collection through the `runCommand` but did not get to make it work as the mongodb command looks like this `db.adminCommand( { renameCollection: "test.orders", to: "test.orders2014" })`. Have you got any example to show me ? |
| Comment by Ian Whalen (Inactive) [ 21/Mar/19 ] |
|
Hey rmasclef you can just use database.runCommand() to rename collections, but we do not have a dedicated admin command or renameCollection helper. |