I used to have a table "user" (with id, email, name...etc.)
Using the following query;
db.one("select * from user where email=$1", request.body.email).then(function (data)
The result inside data was: { current_user: 'postgres'} which looks like data from the database user name rather than the user in my user table.
Renaming my table to something else solved the problem.
That's not likely, there must be something else you are missing.
Plus, this library does not interpret or change the data, you get it exactly as node-postgres provides it.
@sefo user is a reserved word in postgres. It's an alias for current_user function so when you do select * from user; internally it translates to select current_user; which, as you may have guessed, it returns the DB user used in the connection.
Try to avoid reserved names when naming your tables, columns, functions or anything else. users or user_accounts might be a better choice here.
Most helpful comment
@sefo
useris a reserved word in postgres. It's an alias forcurrent_userfunction so when you doselect * from user;internally it translates toselect current_user;which, as you may have guessed, it returns the DB user used in the connection.Try to avoid reserved names when naming your tables, columns, functions or anything else.
usersoruser_accountsmight be a better choice here.