You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I have User defined in schema.prisma as follows:
model User {
createdAt DateTime @default(now())
email String @unique
id String @id
name String
password String
permissions2 Permission2[]
resetToken String?
resetTokenExpiry Float?
updatedAt DateTime @updatedAt
address Address[]
cart CartItem[]
items Item[]
itemvariants ItemVariants[]
order Order[]
orderitem OrderItem[]
}
And in my app.js attempt to do the following:
import { prisma } from 'nexus-plugin-prisma';
use(
prisma({
migrations: false,
features: { crud: true },
}),
);
// 1. decode the jwtt so we can get the user Id on each request
server.express.use((req: any, res: any, next: any) => {
const { token, uuid } = req.cookies;
if(token) {
const { userId } = jwtt.verify(token, process.env.APP_SECRET);
// put the userId onto the req for future requests to access
req.userId = userId;
}
next();
});
// 2. create a middleware that populates the ueer on each request
server.express.use(async (req: any, res: any, next: any) => {
// if they aren't logged in, skip this
if (!req.userId) return next();
const user = await prisma.user.findOne({
where: { id: req.userId } },
);
req.user = user;
next();
});
server.express.listen(PORT, (err: any) => {
if (err) throw err
console.log(`🚀 Server ready at http://localhost:${PORT}`)
});
But VSCode is issuing the above error message on prisma.user.findOne(). What is the issue here?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
nexus: 0.26.0-next.3
nexus-plugin-prisma: 0.16.1
ts-node: 8.10.2
ts-node-dev: 1.0.0-pre.50
So I have User defined in schema.prisma as follows:
And in my app.js attempt to do the following:
But VSCode is issuing the above error message on
prisma.user.findOne()
. What is the issue here?Beta Was this translation helpful? Give feedback.
All reactions