关于 SequoiaDB
快速入门
安装
基本操作
数据模型
SQL引擎
S3引擎
系统架构
数据库管理
连接器
驱动
参考手册
故障排除
SAC 管控中心
Web服务
版本信息
getIndex - 获取指定索引
db.collectionspace.collection.getIndex(<name>)
Collection
该函数用于获取当前集合中指定的索引信息。
被指定的索引名。
Note:
- 索引名不能是空串,含点(.)或者美元符号($),且长度不超过127B。
函数执行成功时,返回类型为 BSONObj 的索引信息。
函数执行失败时,将抛异常并输出错误信息。
getIndex()
函数常见异常如下:
错误码 | 错误名 | 可能发生的原因 | 解决办法 |
---|---|---|---|
-47 | SDB_IXM_NOTEXIST | 索引不存在 | 检查索引是否存在 |
当异常抛出时,可以通过 getLastErrMsg() 获取错误信息或通过 getLastError() 获取错误码。更多错误处理可以参考常见错误处理指南。
v1.10 及以上版本
> db.sample.employee.getIndex( "ageIndex" )
结果如下:
{ "IndexDef": { "name": "ageIndex", "_id": { "$oid": "5f4f3b938f5a48a0c3a5f3ad" }, "key": { "age": 1 }, "v": 0, "unique": true, "dropDups": false, "enforced": false, "NotNull": false, "NotArray": false }, "IndexFlag": "Normal", "Type": "Positive" }