I want to update based on the combination of keys ...
# orm-help
n
I want to update based on the combination of keys which are unique in my DB. When I update based on primary key it works but not on combination of keys which are defined unique. await this.service.update({ where:{ platformApplicationIdentity: uiData.platformApplicationIdentity, settingType: uiData.settingType, identity: uiData.identity, user: uiData.user, }, data:{ lastTouchedBy: uiData.lastTouchedBy, summary: uiData.summary, lastTouchedTimeUTC: uiData.lastTouchedTimeUTC == undefined ? null : uiData.lastTouchedTimeUTC, lastTouchedComment: uiData.lastTouchedComment == undefined ? null : uiData.lastTouchedComment, tenant: uiData.tenant == undefined ? null : uiData.tenant, } })
Here the combination of four keys are unique in my schema.
r
Could you share your schema?
n
model UISettingSummary { platformApplicationIdentity String settingType String identity String user String? id Int @id @default(autoincrement()) lastTouchedBy String lastTouchedTimeUTC String? lastTouchedComment String? summary String tenant String? PlatformApp PlatformApplication @relation(fields: [platformApplicationIdentity], references: [identity]) @@unique([settingType,identity,platformApplicationIdentity,user], name: "UniqueKeys") }
r
The
where
would include the unique name for the fields:
Copy code
where:{
  UniqueKeys: {
            platformApplicationIdentity: uiData.platformApplicationIdentity,
            settingType: uiData.settingType,
            identity: uiData.identity,
            user: uiData.user,
  }
},
Using
ctrl+space
in the
where
block in VSCode should show you this.
👍 1
n
where: { UniqueKeys: [ uiData.settingType, uiData.identity, uiData.platformApplicationIdentity, uiData.user ], }, I changed it to this , but the code editor still shows error
r
It’s not an array. It’s an object
{}
.
💯 1
n
ok
Thx it worked
💯 1