collection的名字是foo,我想改成 post 同时,将url改成site,由于collection很多这样的document,不知道怎样进行批量更新,有方法吗?
foo
post
url
site
{ '_id': ObjectId() 'url': '' }
人生最曼妙的风景,竟是内心的淡定与从容!
collection renameddb.foo.rename('post');
db.foo.rename('post');
Field rename
db.post.update({$rename:{url:'site'}});
collection renamed db.foo.renameCollection('post')
db.foo.renameCollection('post');
collection renamed
db.foo.rename('post');
Field rename
db.post.update({$rename:{url:'site'}});
collection renamed
db.foo.renameCollection('post')