There is a function in my application where users can pick specific entities to delete by selecting checkboxes. The IDs of the selected entities are added to an array. For instance, if I choose the first, second, and fourth entities, their IDs would be:
[0, 1, 3]
In the front-end service, I have the following method:
deleteEntities: function(batchIds){
return $http.delete('/finance/entities', {params: [batchIds collection here??]}).success(function(data){
return data;
});
}
This data is then passed to the back-end service which utilizes this method:
@Component
@Path("/entities")
@Produces("application/json")
public class FinanceEntityServiceImpl implements FinanceEntityService {
@DELETE
public void massDeleteEntitiesByIds(String batchIds){
System.out.println("batch ids: " + batchIds);
List<Long> idList = GsonProcessing.deserializeIdsList(batchIds);
financeDao.massDelete(idList);
}
}
As I was exploring solutions on how to delete collection resources using angularjs $http, I haven't found a definitive answer yet.
I'm uncertain about whether I can pass a fresh collection to $http.delete
as a parameter where it says [batchIds collection here??].
From what I understand so far, when deleting a collection, the URL should follow the format
'/myURL/batch?id=1&id=2&id=3'
. However, this approach doesn't seem practical when trying to delete a batch of 20 IDs.
Therefore, my question is: What is the best way to delete collection resources using angularjs $http.delete?