Say I have this query
var query1 = usersrec.find({username:target}, {});
query1.exec(function (err, docs){
if(err) throw ;
});
and it gives this result
{
"_id" : ObjectId("5806ba413202e30d68152aa4"),
"username" : "sammy",
"firstname" : "samuel",
"lastname" : "jackson",
"gender" : "male",
"phone" : "0123456789",
"image" : "sam.jpg"
}
I want to add a value which I get from another collection {"Balance" : "1011"}
to this resulting document before emitting with socket.io.
I've tried many things and got errors, but this went through without adding the balance key/value:
docs[0].balance = '1011';
console.log(docs);
socket.emit('usernames', docs);
The document still retains its initial values. What am I missing?