WYHNUS / ExchangeBuddy

Find your exchange buddies!
5 stars 0 forks source link

POST /feedpost/:id/reaction and POST /feedpost/comment/:id/reaction needs to do upsert #148

Closed irvinlim closed 7 years ago

irvinlim commented 7 years ago

Instead of using POST, we can use PUT (see http://stackoverflow.com/questions/18470588/in-rest-is-post-or-put-best-suited-for-upsert-operation).

The action should allow for upserts, instead of simply inserts.

ZhangHanming commented 7 years ago

@irvinlim you want it keep update and insert in one endpoint? right now I use PATCH for updating an row

irvinlim commented 7 years ago

Yes preferably. Otherwise I have to GET first before I decide whether to PUT or PATCH.

ZhangHanming commented 7 years ago

@irvinlim updating requires the id of the entry but inserting doesn't. so if we do upsert, the id field will be optional?

irvinlim commented 7 years ago

Because you can only add one reaction per post/comment, you can update based on the provided foreign key.

ZhangHanming commented 7 years ago

done