mongosh 'mongodb+srv://YOUR_MONGODB_ATLAS_URL.mongodb.net/' --apiVersion 1 --username YOUR_ADMIN_USERNAME
> Enter password:
(enter password)
db.getCollectionNames().forEach((collection_name) => {
if (collection_name.indexOf("system.") > -1) {
return;
}
print("\n----------------------------------------");
print(["COLLECTION:", collection_name].join('\n'));
print(
[" Removing ", db[collection_name].count({}), " documents …"].join("")
);
db[collection_name].remove({});
print([" Count: ", db[collection_name].count({}), " documents"].join(""));
print("----------------------------------------\n");
});