定义
参数
$indexName: 细绳|MongoDB\Model\IndexInfo- 要删除的索引的名称或模型对象。 使用
MongoDB\Collection::listIndexes()方法查看集合上的现有索引。 $options: array指定所需选项的数组。
名称类型说明comment
混合
maxTimeMS
整型
处理游标操作的累计时间限制(以毫秒为单位)。MongoDB 最早会在中断点之后中止操作。
1.3版本新增。
会话
与操作相关联的客户端会话。
1.3版本新增。
writeConcern
错误/异常
MongoDB\Exception\UnsupportedException,如果所选服务器使用了选项但不支持选项(例如collation、readConcern、writeConcern)。
MongoDB\Exception\InvalidArgumentException 用于与参数或选项解析相关的错误。
MongoDB\ 驱动程序\Exception\RuntimeException 用于扩展级别的其他错误(例如连接错误)。
例子
以下操作从数据库test的collectionrestaurants中删除名为borough_1的索引:
$collection = (new MongoDB\Client)->test->restaurants;
$collection->dropIndex('borough_1');另请参阅
MongoDB手册中的dropIndexes命令参考
MongoDB 手册中的索引文档