Skip to content

Commit

Permalink
Add method to iterate on collections using regex
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeNaimi authored Feb 12, 2020
2 parents 41acb47 + 615e639 commit f026b8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ config {
email = "richard.capraro@saagie.com"
roles = listOf("developer")
}
person {
id = "guillaume"
name = "Guillaume Naimi"
email = "guillaume.naimi@saagie.com"
roles = listOf("developer")
}
}

bintray {
Expand Down
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 f026b8a

Please sign in to comment.