setAll

suspend fun <T : Model> setAll(collection: MongoCollection<T>, serializer: KSerializer<T>, cacheKey: String = collection.cacheKey(), setData: suspend MongoCollection<T>.() -> List<T>?): Boolean

Insert or update multiple items in your db and return the updated items. This will update their data in the cache buy their id

val db = mongoClient.getDatabase("kacheController")
val usersCollection = db.getCollection<User>("users")
val users = listOf(
User(firstName = "Funyin", lastName = "Kashimawo"),
User(firstName = "John", lastName = "Norris"),
User(firstName = "Tyler", lastName = "Chidubem"),
)
controller.setAll(collection = usersCollection, User.serializer()) {
if (insertMany(users).wasAcknowledged())
users
else
emptyList()
}