久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <i id='Mqss7'><tr id='Mqss7'><dt id='Mqss7'><q id='Mqss7'><span id='Mqss7'><b id='Mqss7'><form id='Mqss7'><ins id='Mqss7'></ins><ul id='Mqss7'></ul><sub id='Mqss7'></sub></form><legend id='Mqss7'></legend><bdo id='Mqss7'><pre id='Mqss7'><center id='Mqss7'></center></pre></bdo></b><th id='Mqss7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Mqss7'><tfoot id='Mqss7'></tfoot><dl id='Mqss7'><fieldset id='Mqss7'></fieldset></dl></div>

      • <bdo id='Mqss7'></bdo><ul id='Mqss7'></ul>
      <tfoot id='Mqss7'></tfoot>

        <small id='Mqss7'></small><noframes id='Mqss7'>

        <legend id='Mqss7'><style id='Mqss7'><dir id='Mqss7'><q id='Mqss7'></q></dir></style></legend>
      1. 如何在 Mongoose 排序結(jié)束時(shí)保持空值?

        How to keep null values at the end of sorting in Mongoose?(如何在 Mongoose 排序結(jié)束時(shí)保持空值?)
          1. <tfoot id='d5Neg'></tfoot>

              <tbody id='d5Neg'></tbody>

            <small id='d5Neg'></small><noframes id='d5Neg'>

              <i id='d5Neg'><tr id='d5Neg'><dt id='d5Neg'><q id='d5Neg'><span id='d5Neg'><b id='d5Neg'><form id='d5Neg'><ins id='d5Neg'></ins><ul id='d5Neg'></ul><sub id='d5Neg'></sub></form><legend id='d5Neg'></legend><bdo id='d5Neg'><pre id='d5Neg'><center id='d5Neg'></center></pre></bdo></b><th id='d5Neg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='d5Neg'><tfoot id='d5Neg'></tfoot><dl id='d5Neg'><fieldset id='d5Neg'></fieldset></dl></div>
                <bdo id='d5Neg'></bdo><ul id='d5Neg'></ul>
                • <legend id='d5Neg'><style id='d5Neg'><dir id='d5Neg'><q id='d5Neg'></q></dir></style></legend>

                • 本文介紹了如何在 Mongoose 排序結(jié)束時(shí)保持空值?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在查詢一個(gè)集合并根據(jù)一個(gè)屬性對結(jié)果進(jìn)行排序.有些文檔還沒有該屬性值,即 null.在排序和限制(asc 或 desc)之后,我想在結(jié)果末尾保留具有空值的文檔.Mongoose 中是否有一種簡單的方法可以使用單個(gè)查詢來做到這一點(diǎn)?如果沒有,我如何分別使用兩個(gè)查詢,因?yàn)槲冶仨毾拗平Y(jié)果以及分頁?

                  I am querying a collection and sorting results based on a property. Some documents don't the that property value yet i.e. null. I want to keep the documents with null values at the end of the results after sorting and limiting (asc or desc). Is there a simple way in Mongoose to do that using a single query? If not, how can I use two queries separately since I have to limit the results as well for pagination?

                  var dealSchema = new Schema({
                  
                      // For Presentation Purposes Only
                      dealId: { type: Number, index: true, unique: true },
                  
                      // BRAND Info
                      brand: { type: ObjectId, ref: 'brand', index: true },
                      brandUser: { type: ObjectId, ref: 'user', index: true, required: true },
                      campaign: { type: ObjectId, ref: 'campaign', index: true },
                  
                      metrics: {
                          totalCost: Number,
                          totalValue: Number,
                          roi: { type: Number, index: true },
                          cpe: { type: Number, index: true }
                      }
                  
                  })
                  

                  我想根據(jù)metrics.cpe"按升序排序,但希望 null 或 0 值位于列表末尾.示例:

                  I want to sort based on 'metrics.cpe' in ascending order, but want null or 0 values to be at the end of the list. Example:

                  [0.1, 0.4, 0.7, 1.5, 2.5, 0, 0, null, null]
                  

                  示例文檔

                  {
                    "_id": "590cdf29c102ae31208fa43a",
                    "campaign": "587e6a880c844c6c2ea01563",
                    "brand": "5a4cff5f8eaa1c26ca194acc",
                    "brandUser": "57fd30cf0df04f1100153e07",
                    "metrics": {
                      "roi": 0,
                      "cpe": 0,
                      "totalValue": 0,
                      "totalCost": 6000
                    }
                  }
                  

                  推薦答案

                  我不確定我要說的解決方案.我無法測試這一點(diǎn),因?yàn)槲椰F(xiàn)在沒有設(shè)置 mongo db,但我認(rèn)為你可以使用 <collection>.aggregate 以及 $project$sort 來實(shí)現(xiàn)這一點(diǎn).

                  Am not sure about the solution am about to say. I cant test this out as I dont have a mongo db set right now, but I think that you can use <collection>.aggregate along with $project and $sort to achieve this.

                  示例代碼:

                  db.inventory.aggregate(
                     [
                        {
                           $project: {
                              item: 1,
                              description: { $ifNull: [ "$amount", -1*(<mimimum value>)* ] }
                           }
                        },
                        { 
                           $sort : { 
                             amount : (-1 or 1 depending on the order you want)
                           }
                        }
                     ]
                  )
                  

                  希望對你有幫助!!

                  這篇關(guān)于如何在 Mongoose 排序結(jié)束時(shí)保持空值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項(xiàng)目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數(shù)據(jù)更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動(dòng)態(tài)元素 - Angular 2 amp;離子2)
                      <i id='qE3QQ'><tr id='qE3QQ'><dt id='qE3QQ'><q id='qE3QQ'><span id='qE3QQ'><b id='qE3QQ'><form id='qE3QQ'><ins id='qE3QQ'></ins><ul id='qE3QQ'></ul><sub id='qE3QQ'></sub></form><legend id='qE3QQ'></legend><bdo id='qE3QQ'><pre id='qE3QQ'><center id='qE3QQ'></center></pre></bdo></b><th id='qE3QQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qE3QQ'><tfoot id='qE3QQ'></tfoot><dl id='qE3QQ'><fieldset id='qE3QQ'></fieldset></dl></div>

                        <small id='qE3QQ'></small><noframes id='qE3QQ'>

                        <legend id='qE3QQ'><style id='qE3QQ'><dir id='qE3QQ'><q id='qE3QQ'></q></dir></style></legend>
                        • <bdo id='qE3QQ'></bdo><ul id='qE3QQ'></ul>
                            <tbody id='qE3QQ'></tbody>
                          <tfoot id='qE3QQ'></tfoot>

                            主站蜘蛛池模板: 亚洲精品国产第一综合99久久 | 国产区精品在线观看 | 毛片.com | 成人字幕网zmw | www.日韩| 国产成人99久久亚洲综合精品 | 日韩在线国产 | 亚州激情| 亚洲国产69 | 久久精品免费看 | 国产高清免费在线 | 国产高清精品一区二区三区 | 欧美激情第一区 | 超黄视频网站 | 久久久九九 | 中文字幕动漫成人 | 中文字幕成人av | 视频在线一区 | 国产精品成人一区二区 | 免费一区 | 日韩欧美三区 | 免费黄色日本 | 一级二级三级黄色 | 亚洲精品一二区 | 欧美精品99 | 欧美中文视频 | 日本不卡免费新一二三区 | 亚洲电影在线播放 | 国产福利在线播放 | 干干干日日日 | 欧美综合久久 | 精品电影 | 韩三级在线观看 | 亚洲精品乱码久久久久久黑人 | 欧美日韩国产在线观看 | 国产小视频自拍 | 在线观看一区 | 国产乱码精品1区2区3区 | 日韩电影中文字幕在线观看 | 亚洲精品电影 | 国产精品成人国产乱一区 |