diff --git a/quotes-api/README.md b/quotes-api/README.md index ea1fd71..83719f7 100644 --- a/quotes-api/README.md +++ b/quotes-api/README.md @@ -112,3 +112,5 @@ DELETE /quotes/:id ```BASH curl --request DELETE --header 'X-Quotes-API-Key: $API_KEY' 'https://ladylilia.com/quotes/api/quotes/666' ``` + +*Note: all subsequent quotes are reindexed* diff --git a/quotes-api/app.py b/quotes-api/app.py index 1ed3190..76884d7 100644 --- a/quotes-api/app.py +++ b/quotes-api/app.py @@ -109,6 +109,10 @@ class QuoteResource(flask_restful.Resource): flask_restful.abort(404, message='Quote {0} does not exist'.format(id)) db.session.delete(quote) db.session.commit() + q = db.session.query(Quote).filter(Quote.id > id) + for quote in q.all(): + quote.id -= 1 + db.session.commit() return None, 204