Hi guys, I am trying to create a full-stack application with user authentication. I have a Node backend connected to a MySQL database and a Vue frontend. On the database I have 2 tables like these:users:user_idemailpassword1johndoe@gmail.comadmin1234tasks:task_idnameuser_id1Walk my dog1As you have probably already guessed, the user_id column in the tasks table relates to the column of the same name in the users table. When a user logs in they have to enter their email and password and after that a list of the tasks associated with that user is displayed. Or it would be, if I knew how.Right now, I can only pull all tasks, regardless of what user they're from, with "SELECT \ FROM tasks". Instead, I would like to do something like *"SELECT \ FROM tasks WHERE user_id = (id of the current user)"*. I don't know if selecting a specific user when logging in is possible to do with MySQL, so the other way I think I could do what I want is by querying the id of the user when he/she logs in, passing it to the frontend, storing it there and making the queries by passing that variable. But this sounds too contrived. Any ideas?
Submitted January 17, 2020 at 06:53PM by albertothedev
No comments:
Post a Comment