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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -