@@ -1282,18 +1282,43 @@ document::value operation_runner::_run_create_collection(document::view operatio
1282
1282
auto arguments = operation[" arguments" ].get_document ().value ;
1283
1283
auto collection_name = arguments[" collection" ].get_string ().value ;
1284
1284
auto session = _lookup_session (arguments);
1285
+
1286
+ std::cerr << " CREATE COLLECTION: " << bsoncxx::to_json (operation) << std::endl;
1285
1287
if (session) {
1286
1288
_db->create_collection (*session, collection_name);
1287
1289
} else if (arguments.find (" encryptedFields" ) != arguments.end ()) {
1288
1290
auto encrypted_fields = arguments[" encryptedFields" ].get_document ().value ;
1289
1291
auto encrypted_fields_map = make_document (kvp (" encryptedFields" , encrypted_fields));
1290
1292
_db->create_collection (collection_name, std::move (encrypted_fields_map));
1293
+ std::cerr << " CREATED COLLECTION WITH ENCRYPTED FIELDS" << std::endl;
1291
1294
} else {
1292
1295
_db->create_collection (collection_name);
1293
1296
}
1294
1297
return empty_document;
1295
1298
}
1296
1299
1300
+ document::value operation_runner::_run_drop_collection (document::view operation) {
1301
+ using bsoncxx::builder::basic::make_document;
1302
+ using bsoncxx::builder::basic::kvp;
1303
+
1304
+ bsoncxx::document::value empty_document ({});
1305
+
1306
+ auto arguments = operation[" arguments" ].get_document ().value ;
1307
+
1308
+ std::cerr << " DROP COLLECTION: " << bsoncxx::to_json (operation) << std::endl;
1309
+ auto collection_name = operation[" arguments" ][" collection" ].get_string ().value ;
1310
+
1311
+ if (arguments.find (" encryptedFields" ) != arguments.end ()) {
1312
+ auto encrypted_fields = arguments[" encryptedFields" ].get_document ().value ;
1313
+ auto encrypted_fields_map = make_document (kvp (" encryptedFields" , encrypted_fields));
1314
+ _db->collection (collection_name).drop (std::move (encrypted_fields_map));
1315
+ std::cerr << " CREATED COLLECTION WITH ENCRYPTED FIELDS" << std::endl;
1316
+ } else {
1317
+ _db->collection (collection_name).drop ();
1318
+ }
1319
+ return empty_document;
1320
+ }
1321
+
1297
1322
operation_runner::operation_runner (collection* coll) : operation_runner(nullptr , coll) {}
1298
1323
operation_runner::operation_runner (database* db,
1299
1324
collection* coll,
@@ -1387,9 +1412,7 @@ document::value operation_runner::run(document::view operation) {
1387
1412
_coll->drop ();
1388
1413
return empty_document;
1389
1414
} else if (key.compare (" dropCollection" ) == 0 ) {
1390
- auto collection_name = operation[" arguments" ][" collection" ].get_string ().value ;
1391
- _db->collection (collection_name).drop ();
1392
- return empty_document;
1415
+ return _run_drop_collection (operation);
1393
1416
} else if (key.compare (" listCollectionNames" ) == 0 ) {
1394
1417
_db->list_collection_names ();
1395
1418
return empty_document;
0 commit comments