cedric
08/26/2021, 4:20 PMVictor Mimo
08/26/2021, 5:00 PMSam Bunger
08/26/2021, 6:25 PMprisma db push
?
Here is my schema:
model profiles {
id String @id
first_name String?
last_name String?
phone_number String @unique
phone_number_ref contacts[]
contacts_ref contacts[] @relation("contact_holder")
}
model contacts {
id Int @id
contact String?
contact_ref profiles? @relation(fields: [contact], references: [phone_number])
contact_holder String
contact_holder_ref profiles @relation("contact_holder", fields: [contact_holder], references: [id])
}
Every profile has an id
and a phone_number
. Each user in the profiles
table will have each of their contacts on their phone put into contacts
as individual rows. contact_holder_ref
will always reference a user id
in the profiles
table. But a user’s contacts might may or may not reference another profile’s phone_number
in the profiles
table. Foreign key constraints are getting created by prisma that prevent me from adding phone numbers in contacts
that don’t exist in profiles
. Is there anything I can do to stop contacts_contact_fkey
from getting created? Everything seems to work when I manually delete the constraint, but then I can’t run prisma db push
again.Craig A. Cook
08/26/2021, 6:27 PMuser
08/27/2021, 6:00 AMmanuel
08/27/2021, 7:23 AMRubèn Suet Marcos
08/27/2021, 9:50 AMinclude
is present. I am requesting to Prisma in a function from a class, and want to be able to catch properly the type for the next class( kind of controller/model). It’s a NestJs app build in TS. I created a gist to give some context and my questions there https://gist.github.com/Ruffeng/0aa09c13792fe5d797d54756843f9faa Any help is highly appreciated 🙂Nima
08/27/2021, 12:47 PMPedro Paulo Almeida
08/27/2021, 9:47 PMmodel Plug {
id Int @id @default(autoincrement())
// other fields, then...
latest_signal_id Int? @unique
latestSignal Signal? @relation(fields: [latest_signal_id], references: [id])
signals Signal[]
}
// Then the Signal model:
model Signal {
id Int @id @default(autoincrement())
plug_id Int
plug Plug @relation(fields: [plug_id], references: [id])
tag_id Int
@@unique([plug_id, tag_id], name: "plug_signals_plug_id_tag_id_unique")
}
As you can see, in “Plug” model I want to have TWO relationships with the Signal model. One of then is: “A Plug has a LIST of Signal, the “signals” relationship”. Then the second one: “Signal have a direct pointer to the “latest” Signal. This “latest signal” is defined by the “latest_signal_id” column in Plug model.
I’m getting the following errors from VSCode Prisma plugin:
Error validating model "Plug": Ambiguous relation detected. The fields `latestSignal` and `signals` in model `Plug` both refer to `Signal`. Please provide different relation names for them by adding `@relation(<name>).
How can I have this kind of “two relationships” at the same time? What am I doing wrong here? Because I put that @relation(fields: [latest_signal_id], references: [id])
in front of prop latestSignal
but it didn’t work.Sam
08/28/2021, 2:07 AMapp.delete('/posts/:id', deletePost);
export const deletePost = async (req: Request, res: Response) => {
const { id }: { id?: number } = req.params;
const post = await prisma.post.delete({
where: {
id: Number(id),
},
})
res.json(post)
};
Now I'm trying to link it with the <PostTable> page... So I have a PostList.ts page, which calls fetch in a UseEffect and gets all the posts then passes it to <PostTable posts={posts}>
So in my PostTable.ts file, I have a posts.map () and then on the delete button, I'm trying to figure out how to delete it
I'm really confused if I need to call useEffect, deletePost (which doesnt work), and then how do I update the page? Should I pass the setPosts from PostList to PostTable? Not sure if I need to call prisma or update the posts using setPostsVdrizzle
08/28/2021, 2:39 AMuser
08/28/2021, 7:01 AMAdrian
08/28/2021, 11:09 AMSELECT s.id, s.name, s.logo_url
FROM supplier AS s
JOIN supplier_user su ON s.id = su."supplierId"
WHERE su."userId" = ${id}
AND su.active = TRUE
I tried to build this with a prisma query but i don’t get this to work. May last try was:
return this.prisma.supplier.findMany({
where: {
supplierUser: {
some: {
active: true,
userId: { equals: id }
}
}
}, select: {
id: true,
name: true,
logoUrl: true,
}
});
can someone pleas help me to understand why and how this joined selects work?glekner
08/28/2021, 12:37 PMtsc
passes locally but fails on herku. any suggestions?glekner
08/28/2021, 12:37 PMsrc/schema/branch/types/BranchMutation.ts(42,36): error TS7006: Parameter 'l' implicitly has an 'any' type.
src/schema/branch/types/BranchMutation.ts(52,36): error TS7006: Parameter 'l' implicitly has an 'any' type.
src/schema/branch/types/BranchMutation.ts(53,47): error TS7006: Parameter 'l' implicitly has an 'any' type.
src/schema/payloads.ts(62,7): error TS2339: Property 'date' does not exist on type 'ObjectDefinitionBlock<"TasksByThisWeekGroupByPayload">'.
src/schema/task/types/Task.ts(18,7): error TS2339: Property 'date' does not exist on type 'ObjectDefinitionBlock<"Task">'.
src/schema/task/types/Task.ts(19,15): error TS2339: Property 'date' does not exist on type 'Omit<OutputDefinitionBlock<"Task">, "nonNull" | "nullable">'.
src/schema/task/types/Task.ts(20,15): error TS2339: Property 'date' does not exist on type 'Omit<OutputDefinitionBlock<"Task">, "nonNull" | "nullable">'.
src/schema/task/types/Task.ts(21,15): error TS2339: Property 'date' does not exist on type 'Omit<OutputDefinitionBlock<"Task">, "nonNull" | "nullable">'.
src/schema/task/types/Task.ts(35,7): error TS2339: Property 'date' does not exist on type 'InputDefinitionBlock<"TaskCreateInput">'.
glekner
08/28/2021, 12:37 PMLuis España
08/29/2021, 2:06 AMspawn C:\Users\OneDrive\Escritorio\electron-template\dist\win-unpacked\resources\static\query-engine-windows.exe ENOENT
i have looked into that folder and the file is actually there, can someone help me out?Rain
08/29/2021, 8:31 AMkkangsan
08/29/2021, 5:36 PMkkangsan
08/29/2021, 5:36 PMUgogo
08/29/2021, 6:15 PMprisma studio
on Heroku?
The output is
Running npm run studio on ⬢ mealy-db... up, run.4905 (Free)
> rev@1.0.0 studio
> blitz prisma studio
Environment variables loaded from .env
Prisma schema loaded from db/schema.prisma
Prisma Studio is up on <http://localhost:5555>
But there is no localhost on Heroku 😁Maximous Black
08/29/2021, 6:35 PMKyle (TechSquidTV)
08/29/2021, 7:45 PMChris Packett
08/30/2021, 5:45 AMMedea T
08/30/2021, 9:37 AMPrisma
08/30/2021, 11:40 AMPrisma
08/30/2021, 11:40 AMPrisma
08/30/2021, 11:41 AMNima
08/30/2021, 1:21 PMAlan
08/30/2021, 2:24 PM