参考 > 参考 > 经营者 > 查询修饰符 > $ returnKey
$returnKey
从v3.2开始不推荐使用
从v3.2开始,shell中$returnKey不推荐使用该运算符 mongo。在mongo外壳中,cursor.returnKey()改用。
mongo
cursor.returnKey()
只返回索引字段或查询结果的字段。如果 $returnKey设置为true,并且查询不使用索引执行读取操作,则返回的文档将不包含任何字段。使用以下形式之一:
true
db.collection.find( { <query> } )._addSpecial( "$returnKey", true ) db.collection.find( { $query: { <query> }, $returnKey: true } )