I have a history collection in MongoDB. I want to be able to save List of object in a single insertion. How can I do that?
For example, I have a repository as below
@Repository
public interface HistoryRepository extends MongoRepository<History, ObjectId>{
}
List myHistories = ArrayList…
When I try to save with HistoryRepository.saveAll(myHistories)
, it saves the list one by one. I want to know if there is a way to save myHistories
with a single insertion command.
As I can see it’s possible in MongoDB docs but I couldn’t figure out with Java