我想删除除列表之外的所有Collection .
db.getCollectionNames().forEach(function(n){db[n].remove({})});
将删除所有集合.
db.getCollectionNames().filter(function(collection){return! /^((keepthisone)|(andthisone)|(alsokeepthisone))$/.test(collection)});
我会列出所有的Collection ,除了我想保留的那些.
我如何将这两者结合起来?
db.getCollectionNames().filter(function(collection){return! /^((keepthisone)|(andthisone)|(alsokeepthisone))$/.test(collection)}).forEach(function(n){db[n].remove({})});
什么都不做.