【发布时间】:2019-11-23 15:38:48
【问题描述】:
鉴于此关联
Product.Locations = Product.belongsToMany(ProductLocation, {
as: 'locations',
through: ProductStock,
foreignKey: 'productId',
otherKey: 'locationId'
});
以下模型已加载
const product = await Product.findById(123, { include: Product.Locations });
console.log(product);
// -> {
// id: 123,
// ....,
// locations: [ {
// ProductStock: { productId: 123, locationId: 456, stock: 99 },
// id: 456,
// ...
// } ],
// ...
// }
如何将名称 ProductStock 更改为 stock?
【问题讨论】:
标签: javascript node.js sequelize.js