how to delete in Drizzle ORM with several "where"

1.4k views Asked by At

I have a function:

export async function deleteFavoriteTrack({profileId, trackId}) {
   await db.delete(favoriteTracks).where(eq(favoriteTracks.profileId, profileId));
}

I can put only one "eq". How can i make like in prisma like:

where {
   profileId,
   trackId
}
1

There are 1 answers

0
cpastore84 On BEST ANSWER

You want to delete the favoriteTrack where both are equal? That sounds like an AND is what you're after!

await db.delete(favoriteTracks).where(
  and(
    eq(favoriteTracks.profileId, profileId),
    eq(favoriteTracks.trackId, trackId),
  )
)