Hi,
I'm new to mongo and node-mongodb-native.
I'm unsure as to whether or not this is the correct way to go about
things, but I've written about 5 mapReduce queries that run every time
a user connects to an express endpoint. I have only 48 records in my
set and no indexes. One user hitting the service seems fine but when I
test 10 current users the app dies straight away with this stack
trace:
node.js:201
throw e; // process.nextTick error, or 'error' event on first
tick
^
TypeError: Cannot read property 'callback' of null
at [object Object].<anonymous> (/Sites/
rf.dev/src/node_modules/
mongodb/lib/mongodb/connection/server.js:280:24)
at [object Object].emit (events.js:67:17)
at [object Object].<anonymous> (/Sites/
rf.dev/src/node_modules/
mongodb/lib/mongodb/connection/connection_pool.js:154:13)
at [object Object].emit (events.js:70:17)
at Socket.<anonymous> (/Sites/
rf.dev/src/node_modules/mongodb/lib/
mongodb/connection/connection.js:330:22)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:347:14)
I'm using mongodb 0.9.9-4 and v0.6.7 and mongo v2.0.2
Here is an example of one of the calls:
_this.db.open(function(err, db) {
db.createCollection('something', function(err, col) {
col.mapReduce(map, reduce, {'out': 'tmp', 'query':
{'shortName' : category}}, function(err, collection) {
collection.find().sort({"value.checkins":-1}).limit(1).nextObject(function(err,
doc){
//do something
});
});
});
});
All 5 of these calls run in parallel using the async library. Should I
not be doing it this way? Should I be caching the results and using
the cached results?
Cheers,