I have a question, Iām making an application that uses passportjs for authentication, on the official website to find the user the findUser method is used (which if I remember correctly belongs to mongoose and mongodb), but Iām using postgresql, the equivalent to findUser in postgresql what would it be?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (3)
It depends on what you're using to talk to Postgres. Here's some boilerplate I use with Massive and bcrypt:
If you're not using Massive, you'd need to change each invocation involving
db
.If you store your user in postgresql, you could interact with your database with raw SQL queries or use an ORM to manage the interaction for you. I'd suggest putting all your database access behind a common interface so that if you swap to using a different database later on you don't have issues.
Basically, just make a db module with an exported function called "findUser" and in there you can implement the method by retrieving the user from the database using your ORM/raw SQL. Then import this db module where you want to call your passport auth and then call the function "findUser" that you have written.
You can also use sequelize by connecting it to your postgres db