0

给定以下架构:

Cars {
id: Int!
features: [Features]
}

Features {
id: Int!
feature: String
}

更新记录时如何从表中删除所有现有功能?例如,我想更新具有“A/C”功能的汽车,并将其替换为“4x4”和“白色”。仅当查询中的数据正确时,如何才能从功能中删除所有功能(请记住,功能可以是多个)。这是我的查询:

updateCar( input:  {
id: 10
features: [{
  feature: 'New feature one'
},
{
  feature: 'New feature two'
}
]

这是解析器:

const car = await models.Cars.findOne({
                where: { id: input.id },
            });
await cars.update({
                features: [input.features]
},
  { 
                   include: [
                    {   model: models.Feature,
                        as: "features"
                    },
)
4

0 回答 0