I am very new to MongoDB. Trying to understand the best option to perform Bulk Write in MongoDB. I want to periodically refresh my Application collection. The key's for documents are AppID, AppName and AppStatus. Below are the actions I want to perform in every run -
- Find the AppID in Application collection.
- If not exists, perform an insert
- If exists, only update the value of AppStatus key.
List<Application> applist = getAppList(); // List contains All the Application private final MongoClient mongoClient; private final MongoTemplate mongoTemplate; MongoCollection<Document> collection = mongoTemplate.getDb().getCollection("Application"); collection.bulkWrite (????);
How do I loop over the appList and perform a bulk insert/update ?