Open DevHyperCoder opened 3 years ago
My recommendation is not to create a route called /surveys
for all of the logged-in user's surveys. Instead, we can just have a /survey
subroute, and just do /survey/@me
. This would return all of the surveys created by the logged-in user.
oh thats nice ; so we will take in a string, and if its @me, handle all surveys and if its not, parse it into a integer (or UUID) and get the id ?
That's not what I meant. Let me tell you my idea of how the /survey/@me
endpoint would work.
Select * from surveys where user_id=theuserid
. This query isn't valid cql, but I hope it explains the stuff.yea i understand that. i was mentioning the parsing because, if we need to get a specifc survey (id = 2) for eg, we would do GET /survey/2
correct ?
For accessing a specific survey, yes. Then we can just get the survey ID and then make a query for that
which field in survey should be unique ? survey id will be always unique. what about the title ?
Title doesn't need to be unique. People might have similar titles like "Job Application", or "Discord Mod Application", etc.
Survey Schema:
Here, i do not think a one to many (User -> Survey) is necessary, because the most common way someone will access the survey is by using the id. I assume the dashboard (or profile) of the logged in user will be accessed less frequently compared to attending a survey.
We need to create a
/survey/<id>
for a individual survey being attended by someone. If the participants list is empty, no one can access the survey apart form the creator. the participants list will be a list of user ids ; We might need to make it a Array*
/surveys
lists all the surveys created by the logged in userSo, for the first endpoint, it will be a simple task of searching the db and in the second, we would need to
find all surveys where userId=currUser.id
Suggestions please :)