amcnulty / Whoop-It-Up

A platform for viewing and creating events for the general public and friends.
https://whoopitup.herokuapp.com/
1 stars 1 forks source link

(backend) Find event end point to accept more than 1 category #78

Closed yankwong closed 6 years ago

yankwong commented 6 years ago

I've modified the find event page so that users can only find events by categories. Is it possible to create a backend endpoint (or modify the current endpoint) so that they can search events by specifying more than 1 category?

For example, if someone wanna search for all "Party", "Online" and "Concerts", the logic should be:

SELECT * FROM Events e LEFT JOIN EventCategories ec ON e.id = ec.EventID WHERE ec.CategoryId = ID1 OR ec.CategoryId = ID2...._

"ID1" and "ID2" represents the category IDs the user select from the frontend form.

Let me know if this is not clear :)

yankwong commented 6 years ago

Added comment on line 147-148 of event.controller.js. The GET parameter will be passed in the form of req.query.cid. It is a string in the format of '1+2+3...' and can be '' (empty)

Since :categoryId won't be used, we can either modify the '/bycategory/:categoryId' endpoint of add a new endpoint