On this page本页内容
Disambiguation消歧
The following page refers to the update operator 下一页涉及更新运算符$unset
. $unset
。For the aggregation stage 对于MongoDB 4.2中提供的聚合阶段$unset
, available starting in MongoDB 4.2, see $unset
.$unset
,请参阅$unset
。
$unset
¶The $unset
operator deletes a particular field. Consider the following syntax:$unset
运算符删除特定字段。考虑下面的语法:
The specified value in the $unset
expression (i.e. ""
) does not impact the operation.$unset
表达式中的指定值(即""
)不会影响操作。
To specify a 若要在嵌入式文档或数组中指定一个<field>
in an embedded document or in an array, use dot notation.<field>
,请使用点表示法。
If the field does not exist, then 如果该字段不存在,则$unset
does nothing (i.e. no operation).$unset
不执行任何操作(即无操作)。
When used with 与$
to match an array element, $unset
replaces the matching element with null
rather than removing the matching element from the array. $
一起使用以匹配数组元素时,$unset
将匹配元素替换为null
,而不是从数组中删除匹配元素。This behavior keeps consistent the array size and element positions.此行为使数组大小和元素位置保持一致。