Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-832

collection.find method dont give 100000 recordset result over a 200000 records

    XMLWordPrintable

    Details

    • Type: Question
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: MongoDB 3.2
    • Labels:
    • Environment:
      MAC OS Sierra

      Description

      Hi everyone!

      I can't get records from the query.js (after ejecute insert.js) via node , but if you do the following instruccion directly to node :

      db.customers.find({'v':{'$gt':5}},

      {'skip': 100000 , 'limit': 10, 'sort': 'v'}

      )

      it works!!Unable to render embedded object: File (... why don't give me recordset from node?... is bug?, error?, a correction?... what I'm doing wrong?, please help me) not found..

      by the way i'm doing the exercise of the The Node Craftman book , exactly page 93-94. insert.js and query.js

      Greetings
      E
      _______________ insert.js _______________
      'use strict';
      /* uso de insert sin manejo de indices */
      var MongoClient = require('mongodb').MongoClient;
      var url = 'mongodb://127.0.0.1:27017/accounting';
      var REGISTROS = 200000;

      MongoClient.connect(
      url,
      function(err, connection) {
      var collection = connection.collection('customers');

      var doInsert = function {
      if (i <= REGISTROS) {
      var value = Math.floor(Math.random() * 10);
      collection.insert(

      {'n':'#'+i, 'v': value}

      ,
      function(err, count)

      { doInsert(i+1); console.log(i); }

      );
      } else

      { console.log('\n[FIN] - Se han insertado %s registros: \n', i); connection.close(); }

      };
      console.log('\n[INICIO] - Insertando %s registros en la coleccion customers', REGISTROS);
      doInsert(1);
      });

      _______________ query.js _____________
      'use strict';

      var MongoClient = require('mongodb').MongoClient,
      assert = require('assert');

      var url = 'mongodb://127.0.0.1:27017/accounting';

      MongoClient.connect(
      url,
      function(err, connection) {
      var collection = connection.collection('customers');

      collection.find(
      {'v':{'$gt':5}},

      { 'skip': 100000 , 'limit': 10 , 'sort': 'v' }

      ).toArray(function (err, documents)

      { assert.equal(err, null); //assert.equal(2, documents.length); console.log('Se encontraron los siguientes registros: %s \n',documents.length); console.dir(documents); connection.close(); }

      );
      }
      );

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            zamudpoe engelbert
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: