-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: MongoDB 3.2
-
Labels:
-
Environment:MAC OS Sierra
-
Empty show more show less
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(
,
function(err, count)
);
} else
};
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}},
).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(); });
}
);