javascript - Why I cannot add field to a JS object? -


i'm programming node sequelize orm mysql. need add new field object sequelize returns on query, doesn't seems work.

category.find({   where: { id: req.params.id },    include: [item] }).success(function(category) {   var items = category.items;   var ci = category.items.map(function(item) { return item.id; });   delete category.items; // works   category.item_ids = ci; // doesn't   // category['item_ids'] = ci; // doesn't work    res.send({     category: category,     items: items   }); }); 

object.isextensible returns true on category object, can't figure out how extend it

try this:

.success(function(category) {   category = category.tojson(); // convert simple js object   ...   category.item_ids = ci;   ...   res.render(...); }); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -