wkd9241
DTDrizzle Team
•Created by lyron1111 on 3/26/2024 in #help
Executing raw Sql query
Hmm, I can't help you further. I've started using Drizzle a couple days ago and just happened to have made a raw sql query, so I had the answer to your question. Regarding your other issue, unfortunately I can't spot the error 🫤
5 replies
DTDrizzle Team
•Created by shikishikichangchang on 3/3/2024 in #help
how can I truncate all tables in the new drizzle studio? Previously there was a drop down button
Now add this script into your
package.json
file:
Edit it to match the path of the file containing the prompts. You can change the script command as well.
Now you can use pnpm db:drop
in your terminal. It will trigger the prompts and after 2 confirmations, it will execute the drop/truncation function.8 replies
DTDrizzle Team
•Created by shikishikichangchang on 3/3/2024 in #help
how can I truncate all tables in the new drizzle studio? Previously there was a drop down button
Here's the file that will be executed by the
exec
function after the 2 confirmations (don't forget to edit the command in the function to match your file path).
In my implementation, I totally drop the tables. If you just want to truncate them (deleting all of the rows but keeping the table), change DROP TABLE
to TRUNCATE TABLE
8 replies
DTDrizzle Team
•Created by shikishikichangchang on 3/3/2024 in #help
how can I truncate all tables in the new drizzle studio? Previously there was a drop down button
I have created 2 files + 1 script to do it from the terminal. Just copy and paste them and you should be fine. Edit them to suit your needs.
This code will be executed using the
tsx
package. It asks a confirmation twice before executing. You can edit the prompts as you wish.
8 replies
DTDrizzle Team
•Created by wkd9241 on 3/25/2024 in #help
Nested update pattern
No, the thing is that the collections are a column in the space table. They aren't a table. They look like this:
As for the
name
and oldName
logic, using trpc, I send the new data of the collection with the oldName
property that is the name
of the collection before the updating (it might not change). Then, I use this oldName
as a pseudo-identifier to know which collection
to update. Each collection has a unique name
.
Now that I double-check the code, I should destructure the updated collection data to extract the oldName
property before assigning it as the new collection's data (during the mapping in the Drizzle transaction)
With Prisma I could update the collections within a Space as shown in the screenshot. With Drizzle, I havn't found a more concise way of doing it then by what you see there (minding the correction I just mentionned).3 replies