Skip to content

Commit

Permalink
✨ Add method to iterate on collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Naimi committed Feb 12, 2020
1 parent d35bf1a commit 615e639
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ class MongoScriptAction(

fun onCollection(databaseName: String, collectionName: String) =
mongoClient.getDatabase(databaseName).getCollection(collectionName)


fun onCollections(databaseNameRegex: Regex, collectionName: String) =
mongoClient.listDatabaseNames().filter { it.matches(databaseNameRegex) }.map {
mongoClient.getDatabase(it).getCollection(collectionName)
}
}

0 comments on commit 615e639

Please sign in to comment.