@@ -340,11 +340,17 @@ public function distinct($fieldName, $filter = [], array $options = [])
340
340
/**
341
341
* Drop this collection.
342
342
*
343
- * @return object Command result document
343
+ * @see DropCollection::__construct() for supported options
344
+ * @param array $options Additional options
345
+ * @return array|object Command result document
344
346
*/
345
- public function drop ()
347
+ public function drop (array $ options = [] )
346
348
{
347
- $ operation = new DropCollection ($ this ->databaseName , $ this ->collectionName );
349
+ if ( ! isset ($ options ['typeMap ' ])) {
350
+ $ options ['typeMap ' ] = $ this ->typeMap ;
351
+ }
352
+
353
+ $ operation = new DropCollection ($ this ->databaseName , $ this ->collectionName , $ options );
348
354
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
349
355
350
356
return $ operation ->execute ($ server );
@@ -353,19 +359,25 @@ public function drop()
353
359
/**
354
360
* Drop a single index in the collection.
355
361
*
362
+ * @see DropIndexes::__construct() for supported options
356
363
* @param string $indexName Index name
357
- * @return object Command result document
364
+ * @param array $options Additional options
365
+ * @return array|object Command result document
358
366
* @throws InvalidArgumentException if $indexName is an empty string or "*"
359
367
*/
360
- public function dropIndex ($ indexName )
368
+ public function dropIndex ($ indexName, array $ options = [] )
361
369
{
362
370
$ indexName = (string ) $ indexName ;
363
371
364
372
if ($ indexName === '* ' ) {
365
373
throw new InvalidArgumentException ('dropIndexes() must be used to drop multiple indexes ' );
366
374
}
367
375
368
- $ operation = new DropIndexes ($ this ->databaseName , $ this ->collectionName , $ indexName );
376
+ if ( ! isset ($ options ['typeMap ' ])) {
377
+ $ options ['typeMap ' ] = $ this ->typeMap ;
378
+ }
379
+
380
+ $ operation = new DropIndexes ($ this ->databaseName , $ this ->collectionName , $ indexName , $ options );
369
381
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
370
382
371
383
return $ operation ->execute ($ server );
@@ -374,11 +386,17 @@ public function dropIndex($indexName)
374
386
/**
375
387
* Drop all indexes in the collection.
376
388
*
377
- * @return object Command result document
389
+ * @see DropIndexes::__construct() for supported options
390
+ * @param array $options Additional options
391
+ * @return array|object Command result document
378
392
*/
379
- public function dropIndexes ()
393
+ public function dropIndexes (array $ options = [] )
380
394
{
381
- $ operation = new DropIndexes ($ this ->databaseName , $ this ->collectionName , '* ' );
395
+ if ( ! isset ($ options ['typeMap ' ])) {
396
+ $ options ['typeMap ' ] = $ this ->typeMap ;
397
+ }
398
+
399
+ $ operation = new DropIndexes ($ this ->databaseName , $ this ->collectionName , '* ' , $ options );
382
400
$ server = $ this ->manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
383
401
384
402
return $ operation ->execute ($ server );
0 commit comments