Questions tagged [prisma]

Prisma is a next-generation Node.js and TypeScript ORM for PostgreSQL, MySQL, SQLite, CockroachDB, MongoDB and SQL Server.

Prisma is a next-generation ORM and can be used in any Node.js or TypeScript backend application (including serverless applications and microservices). This can be a REST API, a GraphQL API a gRPC API, or anything else that needs a database. Use the Prisma client to access your database with Node.js, TypeScript or Go.

Prisma features:

  • An auto-generated and type-safe client library
  • Declarative data modeling and migration system with Prisma Migrate
  • Beautiful data management workflows with Prisma Studio
3236 questions
10
votes
4 answers

Error: P1001: Can't reach database server at `localhost`:`5200`

Technologies I use: nestjs -> for backend prisma -> for orm postgresql -> database I'm trying to run these technologies using Docker but I'm running into the following issue: prisma schema loaded from prisma/schema.prism Datasource "db":…
Furkan Gulsen
  • 1,384
  • 2
  • 12
  • 24
10
votes
1 answer

Prisma deleteMany with a list of IDs

I'm wondering if there is a way in the Prisma Client to batch delete database records by id. Something like this doesn't seem to exist: const idsToDelete = [5, 29, 255] prisma.post.deleteMany({ where: { id: { equals:…
Nate Vaughan
  • 3,471
  • 4
  • 29
  • 47
10
votes
2 answers

Timestamp with timezone column in Prisma

I am evaluating Prisma and I am a complete noob... I am using Postgresql I have the following model definition model Sth { id Int @default(autoincrement()) @id createdAt DateTime @default(now()) updatedAt …
madflow
  • 7,718
  • 3
  • 39
  • 54
10
votes
3 answers

Data modeling in Prisma with relations

I have a problem understanding relations and data-modeling in Prisma. I have an "easy" example about two users who can participate in a tennis game. So i have: Model User { id Int @id name String } Model Game { id Int @id …
Royal
  • 367
  • 2
  • 6
  • 15
9
votes
0 answers

How can I use the Prisma adapter for Next-Auth without email and emailVerified values

I am using next-auth with a custom provider and the Prisma adapter and I only want to store the values: id, name, country, avatar, and gender. However, I am getting this error: [next-auth][error][adapter_error_createUser]…
Anonymouse
  • 91
  • 1
  • 7
9
votes
1 answer

DateTime without time / only data? It is possible in Prisma?

I can in Prisma create columns without data, without time? my model at the moment: model modelName { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) lastNumber Int } Actual results: 2 2022-04-19…
mxcdh
  • 805
  • 3
  • 10
  • 20
9
votes
3 answers

Prisma query engine not found on mac M1

I'm having an issue with running Prisma in my project. Running npx prisma generate works, but then running my app I get: /Users/user/Desktop/project/node_modules/@prisma/client/runtime/index.js:36466 4:29:05 PM web.1 | throw new…
mcw
  • 465
  • 1
  • 4
  • 14
9
votes
4 answers

How to resolve 'getUserByAccount is not a function' in next-auth?

I've updated Nextjs to it's newest version and also updated next-auth and the prisma adapter as specified by the docs. However, when I try to authenticate in the app with signIn I get the following error with the latest…
N1K
  • 128
  • 1
  • 6
9
votes
1 answer

How to change PrismaClient database connection at runtime?

I have .env file like DATABASE_URL="sqlserver://srv:50119;initial catalog=mydb;user=aaa;password=bbb;" and then schema.prisma like datasource db { provider = "sqlserver" url = env("DATABASE_URL") } generator client { provider =…
A_L
  • 1,116
  • 2
  • 11
  • 25
9
votes
2 answers

Automatically add UUID relation on prisma create

I have a User, UserProfile and Post model in my Postgres database. The User and UserProfile depend on each other. I am trying to create a User that automatically creates a UserProfile with it, but I can't seem to find out how to automatically assume…
conaticus
  • 301
  • 1
  • 4
  • 14
9
votes
3 answers

prisma Order by relation has only _count property. Can not order by relation fields

consider following Prisma schema: model Conversation { id Int @id @default(autoincrement()) createdAt DateTime @db.Timestamp(6) messages ConversationMessage[] } model…
E.Belekov
  • 467
  • 1
  • 7
  • 14
9
votes
3 answers

How to run `prisma generate` in production?

I'm confused about how Prisma code generation in production works. The Prisma CLI is supposed to be installed in devDependencies, yet the npx prisma generate command needs to be available in production, since the generated code is necessary for the…
Robert Moore
  • 2,207
  • 4
  • 22
  • 41
9
votes
1 answer

prisma2: how to fetch nested fields?

In prisma 1 I have used fragment to fetch the nested fields. For example: const mutations = { async createPost(_, args, ctx) { const user = await loginChecker(ctx); const post = await prisma.post .create({ data: { …
Ashik
  • 2,888
  • 8
  • 28
  • 53
9
votes
3 answers

Dockerfile: how to Download a file using curl and copy into the container

in this example, I copy wait-for-it.sh inside /app/wait-for-it.sh But, I don't want to save wait-for-it.sh in my local directory. I want to download it using curl and then copy into /app/wait-for-it.sh FROM prismagraphql/prisma:1.34.8 COPY…
Ashik
  • 2,888
  • 8
  • 28
  • 53
8
votes
1 answer

Implicit or Explicit Many to Many relationship in prisma

When should you use a implicit many to many relationship in prisma and when explicit many to many relationship ? Do they have any trade-off or anything that should be noted
Darshan V
  • 198
  • 9