skip to content
Alvin Lucillo

Deleting from multiple collections

/ 1 min read

In mongosh, you can delete from multiple collections with by iterating an array, just like the previous journal’s query example:

["collection1", "collection2", "collection3", "collection4"].forEach((c) =>
	db.getCollection(c).deleteMany({}),
);