Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to delete in Drizzle ORM with several "where"

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
}
like image 555
Илья Маковецкий Avatar asked Oct 11 '25 16:10

Илья Маковецкий


1 Answers

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

like image 185
cpastore84 Avatar answered Oct 14 '25 08:10

cpastore84



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!