0
 Followers
1
 Like

Delete All function for entity

Backend
New

Hi All, 


As we are having functions like 

1.  Create<Entity>

2. CreateOrUpdate<Entity>

3. Update<Entity>

4. Get<Entity>

5. Get<Entity>ForUpdate

6. Delete<Entity>


If we can have Delete All function which takes list as input and delete all the records from Database which all  are in list base on ID. 


Why am asking is there times where we can have requirements to delete data from Particular entity .


Thanks & Regards,

Ramakrushna Rao Seera



Created on 7 Aug
Comments (6)

Hi,

It could be useful, but dangerous at the same time, specially in Production environments.

You can however achieve that using a SQL query, and encapsulate it in a reusable Server Action. Your SQL query would look like this

Cheers

Yes we can write, Even we can write advance Query for everything but why do we have  aggregates since they are more optimized right.   


Could you please explain why it is dangerous to have? If a developer wanted to use then only he will use it otherwise he never uses it as like other functions

It is dangerous in the sense that if a developer leaves (by mistake) behind lets say a timer that runs that code go into production. Someone could trigger that code execution and all data would be lost.

In all cases, when used with caution you should be good.

Absolutely, something could be left by mistake, but at the same time, this could also be put as a warning in the warnings/errors panel.

This doesn't sound like it's asking for

"Delete from {MyEntitity}" but rather

"Delete from {MYEntitity} where id in [1,2,3,4]" where 1,2,3,4 is a list of IDs passed into the method.  

This functionality would be really good where you have a table of data, where each row has a checkbox and a "Delete" button to delete all the checked items. Just pass the comma list of ids or a List of Identity to the function.

Changed the category to Backend


views
108
Followers
0