Allow to craft a JSON response for DELETE SQL queries
Summary:
When a DELETE statement is executed, most SQL databases
return the number of rows deleted on success.
For a CRUD API, no row deleted means the object isn't found
while 1 row deleted means success. Any other result (more
than one row or a SQL error) is a failure.
This change implements such logic in the ApiDeleteResponse
trait, implemented for QueryResult<usize>.
Test Plan:
An example of use is:
pub fn delete_deck(connection: DatabaseConnection, deck_id: i32) -> ApiJsonResponse<()> { diesel::delete( decks .filter(id.eq(&deck_id)) ) .execute(&*connection) .into_delete_json_response() }
Reviewers: dereckson
Reviewed By: dereckson
Differential Revision: https://devcentral.nasqueron.org/D2094