I want to do bulk delete using angularjs http request to flask restless api version 0.17.0. I know that I can do it one by one, using id of record in url. But I would be pleased if this is possible in one request. I am not sure if this is possible
Flask backend looks like this:
manager.create_api(Messages,
methods=['GET','PUT','DELETE'],
preprocessors={"GET_MANY": [auth_func],
"GET_SINGLE": [auth_func],
"PUT_SINGLE":[auth_func],
"DELETE_SINGLE":[auth_func],
"DELETE_MANY":[auth_func] },
allow_delete_many=True)
My Angularjs code looks like this:
$scope.deleteMails = function(){
//$scope.deleteMessage = [1,2,3] array of id to delete
var create_filters = []
$scope.deleteMessage.forEach(ele => {
create_filters.push({"name": "id", "op": "equals", "val": ele.toString()})
});
$http({
method : 'DELETE',
headers: {'X-CSRFToken' : csrf },
url : '/api/tbl_messages',
data : { q : {filters: create_filters} }
})
.then(function(res){
console.log(res)
},function(res){
console.log('error')
})
}
This request is finished with status 200 but my whole table in db is deleted. In all cases it is deleting my whole DB(table) not concrete ids. I really don't know what to do here. Thank you very much for help in advance.