MySQL用のSequelize ORMを使用してノードをプログラミングしています。Sequelize がクエリで返すオブジェクトに新しいフィールドを追加する必要がありますが、うまくいかないようです。
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; // this works
category.item_ids = ci; // this doesn't
// category['item_ids'] = ci; // this doesn't work as well
res.send({
category: category,
items: items
});
});
Object.isExtensible
オブジェクトに対してtrueを返しますcategory
が、実際にそれを拡張する方法がわかりません