MongoDB
Get all the collecitons with this prefix¶
const prefix = 'ticket';
const matchingCollections = db.getCollectionInfos({
name: {
$regex: '^' + prefix
}
});
matchingCollections.forEach(collection => {
print(collection.name);
});
Get all the collecitons with this prefix, along with docs count¶
var prefix = 'ticket';
db.getCollectionInfos({ name: { $regex: '^' + prefix } }).forEach(function (c) {
var cnt = db.getCollection(c.name).countDocuments();
print(c.name + ": " + cnt);
});
substring check