David Ilizarov
05/28/2022, 9:53 PMEzekiel Adetoro
05/28/2022, 9:53 PMnpx prisma db
push during my development. Because I ran npx prisma migrate dev
, it gives me a bunch of error like permission error
. I am using heroku Postgres hobby
for my database. Now I am ready to fully deploy the app to Heroku. But I don't know how to get my schema.prisma
file to Heroku. I dont know how to deploy the database to Heroku Postgres hobby to communicate with my app. What I found online and on Youtube were about #prisma1 nothing about #prisma2. Any help on how to go about this? . Should I deploy this app like a normal NodeJs app to Heroku?Hussam Khatib
05/29/2022, 10:56 AMprisma.*.delete({...})
And view the data in prisma stdudio , I am getting this error
inconsistent query result field * is required to return data get null instead.
I even added the the onDelete: cascade in the relation.
Note: Deletion behaviors for relations are not yet supported in the Prisma schema so you don't see them anywhere. The behavior will still be enforced by the database though since that's where you configured it.Is the reason why it is happening ?
Berian Chaiwa
05/29/2022, 2:53 PMcreated_at DateTime @default(now()) @db.Timestamptz()
last_modified_at DateTime @updatedAt @db.Timestamptz()
My assumption is that both created_at
and last_modified_at
will default to now()
and when I check the generated types
for CreateInput
, for both, they look as below:
created_at?: Date | string
last_modified_at?: Date | string
But Prisma Studio
tells me something different: It defaults last_modified_at
to `now()`'s timestamp as expected and requires me to enter the value for created_at
! Why isn't it defaulting created_at
to now()
?Arnav Gosain
05/29/2022, 3:16 PMmodel Newsletter {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
issues Issue[]
User User? @relation(fields: [userId], references: [id])
userId Int?
}
model Issue {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
subject String
content String
Newsletter Newsletter? @relation(fields: [newsletterId], references: [id])
newsletterId Int?
}
What’s the best way to implement my use case?EdwinJr
05/29/2022, 6:31 PMthis.prisma.users.groupBy({
by: ["uid","language", "school"]
})
Yet the only result I get is:
[
{ uid: 23, language: 'english', "school":"A "},
{ uid: 22, primary_language: 'french', "school":"B" },
{ uid: 24, primary_language: 'french' , "school":"B"}
]
Do you guys have any idea of how I can really group by school and name ? I have a result like:
[
[{ uid: 23, language: 'english', "school":"A "}],
[{ uid: 24, language: 'french', "school":"B "}, { uid: 22, language: 'french', "school":"B "}],
]
Thank you !! 🙂Awey
05/30/2022, 12:41 AMclass-validator
.Wahyu
05/30/2022, 1:37 AMfindMany
where the entity is not referenced by any other entity.
I have a model called RenewalStorage that is a pivot table between Renewal <-> Storage models, I want to find Storage that is not referenced in any RenewalStorageKasir Barati
05/30/2022, 8:30 AMDominik Jašek
05/30/2022, 9:48 AMVivek Poddar
05/30/2022, 10:01 AMmodel Category {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
description String? @db.Text
active Boolean @default(true)
Product Product[]
}
model Product {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String @db.VarChar(255)
brand String @db.VarChar(255)
offerPrice Int @db.Int
description String? @db.Text
category Category @relation(fields: [categoryId], references: [id])
categoryId Int
}
But I don’t see category
attached to the generated typeVivek Poddar
05/30/2022, 10:01 AM/**
* Model Category
*
*/
export type Category = {
id: number
name: string
description: string | null
active: boolean
}
/**
* Model Product
*
*/
export type Product = {
id: number
createdAt: Date
updatedAt: Date
name: string
brand: string
offerPrice: number
description: string | null
categoryId: number
}
Brothak
05/30/2022, 10:13 AMPrisma.sql`Select * from foo where y = ${z};`
and I would like to have
Prisma.sql`Select * from foo where y = ${z} ${addOrder ? ORDER BY foo limit 10;" : ";";`
Brothak
05/30/2022, 10:13 AMDavedavedave
05/30/2022, 12:20 PM// type for existing gets inferred like this:
// { id: string | null }[]
const existing = prisma.users.findMany({
select: { id: true },
where: { NOT: { id: null } }
})
I tried to use Prisma validators with a validator for select and a seperate for where or one for the FindManyArgs type, but this didnt seem to work properly.
How do I get the correct returnType of string ids in this case?
Thanks guys 🙂Jay Pazos
05/30/2022, 1:02 PMJay Pazos
05/30/2022, 1:03 PMJay Pazos
05/30/2022, 1:03 PMJay Pazos
05/30/2022, 1:04 PMJay Pazos
05/30/2022, 1:04 PMJay Pazos
05/30/2022, 1:04 PMJay Pazos
05/30/2022, 1:06 PMSongkeys
05/30/2022, 1:30 PMconnect
to create relational model as described in doc:
const user = await prisma.profile.create({
data: {
bio: 'Hello World',
user: {
connect: { email: '<mailto:alice@prisma.io|alice@prisma.io>' },
},
},
})
I also disabled foreign keys using previewFeatures = ["referentialIntegrity"]
and referentialIntegrity = "prisma"
.
But it still give me error when the connect
field is not existed:
An operation failed because it depends on one or more records that were required but not found.
Is there any way that I could disable this validation? I only want this relational model when querying, not when inserting and strictly validating my create input.
Thank you so much!
edit: i post this here https://github.com/prisma/prisma/discussions/13565Simon Thow
05/30/2022, 1:41 PMMichael Roberts
05/30/2022, 2:10 PMMichael Roberts
05/30/2022, 2:10 PMexport const findManyTelescopes = async (prisma: PrismaClient) => {
return await prisma.telescope.findMany({
select: selectPublicFieldsForTelescope
})
}
Michael Roberts
05/30/2022, 2:11 PMRubén Lopez Lozoya
05/30/2022, 2:33 PMprisma.$transaction((prisma) => async {
const updates = items.map((item) => {
prisma.updateMany(....)
});
await Promise.all(updates);
})
} catch (err) {
// Handle the rollback...
}
if any of the promises rejects, the transaction will rollback but only all the operations that happened before the failing one. The rest of the operations that are being executed as part of the Promise.all() will still reach the database, leaving us with an undesired partial update. I would expect ORMs to handle this situation for me and somehow disregard/rollback all ongoing operations after one of the promises inside a transaction fails. I am wondering if what I want to achieve can be done using Prisma out of the box or if I will have to play around with Promise.allSettled API (or just going full sequential) to get what I want.FUTC
05/30/2022, 8:02 PMrcastell
05/30/2022, 8:11 PM