Ben-Avrahami / Tindira

0 stars 1 forks source link

Fix database in getListingById #90

Closed yonisimian closed 4 months ago

yonisimian commented 4 months ago

https://github.com/Ben-Avrahami/Tindira/blob/a1f142fc6cebf34ffce026078644acd32d7e807d/Tindira-Server/Lambda-Functions/getListingById/index.mjs#L108

The code line above should be replaced with a deletion of that listing id from the user's listings array.

Note that this is not an indication of an error; a failure to retrieve a listing is a valid flow of the program, e.g. when a listing has been deleted by the user. In that case, we'd like to "lazily" clean the database (i.e., the user's listing array) whenever we try to access a listing that's no longer exist.

OmerK100 commented 4 months ago

Okay, a small change we have decided to implement:

When creating a post (createListing), the ID of the listing is added to the array under the listings field of the user (now the username of the user who posts the listing is sent as a query string as part of the request)

When deleting a post (deleteListing), the ID of the listing is removed from the array under the listings field of the user (now the username of the user who posts the listing is sent as a query string as part of the request)

yonisimian commented 4 months ago

I get error 502 when creating a listing: image please check the marked error (createListing/index.mjs line 17)

OmerK100 commented 4 months ago

Yes, thank you, I've allowed to add the query string parameter, try now

yonisimian commented 4 months ago

still getting the same error from the same line 17