我无意中将一个收藏命名为“收藏”;统计数据“;在MongoDB中,现在无法重命名它

我无意中将一个收藏命名为“收藏”;统计数据“;在MongoDB中,现在无法重命名它,mongodb,Mongodb,哎呀 我使用猫鼬,无意中创建了一个集合“stats”。 直到几周后我才意识到这将是一个问题,所以我现在需要重命名(而不仅仅是删除)集合 然而,我的尝试遇到了一个可预见的问题: PRIMARY> db.stats.find(); Thu Oct 18 10:39:43 TypeError: db.stats.find is not a function (shell):1 PRIMARY> db.stats.renameCollection('statssnapshots'); Thu

哎呀

我使用猫鼬,无意中创建了一个集合“stats”。 直到几周后我才意识到这将是一个问题,所以我现在需要重命名(而不仅仅是删除)集合

然而,我的尝试遇到了一个可预见的问题:

PRIMARY> db.stats.find();
Thu Oct 18 10:39:43 TypeError: db.stats.find is not a function (shell):1
PRIMARY> db.stats.renameCollection('statssnapshots');
Thu Oct 18 10:39:45 TypeError: db.stats.renameCollection is not a function (shell):1
试一试

你也可以这样做

db.getCollection("stats").find().

db.getCollection()是我需要的,谢谢![“stats”]不起作用。哇,没想到我会在mongo遇到这样的问题。奇怪的是,他们把这种方法放在db上。请删除db[“stats”],因为它只引用内置的stats函数。
db["stats"].renameCollection('statssnapshots').
db.getCollection("stats").find().