I had a User table with additional fields: id, email, firstname, lastname, create_date,
etc.
Loved the idea to db authentication, and setup the dbAuth
.
I added the hashedPassword
and salt
fields to the db and to the model, and then I scaffold the user model (with force).
After doing so, all the other fields in the db
were not retrieved. The only one that were retrieved were those that were defined in the auth.js
file.
I tried also to change the db.user.findMany()
to include the 'select'
option for the missing fields (as described in Prisma docs), but got error message like:
Error:
api | Invalid `prisma.user.findMany()` invocation:
api |
api | {
api | select: {
api | ? id?: true,
api | ? email?: true,
api | ? hashedPassword?: true,
api | ? salt?: true,
api | create_date: true
api | ~~~~~~~~~~~
api | }
api | }
api |
api |
api | Unknown field `create_date` for select statement on model User. Available options are listed in green.
I also tried to add the additional fields to the 'api\src\functions\auth.js'
, like:
...
authFields: {
id: 'id',
username: 'email',
hashedPassword: 'hashedPassword',
salt: 'salt',
create_by: 'create_by',
create_date: 'create_date',
},
...
that did not help as well.
When I used the db.user.findMany()
, and logged the QUERY
for Prisma
, to log the SQL statement, it did not include any of the additional fields, although they are included in the model:
query:
"SELECT \"gvg\".\"users\".\"id\",
\"gvg\".\"users\".\"email\",
\"gvg\".\"users\".\"hashedPassword\",
\"gvg\".\"users\".\"salt\"
FROM \"gvg\".\"users\"
WHERE \"gvg\".\"users\".\"id\" = $1
LIMIT $2 OFFSET $3"
Prisma Studio
does retrieve the fields correctly.
Any suggestions?