<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 聚合 > 譯者:[飛龍](https://github.com/wizardforcel) > 來源:[Aggregation](https://github.com/dresende/node-orm2/wiki/Aggregation) 如果你需要從一個模型中獲取一些聚合值,你可以使用`Model.aggregate()`。下面通過一個例子來展示: ``` Person.aggregate({ surname: "Doe" }).min("age").max("age").get(function (err, min, max) { console.log("The youngest Doe guy has %d years, while the oldest is %d", min, max); }); ``` 可以傳遞一個含有屬性的`Array`來選擇僅僅保留一小部分屬性。方法也會接收一個`Object`來定義條件。 下面是一個展示如何使用`.groupBy()`的例子: ``` // 和 "select avg(weight), age from person where country='someCountry' group by age;" 相同 Person.aggregate(["age"], { country: "someCountry" }).avg("weight").groupBy("age").get(function (err, stats) { // stats 是一個數組,每個記錄都有 'age' 和 'avg_weight' 屬性 }); ``` ## 基本的 `.aggregate()` 方法 + `limit()`:你可以傳遞一個數值作為個數,或者兩個數值分別作為偏移和個數 + `order()`:和`Model.find().order()`相同 ## 額外的 `.aggregate()` 方法 + `min` + `max` + `avg` + `sum` + `count`(它有一個快捷方式 - `Model.count`) 有更多的聚合函數是依賴于驅動的(比如數學函數)。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看