Filter a list inside forEach function of another list - Kotlin
val userChoiceCategories = recommendedCategoryDb.find(RecommendedCategory::userId eq userId).toList()
val categoriesToOmit = userChoiceCategories.map { it.category.name }.toSet()
return articleDb.find().toList().filter { !categoriesToOmit.contains(it.category) }
and in more conciese form:
return recommendedCategoryDb
.find(RecommendedCategory::userId eq userId).toList()
.map { it.category.name }.toSet()
.let { toOmit ->
articleDb
.find().toList()
.filter { article -> article.category !in toOmit }
}