chicken-sloths / bangazon-api-sprint1

API for a mock Amazon + Etsy platform providing developers access to the company's employee & product data
0 stars 0 forks source link

Fixes #107: this.changes on DELETE #134

Closed DavidLarsKetch closed 6 years ago

DavidLarsKetch commented 6 years ago

Description

We were a bit all over the place with what DELETE returns, and now all DELETE functions return this.changes and a 200 when something was there to DELETE and 204 when something was not there to DELETE, but the table does exist.

Number of Fixes

1

Related Ticket(s)

Fixes #107, Completes #86

Problem to Solve

Inconsistent feedback was given to the user on a DELETE request, in particular with ComputersModel, TrainingProgramsModel, OrdersModel, ProductsModel, ProductTypesModel & PaymentOptionsModel Accurate status codes were not being sent back from DELETE requests

Proposed Changes

All DELETE requests return this.changes If this.changes equals 1 (or more), sends back 200 If this.changes equals 0, sends back 204

Expected Behavior

If successful DELETE then should return 1 and 200. If nothing was present at that location, but the table exists, then DELETE returns 0 and 204.

Steps to Test Solution

  1. npm run db:generate
  2. npm start
  3. DELETE http://localhost:8080/api/v1/[table-name]/1 should return 200
  4. Then, again, DELETE http://localhost:8080/api/v1/[table-name]/1 should return 204
  5. Tables to test are: computers, training-programs, orders, products, product-types, & payment-options

Testing

TimAConner commented 6 years ago

Interesting: if you delete something that has already been deleted, it returns blank. I would think it would return 0.

DavidLarsKetch commented 6 years ago

Yeah, so, I haven't been able to get something to send or json back with 204 I don't know why.