Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 从索引mongod中删除单个字段_Database_Mongodb_Mongoose_Mongodb Query - Fatal编程技术网

Database 从索引mongod中删除单个字段

Database 从索引mongod中删除单个字段,database,mongodb,mongoose,mongodb-query,Database,Mongodb,Mongoose,Mongodb Query,我无法从索引中删除单个字段 db.customer.getIndexes() 我正在尝试从上面删除“unique”:是的,,请帮助我 db.customer.update( {"name" : "customer_id_1" }, { $unset: { "unique" : true } } ) $unset表达式中的指定值(即“”)不会影响操作 要在嵌入文档或数组中指定,请使用点表示法 行为 如果该字段不存在,则$unset不执行任何操作(即无操作

我无法从索引中删除单个字段

db.customer.getIndexes()

我正在尝试从上面删除“unique”:是的,,请帮助我

   db.customer.update(
       {"name" : "customer_id_1" },
       { $unset: { "unique" : true } }
    )
$unset表达式中的指定值(即“”)不会影响操作

要在嵌入文档或数组中指定,请使用点表示法

行为 如果该字段不存在,则$unset不执行任何操作(即无操作)


与$一起使用以匹配数组元素时,$unset将匹配元素替换为null,而不是从数组中删除匹配元素。此行为保持数组大小和元素位置的一致性。

您好,我已经尝试过,但没有成功,db.customer.update({“name”:“customer\u id\u 1”},{$unset:{“unique”:true});WriterResult({“nMatched”:0,“nUpserted”:0,“nModified”:0}){$unset:{“unique”:true}、{multi:true}或{$unset:{“unique”:1}、{multi:true}——投票方法将修改匹配的文档,而不是OP需要的索引。-####单击链接()。#####:从集合中删除或删除指定的索引。方法提供了dropIndexes命令的包装器。无法删除_id字段上的默认索引。要删除文本索引,请指定索引名称。
   db.customer.update(
       {"name" : "customer_id_1" },
       { $unset: { "unique" : true } }
    )