Kha
03/18/2021, 7:00 AMKha
03/18/2021, 7:01 AMMy models:
model User {
id String @id @map("user_id")
email String @unique
location Location? @relation(fields: [locationID], references: [id])
locationID Int?
}
model Location {
id Int @id @default(autoincrement())
label String @unique
placeID String @unique
city City @relation(fields: [cityID], references: [id])
state State? @relation(fields: [stateID], references: [id])
country Country @relation(fields: [countryID], references: [id])
cityID Int
stateID Int?
countryID Int
User User[]
}
Kha
03/18/2021, 7:01 AMawait this.prisma.user.update({
where: {
id: userID,
},
data: {
location: {
connectOrCreate: {
where: {
label,
},
create: {
label,
placeID,
city: {
connectOrCreate: {
where: {
name: city,
},
create: {
name: city,
},
},
},
state: {
connectOrCreate: {
where: {
name: state,
},
create: {
name: state,
},
},
},
country: {
connectOrCreate: {
where: {
name: country,
},
create: {
name: country,
},
},
},
},
},
},
},
include: {
location: true,
},
});
}
Kha
03/18/2021, 7:02 AMlocation
field doesn’t exist and suggests that maybe I meant locationID insteadKha
03/18/2021, 7:02 AMUnknown arg `location` in data.location for type UserUncheckedUpdateInput. Did you mean `locationID`
Manish
03/18/2021, 7:12 AMKha
03/18/2021, 7:12 AMnpx prisma generate
Kha
03/18/2021, 7:12 AMManish
03/18/2021, 7:14 AMKha
03/18/2021, 7:14 AMKha
03/18/2021, 7:15 AMlocation
, only locationID
Kha
03/18/2021, 7:15 AMlocation
there right?Manish
03/18/2021, 7:16 AMManish
03/18/2021, 7:16 AMKha
03/18/2021, 7:17 AMManish
03/18/2021, 7:17 AMKha
03/18/2021, 7:21 AMKha
03/18/2021, 7:22 AMUserUncheckedCreateInput
Kha
03/18/2021, 7:23 AMManish
03/18/2021, 7:23 AMKha
03/18/2021, 7:24 AMlocationID
instead of the location
objectManish
03/18/2021, 7:24 AMRyan
03/18/2021, 7:31 AMundefined
or null
and check.Kha
03/18/2021, 7:39 AMKha
03/18/2021, 7:39 AMKha
03/18/2021, 7:40 AMError:
Invalid `prisma.user.update()` invocation:
{
where: {
id: '3fa015c4-d06b-4413-adb4-5ffb2bc31722'
},
data: {
location: {
~~~~~~~~
connectOrCreate: {
where: {
label: 'Tokyo, Japan'
},
create: {
label: 'Tokyo, Japan',
placeID: '1234',
city: {
connectOrCreate: {
where: {
name: 'Tokyo'
},
create: {
name: 'Tokyo'
}
}
},
state: {
connectOrCreate: {
where: {
name: undefined
},
create: {
name: undefined
}
}
},
country: {
connectOrCreate: {
where: {
name: 'Japan'
},
create: {
name: 'Japan'
}
}
}
}
}
}
}
}
Unknown arg `location` in data.location for type UserUncheckedUpdateInput. Did you mean `locationID`? Available args:
type UserUncheckedUpdateInput {
id?: String | StringFieldUpdateOperationsInput
email?: String | StringFieldUpdateOperationsInput
password_hash?: String | StringFieldUpdateOperationsInput
time_joined?: BigInt | BigIntFieldUpdateOperationsInput
username?: String | NullableStringFieldUpdateOperationsInput | Null
name?: String | NullableStringFieldUpdateOperationsInput | Null
profilePicture?: String | NullableStringFieldUpdateOperationsInput | Null
bio?: String | NullableStringFieldUpdateOperationsInput | Null
dateOfBirth?: DateTime | NullableDateTimeFieldUpdateOperationsInput | Null
locationID?: Int | NullableIntFieldUpdateOperationsInput | Null
emailpassword_pswd_reset_tokens?: emailpassword_pswd_reset_tokensUncheckedUpdateManyWithoutUserInput
}
at Document.validate (/Users/khanguyen/Desktop/Projects/codusk-api/node_modules/@prisma/client/runtime/index.js:32448:19)
at PrismaService._executeRequest (/Users/khanguyen/Desktop/Projects/codusk-api/node_modules/@prisma/client/runtime/index.js:34385:17)
at /Users/khanguyen/Desktop/Projects/codusk-api/node_modules/@prisma/client/runtime/index.js:34320:52
at AsyncResource.runInAsyncScope (async_hooks.js:197:9)
at PrismaService._request (/Users/khanguyen/Desktop/Projects/codusk-api/node_modules/@prisma/client/runtime/index.js:34320:25)
at Object.then (/Users/khanguyen/Desktop/Projects/codusk-api/node_modules/@prisma/client/runtime/index.js:34440:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Kha
03/18/2021, 7:41 AMKha
03/18/2021, 7:41 AMstate
is undefinedKha
03/18/2021, 7:41 AMKha
03/18/2021, 7:43 AMstate
if a state is not provided?Kha
03/18/2021, 7:44 AMKha
03/18/2021, 7:49 AMstate: state
? {
connectOrCreate: {
where: {
name: state,
},
create: {
name: state,
},
},
}
: undefined,