I am use MongoClient = require('mongodb').MongoClient;
module in NodeJs. But, i have not get single row JSON Object result in node. I have no any idea in mongodb client module.
Simple Query: select *from settings where id=1;
Mongo Query: db.collection("settings").findOne({_id:"5860cdf634c39399937f6619"});
I have get multiple JSON row like:
mongo.client.connect(mongo.url, function(err, db){
var resultArr = [];
var data = db.collection("settings").find();
data.forEach(function(doc, err){
mongo.assert.equal(null, err);
resultArr.push(doc);
}, function(){
db.close();
res.json({error:false,data:resultArr,msg:""});
});
});
This is working fine. But, i have not able to get single row.
I am use this library : http://mongodb.github.io/node-mongodb-native/2.2/installation-guide/