I developed a backend using Prisma as ORM. Recently I had to truncate (more than once) some tables.
I did it directly with SQL queries, so I'm thinking to include a truncate option to the Delete endpoint.
It's recommended to do that? I'm asking overall because of possibly security issues.
If so, what's better, a $queryRaw with a truncate or a deleteMany({where: {}}).
I know if I want to delete CASCADE I have to add it to the ON DELETE on the foreign keys.
It depends on your application and use case, but either queryRaw
or deleteMany
will work.
If you would use deleteMany
then all the records will be deleted in a transaction as mentioned here which depending on your use case could be favourable.