jonfanz
jonfanz
PPrisma
Created by Mr.Traveller on 9/3/2024 in #help-and-questions
As a fullStack developer, I am looking for new project
Hi there, no soliciting or advertising per the #rules
3 replies
PPrisma
Created by aXXo on 8/30/2024 in #help-and-questions
Is support for Postgres composite types planned?
Hello! Saw you posted in + upvoted the feature request. Thank you! It's not currently planned. We have a lot of planned features and it's not feasible to get everything in, unfortunately.
3 replies
PPrisma
Created by Alaskan donut on 8/28/2024 in #help-and-questions
Complicated groupBy query
let me know how it works for you. I can try and tweak things to see if I can get a better answer, but I think that will help get you in the right direction.
7 replies
PPrisma
Created by Alaskan donut on 8/28/2024 in #help-and-questions
Complicated groupBy query
Hacked around a bit and I think this is close to what you want:
SELECT
p.id,
p."userId",
r."reactionTypeId",
COUNT(r.id) as reaction_count
FROM
"Post" p
LEFT JOIN
"Reaction" r ON p.id = r."postId"
WHERE
p."userId" = $1
GROUP BY
p.id, p."userId", r."reactionTypeId"
ORDER BY
p.id, r."reactionTypeId"
SELECT
p.id,
p."userId",
r."reactionTypeId",
COUNT(r.id) as reaction_count
FROM
"Post" p
LEFT JOIN
"Reaction" r ON p.id = r."postId"
WHERE
p."userId" = $1
GROUP BY
p.id, p."userId", r."reactionTypeId"
ORDER BY
p.id, r."reactionTypeId"
Obviously I don't have your data set so I can't confirm if that would be exactly what you want.
7 replies
PPrisma
Created by jjmm on 8/27/2024 in #help-and-questions
"prisma generate --sql" keeps on hanging
Are you able to connect to your db directly? This feature requires access.
4 replies
PPrisma
Created by jmcclint on 8/27/2024 in #help-and-questions
prisma 5.19.0 preview feature "typedSql" not valid feature
Is it marked as invalid in your IDE or when running terminal commands?
6 replies
PPrisma
Created by dhe128 on 8/24/2024 in #help-and-questions
Error: P3005 The database schema is not empty.
Are you using Supabase Auth in your project?
9 replies
PPrisma
Created by Vector Axel on 8/22/2024 in #help-and-questions
Troubles with prisma when deploying to fly.io
I would check out @kentcdodds’ Epic Stack. It is designed to be deployed on fly.io Maybe something in his repo can help! https://github.com/epicweb-dev/epic-stack
7 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
no prob
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
model User {
id String @id @default(cuid())
tournamentsHosted Tournament[] @relation(name: "TournamentHost")
tournamentsJoined Tournament[]
}

model Tournament {
id String @id @default(uuid())
hostId String
host User @relation(name: "TournamentHost", fields: [hostId], references: [id])
users User[]
}
model User {
id String @id @default(cuid())
tournamentsHosted Tournament[] @relation(name: "TournamentHost")
tournamentsJoined Tournament[]
}

model Tournament {
id String @id @default(uuid())
hostId String
host User @relation(name: "TournamentHost", fields: [hostId], references: [id])
users User[]
}
There you go!
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
Now if you do that, you'll see an error under "tournamentsHosted" about an ambiguous relation. Then you just have to add a name to the host<->tournamentsHosted relation (like you had)
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
Okay, figured it out 🙂 So you have two relations. One is "one-to-many" which is User<->Tournament (one user can host many tournaments) The other is "many-to-many" which is (also) User<->Tournament (one user can join many tournaments, each tournament has many users. Let's break down the two relations:
model User {
id String @id @default(cuid())
tournamentsHosted Tournament[]
}

model Tournament {
id String @id @default(uuid())
hostId String
host User @relation(fields: [hostId], references: [id])
}
model User {
id String @id @default(cuid())
tournamentsHosted Tournament[]
}

model Tournament {
id String @id @default(uuid())
hostId String
host User @relation(fields: [hostId], references: [id])
}
So that will be both directions of the first "one-to-many" relation. Now to add a many-to-many, we just have to add lists of models on both sides.
model User {
id String @id @default(cuid())
tournamentsHosted Tournament[]
tournamentsJoined Tournament[]
}

model Tournament {
id String @id @default(uuid())
hostId String
host User @relation(fields: [hostId], references: [id])
users User[]
}
model User {
id String @id @default(cuid())
tournamentsHosted Tournament[]
tournamentsJoined Tournament[]
}

model Tournament {
id String @id @default(uuid())
hostId String
host User @relation(fields: [hostId], references: [id])
users User[]
}
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
weird. Let me try and replicate this.
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
Huh yeah that does look wrong. What version of the VSCode extension are you on?
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
You can change the names to something better. Maybe in your case it would be tournamentsHosted and tournamentsAttended?
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
The thing putting in those lines is our Prisma formatter, which is seeing the missing “back relation” fields and adding them
16 replies
PPrisma
Created by aychar on 8/16/2024 in #help-and-questions
Prisma keeps pasting incorrect schema
So that’s expected (and correct!) behavior. https://www.prisma.io/docs/orm/prisma-schema/data-model/relations The thing to note there is this quote:
At a Prisma ORM level, a connection between two models is always represented by a relation field on each side of the relation.
16 replies
PPrisma
Created by Jake on 6/14/2024 in #help-and-questions
Is it possible to use prisma pulse if your database is behind a VPN?
static IP support for Pulse is now available https://www.prisma.io/docs/pulse/static-ip
6 replies
PPrisma
Created by sunny on 8/7/2024 in #help-and-questions
Migration engine exited. Error: Command failed with UNKNOWN:
What version of prisma and @prisma/client ?
6 replies
PPrisma
Created by Dan on 8/5/2024 in #help-and-questions
Prisma ORM DocumentDB AWS
It looks like DocumentDB isn't fully compatible w/ Mongo, so I wouldn't expect our integration to work for them. There's an open issue that you could follow.
3 replies