// Update based on a unique identifier (e.g., CSPA, version, layout_name)
Document filter = new Document("CSPA", updatedDoc.getString("CSPA"))
.append("version", updatedDoc.getString("version"))
.append("layout_name", updatedDoc.getString("layout_name"));
// Replace the document if it exists, or insert it if it doesn't
actualCollection.replaceOne(filter, updatedDoc, new ReplaceOptions().upsert(true));
} catch (Exception e) {
e.printStackTrace();
}
private void updateMongoDBCollection(Document updatedDoc) { try (var mongoClient = MongoClients.create(mongoConfig.getUri())) { MongoDatabase database = mongoClient.getDatabase(mongoConfig.getDatabase()); MongoCollection actualCollection = database.getCollection(mongoConfig.getActualCollection());
}