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
}
Adam Boulila
08/10/2022, 11:12 AMLogan
08/10/2022, 12:54 PMconsole.log(session.id);
const userToken = await prisma.account.findFirst({
where: { id: session?.id },
});
console.log(userToken);
Hey all. Just found an issue with my prisma query. When trying to findFirst
by id
with a value that is undefined
it returns the first document in the database. Surely it should only return something if the value id
was found?
In the code above, session.id
is undefined. the console.log(userToken)
returns the first account in the database.Seb Powell
08/10/2022, 12:59 PMSeb Powell
08/10/2022, 12:59 PMError: Error in connector: Error querying the database: db error: FATAL: sorry, too many clients already
Seb Powell
08/10/2022, 1:00 PMSeb Powell
08/10/2022, 1:00 PMSeb Powell
08/10/2022, 1:00 PMSeb Powell
08/10/2022, 1:01 PMSeb Powell
08/10/2022, 1:02 PMBastien Etienne
08/10/2022, 1:17 PMtry {
const result = await prisma.cibest_role.findUnique({
where: {
name: props.roleName,
features: {
service_name: props.featureName,
},
},
select: {
features: {
select: {
service_name: true,
create: true,
read: true,
update: true,
delete: true,
icon: { select: { name: true } },
},
},
},
});
Richard Ward
08/10/2022, 1:21 PMfindUnique
can only search on unique
columnsRichard Ward
08/10/2022, 1:22 PMfeatures
is not unique then try using prisma.cibest_role.findFirst
or prisma.cibest_role.findMany
insteadkami gerami
08/10/2022, 1:24 PMmodel Lock {
id String @id @default(cuid())
from String @unique
to String
locked Boolean @default(false)
User User @relation(fields: [email], references: [email])
email String
@@unique([from, to, email]) // use can only create one entry with matching from, to and email.
}
model User {
id String @id @default(cuid())
name String?
email String @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
role Role @default(USER)
timereport Timereport[]
Lock Lock[]
}
model Timereport {
id String @id @default(cuid())
date String
Event Event @relation(fields: [event], references: [name])
event String
hours Float
User User @relation(fields: [email], references: [email])
email String
Project Project @relation(fields: [project], references: [name])
project String
@@unique([date, event, email]) // Do not allow multiple entries of same date + event + email
}
Bastien Etienne
08/10/2022, 1:24 PMrcastell
08/10/2022, 3:34 PMrcastell
08/10/2022, 3:36 PMSlackbot
08/10/2022, 3:48 PMRain
08/10/2022, 5:25 PMprisma.user.create({ data, Post: { createMany: {data: postData}});
prisma chobo
08/10/2022, 5:44 PMnick
08/10/2022, 6:34 PMDave Rupert
08/10/2022, 10:12 PM4.2.0
announcement with metrics and telemetry and that was a very serendipitous thing. Thanks for all the hard work.Raja Singh
08/10/2022, 11:33 PMJustin F
08/11/2022, 12:30 AMKinjal Raykarmakar
08/11/2022, 6:57 AMJeffr
08/11/2022, 7:17 AMJan D'Hollander
08/11/2022, 10:54 AMvassbence
08/11/2022, 1:21 PMEnzot
08/11/2022, 2:20 PMfindMany.
I have db with 30000 records and I am only able to take 5000 of them. If I try get more I have error from tokio-runtime-worker
. It is bug or feature?Heinz Gericke
08/11/2022, 2:38 PM