Questions tagged [prisma2]

For questions about Version 2 of the Prisma ORM

232 questions
1
vote
1 answer

Prisma 2 query relation return null

I migrated my project from prisma 1. Then I added new models relative to my Live model. I try to query the new models with relation type (one-to-one and one-to-many) but that returns null. Here is my prisma.schema Query live.questionnaire{} works…
J.dev
  • 844
  • 3
  • 12
  • 22
1
vote
3 answers

Prisma and ApolloClient: Prevent overwriting the include conditions at the backend by the frontend for relations

I have a problem, thx for any help. With prisma we can use include with where conditions for models with a relation. If I make include conditions I get the right result. If I return it to the frontend it gets overwritten. I want to return exact my…
Tölz
  • 766
  • 2
  • 8
  • 18
1
vote
1 answer

Prisma: Most performant way to query for sub relations

I want to query for posts and for each post I wan't just the like from the current user. I have 2 solutions and both are working. But which one is better? Or are there better solutions? Frontend: React + ApolloClient Backend: Primsa2 + Graphql…
Tölz
  • 766
  • 2
  • 8
  • 18
1
vote
0 answers

Prisma - Where selector on type with two unique fields

I'm trying to implement resolver which will check if the user with given login exists in the database. But I have a hard time with where selector in Prisma. So I have the type User: type User { UserID: ID! @id Login: String! @unique Password:…
XYZCODE123
  • 372
  • 3
  • 12
1
vote
1 answer

Prisma2: how to design schema which has relation with Array type Model?

I faced some problems when designing the schema. case 1: model User { package: @relation(fields: [authorId], references: [id]) packageId: Int } model Package { user User[] } one package can be subscribed by hundreds of users. So, I think…
Ashik
  • 2,888
  • 8
  • 28
  • 53
1
vote
1 answer

Is it possible to override connection url at client instantiation in Prisma2?

I am aware that Prisma2 by default wants you to bake the DB connection URL into an environment variable referenced via the Schema. I understand this is needed for CLI operations like migrate to work. However, at application bootstrap, when the code…
Adam Duro
  • 882
  • 1
  • 9
  • 21
1
vote
1 answer

How To save Json in Prisma 2.0?

I have JSON type in MySQL database. This is valid JSON. ["Text 1","Text 2"] And in MySQL I can execute: UPDATE table_name SET col='["Text 1","Text 2"]' WHERE id=1; But in Prisma 2.0 db.table_name.create({ data: { col: ["Text…
Daniel
  • 7,684
  • 7
  • 52
  • 76
0
votes
1 answer

How to search this Query using prisma?

I'm making database of travel destination which people have been to by many-to-many relationship. model Person { id String @id @default(cuid()) name String personCountry PersonCountry[] } model Country { id String @id @default(cuid()) …
Yusuke
  • 43
  • 5
0
votes
1 answer

how do I find the types to create with a Prisma client?

I have a Prisma model called 'bid' and I want to make sure my data is typed correctly to create. There are many auto-generated prisma types, but not sure of the naming convention and how to get the right type to use. I have a bid schema like…
dcsan
  • 11,333
  • 15
  • 77
  • 118
0
votes
0 answers

Prisma raw date query returns no result with JS date Object but has result with date string

I have a raw query (postgresDb) with date input const orderStatArr: any = await this.prismaService .$queryRaw`select sum(tempt.totalAmount), count(tempt."orderId"), orders."paystat" as paystat from (select sum(items.count * items.amount) as…
Jay
  • 336
  • 1
  • 4
  • 15
0
votes
0 answers

Save related models using Prisma

I have two models, Quiz and QuizQuestions a One to Many relation, i recive both on the request and want to save them at once since they are related to each other. But i'm receiving Error on create schema: model Quiz { quiz_id Int…
Blamet
  • 11
  • 3
0
votes
1 answer

Prisma modeling many to many

Im hoping there's a simple answer to this i'm missing in the docs. I have 3 models (tables): Class, Lecture, Notes A Class record can have many Notes A Lecture record Can have many Notes My models look like model Class { id String @id name…
empire29
  • 3,729
  • 6
  • 45
  • 71
0
votes
0 answers

query prisma relation to return child field if parent field meets condition

I have two models: Post model and a PostItem model. A Post can have multiple PostItems. model Post { id Int @id @default(autoincrement()) title String @db.VarChar(300) postItemNoteStatus String …
kris
  • 127
  • 3
  • 12
0
votes
0 answers

Prisma Client running in AWS Lambda with CloudFormation error: ENOENT: no such file or directory, open '/var/task/schema.prisma'

I've a lambda configured through cloudformation sam OrganizationPOSTFunction: Type: AWS::Serverless::Function Properties: FunctionName: OrganizationPOST CodeUri: ../src/ Handler: organization-post.lambdaHandler …
clagccs
  • 2,224
  • 2
  • 21
  • 33
0
votes
0 answers

Prisma nested "Where" with "OR" operator returns nothing

Adding "OR" inside nested "where" returns nothing. Removing "OR" inside nested "where" returns the results. What's the issue?
aivarastee
  • 81
  • 2
  • 12