Query external API and store in database

Hi all, I would like to store into the database of my app some information that I periodically pull from an external API. The plan is: - create an plain Next.js API endpoint - store the data that I care into my database - ping the endpoint with a cron (Upstash) The thing that's not clear to me is that I have created the model when I try to use createMany I get the error in the image. I am pretty sure I am missing something here. I thought I could not use tRPC for this kind of call so I haven't created the route for the token model but as soon as I try to use a method on the token table I get the error, even though TS suggest me the table. What is the best way to do this? I have to follow the tRPC route, create a caller and call it from my external API? Thanks in advance to anyone will help me.
2 Replies
cupofcrypto
cupofcrypto•2y ago
BTW I am importing PrismaClient as suggested from the prisma docs: https://www.prisma.io/nextjs
Prisma
Next.js Database with Prisma | Next-Generation ORM for SQL Databases
Prisma is a next-generation ORM for Node.js & TypeScript. It's the easiest way to build Next.js apps with MySQL, PostgreSQL & SQL Server databases.
cupofcrypto
cupofcrypto•2y ago
Ok so I had to restart the application and everything started to work flawlessly 😅
Want results from more Discord servers?
Add your server