Trying to loop on all updated field I've got and update them dynamically before saving.
Product.findOne({ _id: productNewData['_id'] }, function (err, doc) {
for (var key in productNewData) {
# what do I do here?
}
doc.save();
});
I know that ruby has a send method like this:
doc.send(key) = productNewData[key]
I guess I can validate the params given and use eval
. Is there any other way?