i'm new to NodeJS and i'm using MongoJS to connect to my database.
All is working fine, but when i use db.collection.find() function, it returns only the first 10 results on the database.
function listMessages(from,to){
console.log("[REQ] User "+from+" asked chat with "+to);
var htext = 'Welcome to the chat<br/>';
db.messages2.find({$or:[{from_id: from, to_id: to}, {from_id: to, to_id: from}]},function(err, echoData) {
if( err || !echoData) console.log("No messages found");
else echoData.forEach( function(returnData) {
htext += returnData.from_id+": "+returnData.text+"<br/>";
});
io.sockets.emit('html message '+from, htext, to);
});
}
It works fine, but returns only the first 10 results on the database, even if i use limit.
I've tried to use this too, and it didnt worked:
db.messages2.find({$or:[{from_id: from, to_id: to}, {from_id: to, to_id: from}]},{},{limit: 50}, function(err, echoData) {
What I need to do to fix this? Thanks!