这是关于后缀ORM的,我正在为餐后应用程序开发节点js。MealPrice表(FK : mealId)链接到饭桌(PK : Id),饭桌(FK : RestaurantId)链接到餐厅表(PK : Id)。从“餐价”表没有直接连接到“餐厅”桌。我需要的是,如果我将"IsActive = true“状态传递给mealPrice表,并且应该得到餐馆(不同列表)列表。老实说,我在续写ORM方面没有多少经验。这就是我现在所尝试的,它返回mealPrice和餐餐数据。
global.mealpricing.belongsTo(global.meal, { targetKey: 'id', foreignKey: 'mealId' });
global.meal.belongsTo(global.resturant, { targetKey: 'id', foreignKey: 'resturantId' });
global.mealpricing.findAll({
include: [{
model: global.meal,
}],
where: { isActive: true }
}).then(meals => {
res.send(meals);
});我关心的是如何获得JSON唯一餐厅的不同列表?请给我一个方向。
发布于 2018-03-10 10:13:47
https://stackoverflow.com/questions/49206415
复制相似问题