ForeignKeyConstraintViolation { constraint: Index(\"Device\") }
每当我尝试运行以下查询时,我都会收到此错误。
const _CreatedConnectedToMobile = await Context.Database.ConnectedToMobile.create({ 'data': {} }) <-- creates entry in db with default values.
// Create mobile entry where i am trying to create entry in Account Table, with Connection to Device and ConnectedToMobile Table.
// Account, Device and ConnectedToMobile -> Mobile(Table) by foriegn key.
await Context.DataBase.mobile.create({
'data': {
'number': mobileNumber,
'Account': {
'create': {
'accountType': _accountType,
'activeAs': _accountType,
'accessPin': accessPin
}
},
'Device': {
'connectOrCreate': {
'where': { deviceUniqueId },
'create': { deviceUniqueId }
}
},
'ConnectedToMobile': {
'connect': {
'id': _CreatedConnectedToMobile.id
}
}
}
})
如果我尝试 serpratly 运行一切正常但缩短它会导致错误,为什么?