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

Answer by Iftah for Node- Can't attach key/value to object

$
0
0

Do you intend to save the result after you modify it?
Are you using Mongoose virtual properties in your broadcastSingleClient function ?

if not then I think you can use lean which will return plain js object - without the Mongoose object wrapping it.

Try this:

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

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>