• <small id='6xB2p'></small><noframes id='6xB2p'>

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

      1. <tfoot id='6xB2p'></tfoot>
        • <bdo id='6xB2p'></bdo><ul id='6xB2p'></ul>

      2. <legend id='6xB2p'><style id='6xB2p'><dir id='6xB2p'><q id='6xB2p'></q></dir></style></legend>

        MongoDB计算不同的价值?

        MongoDB count distinct value?(MongoDB计算不同的价值?)

          <legend id='IATNx'><style id='IATNx'><dir id='IATNx'><q id='IATNx'></q></dir></style></legend>

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

            <tfoot id='IATNx'></tfoot>
            <i id='IATNx'><tr id='IATNx'><dt id='IATNx'><q id='IATNx'><span id='IATNx'><b id='IATNx'><form id='IATNx'><ins id='IATNx'></ins><ul id='IATNx'></ul><sub id='IATNx'></sub></form><legend id='IATNx'></legend><bdo id='IATNx'><pre id='IATNx'><center id='IATNx'></center></pre></bdo></b><th id='IATNx'></th></span></q></dt></tr></i><div id='IATNx'><tfoot id='IATNx'></tfoot><dl id='IATNx'><fieldset id='IATNx'></fieldset></dl></div>
                • <bdo id='IATNx'></bdo><ul id='IATNx'></ul>
                    <tbody id='IATNx'></tbody>

                • 本文介绍了MongoDB计算不同的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  下面显示我的代码.我必须计算重复的不同值的次数.在这里,我在结果"中存储了不同的值.我使用 collection.count() 来计算,但它不起作用.请任何人告诉我我必须在哪里出错.非常感谢.

                  Here below show my code. I have to calculate the how many times distinct value repeated. Here i have store distinct value in "results".I used collection.count() to calculate but it's not work. please any one tell me where i have to mistake. Thank you very much .

                  var DistinctIntoSingleDB = function(Collection,arr,opt,distVal,callback){
                   Collection.find({}).distinct(distVal, function(err, results) {
                        if(!err && results){
                              console.log("Distinct Row Length :", results.length);
                              var a,arr1 = [];
                              for(var j=0; j<results.length; j++){
                                  collection.count({'V6': results[j]}, function(err, count) {
                                        console.log(count)
                                  });
                  
                                  arr1.push(results[j]+ " : " +a);
                              }
                              callback(results,arr1);
                        }else{
                             console.log(err, results);
                             callback(results);
                        }
                   });
                  

                  推荐答案

                  在集合 'col1' 上获取字段 'field1' 的不同值并写入单独的集合 'distinctCount'.如果集合很大,也允许使用磁盘空间.

                  To get occurrences of distinct values of a field 'field1' on a collection 'col1' and write to a separate collection 'distinctCount'. Also allow to use disk space in case the collection is huge.

                  db.col1.aggregate(
                            [{$group: {
                                _id: "$field1",
                                count: { $sum : 1 }
                              }}, {
                              $group: {
                                _id: "$_id",
                                count: { $sum : "$count" }
                              }},{
                                $out: "distinctCount"
                              }],
                           {allowDiskUse:true}
                  )
                  

                  这篇关于MongoDB计算不同的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))
                • <tfoot id='oqI2l'></tfoot>

                      <tbody id='oqI2l'></tbody>

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

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