Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Martin Ratinaud
Martin Ratinaud

Posted on

     

Prisma "null or does not exists"

I've been using Prisma on my latest projectKaraoke Tools and as crazy as it may seem, I did not find any easy way (like a plugin) to handle soft delete behaviour.

So I had to tweak it myself manually and ending up in a case where

  • deletedAt can be null
  • deletedAt can NOT exist

This is because I'm using mongo and no default value fordeletedAt.

This filtering in Prisma is not handled by default (likedeletedAt: null so I had to do it with anOR request.

constitems=awaitprisma.event.findMany({...where:filters:{OR:[{deletedAt:{isSet:false}},{deletedAt:null}],...});
Enter fullscreen modeExit fullscreen mode

As it took me almost an hour to find this (chatGPT not being helpful), I wrote this article.

Cheers

Top comments(6)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
konstantin_potyomkin_be72 profile image
Konstantin Potyomkin
  • Joined

I spent two days trying to solve this problem—documentation, AI, even prayers to the gods—nothing worked. Your article was super helpful and gave me the direction I needed to solve it! Thank you!

CollapseExpand
 
claudsondouglas profile image
Claudson
  • Joined

Thank you, the tears have already fallen from my face, thannnnkssssssss!!!!!!!

CollapseExpand
 
gustawdaniel profile image
Daniel Gustaw
  • Joined

Concise and to the point. Thank you very much. Chat GPT was trying to convince me that prisma doesn't support it xD

CollapseExpand
 
mrispoli24 profile image
Mike Rispoli
I'm an award-winning designer, engineer and creative technologist that helps daring founders ship valuable software.
  • Location
    New York City
  • Work
    Co-founder & CTO at Cause of a Kind
  • Joined

I just lost a few hours to this myself I wish I found this sooner, much appreciated!

CollapseExpand
 
yimy profile image
aLeaTioN Shen
  • Joined

Created account quickly just to thank you, I was using Cursor pro with claude-3.7-sonnet-thinking and it couldn't figure it out, and prisma documentation wasn't helpful at all, thanks for sharing!

CollapseExpand
 
rfsilvagyn profile image
Raphael Felix
  • Joined

I need help convert command sql to prisma:

SELECT acctuniqueid,
username,
callingstationid,
framedipaddress
FROM tiger.RadiusAcct
WHERE username = ${element.login}
AND acctstoptime IS NULL
AND NOT EXISTS (
SELECT 1
FROM tiger.RadiusAcct subquery
WHERE subquery.username = ${element.login}
AND subquery.acctstoptime IS NOT NULL
AND subquery.radacctid > tiger.RadiusAcct.radacctid
)
ORDER BY radacctid DESC
LIMIT 1;

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Remote enthusiast. Freelancer. No-Ego doer.@stakingcryptoio, @headlinker_, @remote_family.Father of 2, former CEO, life hackerSurf, family and fun
  • Location
    Tamarin, Mauritius
  • Education
    Engineer
  • Work
    Freelance Fullstack Dev
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp