Hello everyone, I have a user user table and a sig...
# orm-help
s
Hello everyone, I have a user user table and a signup token table that has one-to-one relation, I'd like to delete the signup token using the user email. is there a way to do it in a single query or should I fetch the token first using the email and then make another query to delete the token.
Copy code
model User {
  id           Int          @id @default(autoincrement())
  email        String       @unique
  first_name   String
  last_name    String
  signup_token SignUpToken?
}

model SignUpToken {
  id         Int      @id @default(autoincrement())
  token      Int
  user       User     @relation(fields: [userId], references: [id])
  userId     Int      @unique
  created_at DateTime
  updated_at DateTime @default(now())
}
Can the following two queries be combined into one?
Copy code
const user = await this.prismaService.user.findFirst({
      where: {
        email: resendTokenInput.email
      }
    });

    await this.prismaService.signUpToken.delete({
      where: {
        userId: user.id
      }
    });
c
Copy code
await this.prismaService.signUpToken.delete({
      where: {
        user: { 
          email: resendTokenInput.email
        }
      }
    });