簡體   English   中英

使用Node.js在mongodb中返回多少文檔find()是否有限制

[英]Is there a limit on how many docs find() returns in mongodb using Nodejs

/*     I am trying to read all the docs available in a collection using below command.`enter code here`
            collection.find({}).toArray(function(err, data)***

            I am getting the data returned if i use limit() command but i can goto limit of 101 rows. 
            My collection has 30K rows and i would like to retrieve all 30K rows of Data as per my business need.`enter code here`

            Is there a limit on how many docs we can pull using toArray command?if so, is there an efficient way of this command please?
            /**
             * http://usejsdoc.org/
             */
 */       
        //Declarations
            var json2html = require('node-json2html');
            var MongoClient = require('mongodb').MongoClient;
            var url = 'mongodb://localhost:27017/Narsi30KDB';
            var str = "";
            var data = "";
            var html= "";
         //Service Name   
            exports.alldocs = (function(req, res) {
        //Mongodb Connection    
                MongoClient.connect('mongodb://localhost:27017', function(err, client) {
                    if (err)
                        throw err;
                        var db = client.db('TestDB1');
                    // Get the documents collection
                    var collection = db.collection('TestCollection1');
                    // Find some documents
                    collection.find({}).toArray(function(err, data) {

                //  console.log(data);

var transform = {"<>" : "div", "html" : "${AGENT CODE} ${CHANNEL} ${TRANSACTION TYPE} ${ACTION TYPE} ${CUSTOMER NAME} ${IMEI} ${SIM} ${MOBILE ISD} ${PRODUCT ISD} ${ACTION DATE} ${LIVE DAYS} ${MOBILE} ${NEW MOBILE} ${BAN} ${BILLING MARKET} ${SUBMARKET} ${PRODUCT CODE}" };

                        var html = json2html.transform(data, transform);
         //Sending data to the browser              
                        res.send(html);
                    //  res.send(data);
                                            });
                    client.close();
                        });
                        });

find方法將返回與您的過濾器匹配的所有文檔。 但是,您可以使用find().limit()對其進行find().limit()

另外,如果要執行分頁之類的操作,則可以使用find().skip()跳過一些文檔,然后再次限制結果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM