Field excluded when running prisma query to supabase

The following code:
const user = await prisma.user.findFirst({ where: { email: email } });

console.log("user:", user);
const user = await prisma.user.findFirst({ where: { email: email } });

console.log("user:", user);
Produces the following in the terminal:
user: { id: 5, email: '[email protected]', name: 'asdfvc', example: 'asdf' }
user: { id: 5, email: '[email protected]', name: 'asdfvc', example: 'asdf' }
Even though my users table contains a password field (see photo) in my supabase and it is in sync with my schema. Any thoughts on why the prisma query won't select password (or updated_at or created_at for that matter)?
No description
3 Replies
gaurav1998
gaurav1998OP7mo ago
Interestingly enough, when I drop the example column and then push, and then run this:
const user = await prisma.user.findFirst({
where: { email: email },
select: {
id: true,
email: true,
password: true,
},
});
const user = await prisma.user.findFirst({
where: { email: email },
select: {
id: true,
email: true,
password: true,
},
});
I get the following:
Failed to fetch user: PrismaClientValidationError:
Invalid `prisma.user.findFirst()` invocation:

{
where: {
},
select: {
id: true,
email: true,
password: true,
~~~~~~~~
? name?: true,
? example?: true
}
}
Failed to fetch user: PrismaClientValidationError:
Invalid `prisma.user.findFirst()` invocation:

{
where: {
},
select: {
id: true,
email: true,
password: true,
~~~~~~~~
? name?: true,
? example?: true
}
}
Which means it's still expecting the example field. Why could that be? For more context, I have the following schema:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}

generator client {
provider = "prisma-client-js"
}

model Service {
id Int @id @default(autoincrement())
html String
editor_state String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
name String
slug String
card_title String
card_description String
}

model User {
id Int @id @default(autoincrement())
email String @unique
password String @default("$2a$10$cQEFiUaWpFvVVO5AcV3QN.7ohJXxxOPouTxORiZP.mUhupwEpDnUy")
created_at DateTime @default(now())
updated_at DateTime @default(now()) @updatedAt
name String
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}

generator client {
provider = "prisma-client-js"
}

model Service {
id Int @id @default(autoincrement())
html String
editor_state String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
name String
slug String
card_title String
card_description String
}

model User {
id Int @id @default(autoincrement())
email String @unique
password String @default("$2a$10$cQEFiUaWpFvVVO5AcV3QN.7ohJXxxOPouTxORiZP.mUhupwEpDnUy")
created_at DateTime @default(now())
updated_at DateTime @default(now()) @updatedAt
name String
}
gaurav1998
gaurav1998OP7mo ago
GitHub
Why can't I access password in user? (ORM) (Postgres-Supabase) · Is...
Bug description Using the following query: const user = await prisma.user.findFirst({ where: { email: email } }); console.log("user:", user); Produces the following in the terminal: user:...
gaurav1998
gaurav1998OP7mo ago
Wow. Fixed: just had to close and open vs code
Want results from more Discord servers?
Add your server