|
57 | 57 | import com.mongodb.client.model.DeleteManyModel;
|
58 | 58 | import com.mongodb.client.model.DeleteOneModel;
|
59 | 59 | import com.mongodb.client.model.DeleteOptions;
|
| 60 | +import com.mongodb.client.model.DropCollectionOptions; |
60 | 61 | import com.mongodb.client.model.DropIndexOptions;
|
61 | 62 | import com.mongodb.client.model.EstimatedDocumentCountOptions;
|
62 | 63 | import com.mongodb.client.model.FindOneAndDeleteOptions;
|
|
77 | 78 | import com.mongodb.client.model.UpdateManyModel;
|
78 | 79 | import com.mongodb.client.model.UpdateOneModel;
|
79 | 80 | import com.mongodb.client.model.UpdateOptions;
|
| 81 | +import com.mongodb.client.model.ValidationOptions; |
80 | 82 | import com.mongodb.client.model.WriteModel;
|
81 | 83 | import com.mongodb.client.model.bulk.ClientBulkWriteOptions;
|
82 | 84 | import com.mongodb.client.model.bulk.ClientBulkWriteResult;
|
@@ -1364,12 +1366,21 @@ public OperationResult executeDropCollection(final BsonDocument operation) {
|
1364 | 1366 | BsonDocument arguments = operation.getDocument("arguments", new BsonDocument());
|
1365 | 1367 | String collectionName = arguments.getString("collection").getValue();
|
1366 | 1368 |
|
1367 |
| - if (operation.getDocument("arguments").size() > 1) { |
1368 |
| - throw new UnsupportedOperationException("Unexpected arguments " + operation.get("arguments")); |
| 1369 | + DropCollectionOptions dropCollectionOptions = new DropCollectionOptions(); |
| 1370 | + for (Map.Entry<String, BsonValue> entry : arguments.entrySet()) { |
| 1371 | + switch (entry.getKey()) { |
| 1372 | + case "collection": |
| 1373 | + break; |
| 1374 | + case "encryptedFields": |
| 1375 | + dropCollectionOptions.encryptedFields(entry.getValue().asDocument()); |
| 1376 | + break; |
| 1377 | + default: |
| 1378 | + throw new UnsupportedOperationException("Unsupported drop collections option: " + entry.getKey()); |
| 1379 | + } |
1369 | 1380 | }
|
1370 | 1381 |
|
1371 | 1382 | return resultOf(() -> {
|
1372 |
| - database.getCollection(collectionName).drop(); |
| 1383 | + database.getCollection(collectionName).drop(dropCollectionOptions); |
1373 | 1384 | return null;
|
1374 | 1385 | });
|
1375 | 1386 | }
|
@@ -1429,6 +1440,11 @@ public OperationResult executeCreateCollection(final BsonDocument operation) {
|
1429 | 1440 | case "clusteredIndex":
|
1430 | 1441 | options.clusteredIndexOptions(createClusteredIndexOptions(cur.getValue().asDocument()));
|
1431 | 1442 | break;
|
| 1443 | + case "validator": |
| 1444 | + ValidationOptions validationOptions = new ValidationOptions(); |
| 1445 | + validationOptions.validator(cur.getValue().asDocument()); |
| 1446 | + options.validationOptions(validationOptions); |
| 1447 | + break; |
1432 | 1448 | default:
|
1433 | 1449 | throw new UnsupportedOperationException("Unsupported argument: " + cur.getKey());
|
1434 | 1450 | }
|
|
0 commit comments