MongoDB:查询和投影操作符(参照)

原帖,请参看这里。

官网:https://docs.mongodb.com/manual/reference/operator/query/

这一章节都是很简单的英语,就做一个很简单的备注,如果连这个英语都看不懂,那就需要提高了,程序员看不懂基本的英语是很难提高的。
这一章节还需要完善一些样例,这个有待补充。

查询选择器

比较

名字描述
$eqMatches values that are equal to a specified value.(判断相等)
$gtMatches values that are greater than a specified value.(判断大于)
$gteMatches values that are greater than or equal to a specified value.(判断大于等于)
$inMatches any of the values specified in an array.(判断在其中)
$ltMatches values that are less than a specified value.(判断小于)
$lteMatches values that are less than or equal to a specified value.(判断小于等于)
$neMatches all values that are not equal to a specified value.(判断所有值都不等于指定值)
$ninMatches none of the values specified in an array.(判断不在其中)

逻辑

名字描述
$andJoins query clauses with a logical AND returns all documents that match the conditions of both clauses.(与)
$notInverts the effect of a query expression and returns documents that do not match the query expression.(非)
$norJoins query clauses with a logical NOR returns all documents that fail to match both clauses.(异或)
$orJoins query clauses with a logical OR returns all documents that match the conditions of either clause.(或)

元素

名字描述
$existsMatches documents that have the specified field.
$typeSelects documents if a field is of the specified type.

评估

名字描述
$exprAllows use of aggregation expressions within the query language.
$jsonSchemaValidate documents against the given JSON Schema.
$modPerforms a modulo operation on the value of a field and selects documents with a specified result.
$regexSelects documents where values match a specified regular expression.
$textPerforms text search.
$whereMatches documents that satisfy a JavaScript expression.

地理空间

名字描述
$geoIntersectsSelects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects.
$geoWithinSelects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin.
$nearReturns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near.
$nearSphereReturns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere.

数组

名字描述
$allMatches arrays that contain all elements specified in the query.
$elemMatchSelects documents if element in the array field matches all the specified $elemMatch conditions.
$sizeSelects documents if the array field is a specified size.

位操作

名字描述
$bitsAllClearMatches numeric or binary values in which a set of bit positions all have a value of 0.
$bitsAllSetMatches numeric or binary values in which a set of bit positions all have a value of 1.
$bitsAnyClearMatches numeric or binary values in which any bit from a set of bit positions has a value of 0.
$bitsAnySetMatches numeric or binary values in which any bit from a set of bit positions has a value of 1.

注释

名字描述
$commentAdds a comment to a query predicate.

投影操作

名字描述
$Projects the first element in an array that matches the query condition.
$elemMatchProjects the first element in an array that matches the specified $elemMatch condition.
$metaProjects the document’s score assigned during $text operation.
$sliceLimits the number of elements projected from an array. Supports skip and limit slices.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值