Deleting the content of a table #341
Answered
by
noam-honig
OriBennett
asked this question in
Q&A
-
I'm trying to delete the full content of a table for seeding purposes. Is there a way to do it without getting all the contents then iterating over them? |
Beta Was this translation helpful? Give feedback.
Answered by
noam-honig
Feb 10, 2024
Replies: 1 comment
-
Hi @OriBennett, although there is no built-in way of doing that, it is very easy to implement yourself. Checkout the following article on how you can perform database operations directly: In short, if it's an sql database, here's the code: SqlDatabase.getDb().execute(`truncate table ${repo(City).metadata.dbName}`) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
noam-honig
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @OriBennett, although there is no built-in way of doing that, it is very easy to implement yourself.
Checkout the following article on how you can perform database operations directly:
https://remult.dev/docs/running-sql-on-the-server.html#using-the-underlying-database
In short, if it's an sql database, here's the code: