Ennabah
08/10/2022, 9:57 AMFile
. This data is changing every few seconds. With every query to prisma.directoryNode.findFirst
, we need to join the data from the other database to the query. I have already connected to the remote database using postgres_fdw
and can query the data with $queryRaw.
Can anyone help us with performing a join from a remote database while using prisma.directoryNode.findFirst
to maintain type safety. Performing a join using prisma’s type safety would be ideal if it’s supported.
enum NodeType {
FOLDER
FILE
}
model DirectoryNode {
id Int @id @default(autoincrement())
type NodeType
folder Folder? @relation(fields: [folderId], references: [id])
folderId Int? @unique
file File? @relation(fields: [fileId], references: [id])
fileId Int? @unique
children DirectoryNode[] @relation("directoryNode")
parent DirectoryNode? @relation("directoryNode", fields: [parentId], references: [id])
parentId Int?
// timestamps
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Folder {
id Int @id @default(autoincrement())
name String
node DirectoryNode?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model File {
id Int @id @default(autoincrement())
name String
extension String
defaultAppName String
node DirectoryNode?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Ennabah
08/11/2022, 1:03 PMpostgres_fdw
). Is it possible to join (or I should rather say include
) from the foreign table with prisma.model.find
? instead of relying on raw queries and losing the type safety?
Many thanksNurul
08/30/2022, 12:10 PMpostgres_fdw
isn’t supported natively yet so queryRaw would be the only workaround for now.
Here’s the Feature Request: #8614
Please consider leaving a 👍 to the request so that we could prioritize it.Ennabah
08/30/2022, 1:20 PM