how to delete in Drizzle ORM with several "where"

1.5k 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 best solutions below

0
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),
  )
)