2012-10-18 11 views
9

おっと。私は誤ってMongoDBのコレクション "stats"に名前を付けて、名前を変更できません

私はmongooseを使用し、誤ってコレクション "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 

答えて

12

てみデシベルの[ "統計"]。見つけ()とDB [ "統計"]。renameCollection( 'statssnapshots')。

また、db.getCollection( "stats")。find()を実行することもできます。

+1

db.getCollection()は私が必要としていたものです。ありがとう! ["stats"]は機能しませんでした。 –

+0

wowはmongoでこの種の問題に遭遇するとは思わなかった。奇妙な彼らはこのメソッドをdbに置く。 db ["stats"]を削除してください。これはstats関数のビルドのみを参照するためです。 –

関連する問題