• mongoDB之Pipeline Aggregation Stages


    原文链接:https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/

    管道聚合

    $project Reshapes each document in the stream, such as by adding new fields or removing existing fields. For each input document, outputs one document.

    修改文件的输入或输出流,例如增加新的字段,或者删除已存在的字段。

    $match  Filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage. $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match).

    过滤文件流,但不改变文件流中的字段。

    $redact Reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves. Incorporates the functionality of $project and $match. Can be used to implement field level redaction. For each input document, outputs either one or zero documents.

    The argument can be any valid expression as long as it resolves to $$DESCEND$$PRUNE, or $$KEEP system variables. For more information on expressions, see Expressions.

    支持表达式方式的过滤,很重要的功能。

    $limit  Passes the first n documents unmodified to the pipeline where n is the specified limit. For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents).

    限制传入到下一个阶段的字段个数。

    $skip  Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first ndocuments).

    $unwind Deconstructs an array field from the input documents to output a document for eachelement. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array.

     对某个字段组进行分组,分成多个元素。

    $group Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group. Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields.

    根据group分组的表达形式,对于输入的字段进行处理,并规定的group的组的规则输出。

    $sort  Reorders the document stream by a specified sort key. Only the order changes; the documents remain unmodified. For each input document, outputs one document.

    $geoNear Returns an ordered stream of documents based on the proximity to a geospatial point. Incorporates the functionality of $match$sort, and $limit for geospatial data. The output documents include an additional distance field and can include a location identifier field.

    $lookup Performs a left outer join to another collection in the same database to filter in documents from the “joined” collection for processing.

    $out  Writes the resulting documents of the aggregation pipeline to a collection. To use the $out stage, it must be the last stage in the pipeline.

    $indexStats Returns statistics regarding the use of each index for the collection.

  • 相关阅读:
    react实现转盘动画
    a标签做锚点定位,有部分内容被置顶头部遮挡的解决方法
    react复制文案到剪切板
    MySQL Windows安装配置
    Qt编译MySQL驱动
    P8375 [APIO2022] 游戏 解题报告
    CF1687E Become Big For Me 出题报告
    解决 windows 10 WSL 安装Ubuntu后 屏幕亮度飙至最高 且屏幕亮度无法调节 外接显示器无法显示 的问题
    Dubbo3 源码系列 Dubbo“纠葛”(入门篇)
    windows监控进程死亡并拉起
  • 原文地址:https://www.cnblogs.com/passion-hzhang/p/6052423.html
Copyright © 2020-2023  润新知