Questions tagged [prisma2]

For questions about Version 2 of the Prisma ORM

232 questions
0
votes
1 answer

One-to-many and may-to-many relation between two prisma model

I am working on a side project and I came to an issue that I'm not sure how to solve. I have created two models, one for User and one for Project. The relation between them is many-to-many, as many users can have many projects, but i would also like…
Miloslavc
  • 127
  • 2
  • 7
0
votes
1 answer

How to do SQL insert for Postgres using Prisma with condition on count of rows?

I am trying to insert a row into database provided that - number of rows satisfying some condition already in the table is less than certain threshold, say 10. For example, in below model, I don't want to have a project to have more than 10 users;…
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
0
votes
1 answer

How to use Prisma with ValidationPipe in NestJS?

I'm trying to use Prisma with ValidationPipe that NestJS provides but it is not working, I was using class-validator package with DTO's (classes) as ValidationPipes and it was working fine, now I need a way to use the same pattern with Prisma…
SebMaz93
  • 539
  • 1
  • 6
  • 14
0
votes
2 answers

Check for object ownership with Prisma

I'm new to working with Prisma. One aspect that is unclear to me is the right way to check if a user has permission on an object. Let's assume we have Book and Author models. Every book has an author (one-to-many). Only authors have permission to…
Xen_mar
  • 8,330
  • 11
  • 51
  • 74
0
votes
0 answers

Prisma migration issue after deploying to Heroku

I have an app written in NextJS deployed to Vercel and spun up PostreSQL on Heroku. Earlier I was using MySQL then changed configuration to PostgreSQL. I have deployed tables to Heroku PostgreSQL using npx prisma migrate save --schema…
rohitpaniker
  • 695
  • 1
  • 7
  • 25
0
votes
1 answer

Prisma: Create or Connect Records in Explicit Many-to-Many Relations

In my Prisma Schema, I'm finding it difficult to undertand how to to create records in case of explicit many-to-many relations. I have the following schema. Basically it represents Lists of Books. Users can Create Lists of Books. A user can create a…
asanas
  • 3,782
  • 11
  • 43
  • 72
0
votes
1 answer

How can I create a custom repository in Prisma 2 using NestJS like TypeORM?

In TypeORM I can create a CustomRepository like it: import {EntityRepository, Repository} from "typeorm"; import {User} from "../entity/User"; @EntityRepository(User) export class UserRepository extends Repository { findByName(firstName:…
Émerson Felinto
  • 433
  • 7
  • 18
0
votes
2 answers

How to use cron job in Blitz.js

information I looking for :( How to implementing cron job using Blitz.js. what I done so far have double-checked Blitz.js document. what I want ask Does anyone know or have been done implementing cron job using Blitz.js?? simple sample code would be…
Ryoma Kishimoto
  • 425
  • 1
  • 6
  • 16
0
votes
1 answer

Add Date Type to prisma2 schema

i am trying to add an Date type to my prisma2 schema. I know there is a DateTime type but I am just needing the date. Because I haven't found anything related to Date I would add an Custom input with day, month and year and create then a Date with…
user2675468
  • 150
  • 3
  • 16
0
votes
1 answer

How to create many to many relationship in prisma2

I am using Prisma2+GraphQL and I would like to write schema.prisma this is my code below model Message { id Int @id @default(autoincrement()) text String from User to User room Room createdAt DateTime @default(now()) User User…
0
votes
1 answer

Error: P1014 The underlying table for model `_migration` does not exist

I am getting this error in Prisma Migrations. I know it's experimental but I need the migrations table in the database. My Schema is as follows datasource db { provider = "mysql" url = env("DATABASE_URL") } generator client { …
Pranta
  • 2,928
  • 7
  • 24
  • 37
0
votes
1 answer

Unable to solve Prisma 1 - 1 and 1 - n relation error

I have 3 Prisma2 tables where User can have lots of Sheet and only one Doc model User { id Int @default(autoincrement()) @id firstName String lastName String email String @unique sheets Sheet[] docs Doc? } model Sheet { id Int…
rohitpaniker
  • 695
  • 1
  • 7
  • 25
0
votes
1 answer

Unable to Create Multiple Connect Query in Prisma?

I am getting this error ForeignKeyConstraintViolation { constraint: Index(\"Device\") } whenever i try to run following query. const _CreatedConnectedToMobile = await Context.Database.ConnectedToMobile.create({ 'data': {} }) <-- creates entry in db…
Sushant
  • 1
  • 3
0
votes
1 answer

Prisma update function fails because of incorrect type

I am using Prisma2. The mutation function looks like this: const updateUserProfileDetails = async ( inputValues, ctx: { session?: SessionContext } = {} ) => { const profile = await db.user.update({ where: { id: ctx.session!.userId }, …
Kayote
  • 14,579
  • 25
  • 85
  • 144
0
votes
1 answer

Missing a required value when setting array

I'm using Prisma upsert and getting an error about missing a required value when I'm trying to set one of the fields, which is an array type, specifically numeric[]. I'm using Prisma version 2.6.0 Data is getting into the database for all except a…
giraffesyo
  • 4,860
  • 1
  • 29
  • 39
1 2 3
15
16