Quantcast
Channel: Node- Can't attach key/value to object - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Node- Can't attach key/value to object

$
0
0

Using Node. This is weird, I am not able to attach a key/value....broadcastStamp = date to the object result. I verified with typeof it is a object. There is no error...the key/value is just simply not there.

function broadcastSingleClient(result, event, httpObject) {    var date = new Date().valueOf();    result.broadcastStamp = date;     console.log(result);

UPDATE: This object is coming from a mongoose/mongodb query call back function:

Object.keys(models).forEach(function (model) {    models[model].find({}).sort({_id: -1}).limit(1).exec(        function (err, result){            broadcastSingleClient(result[0], model+"Result", res);        });

When doing this query in the shell without the exec() call back, I am able to attach to the object.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images