Does upsert work in mongodb prisma connector? If yes, is there a way I can use upsert and connect together? My problem is I have a model User, I want to search based on its id. Now I want to update the user if the id is found but if not, I want to create a permissions entry also connecting my user id. Here's the code for it
const { id: userId, ...rest } = request;
const response = await db.user.upsert({
where: { id: userId },
update: rest,
create: {
...rest,
Permissions: {
create: {
access: true,
email: rest.email,
},
connect: {
subAccountId: userId,
},
},
},
})
This gives me a type error Type '{ subAccountId: string; }' is not assignable to type 'PermissionsWhereUniqueInput | PermissionsWhereUniqueInput[] | undefined'. Type '{ subAccountId: string; }' is not assignable to type 'undefined'