Home
DevCentral
Search
Configure Global Search
Log In
Transactions
D2094
Change Details
Change Details
Old
New
Diff
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>`. 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() } ```
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>`.
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>`.
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() } ```
Continue