Sanyam Bansal
07/27/2022, 6:49 PMDave Edelhart
07/27/2022, 7:19 PMDave Edelhart
07/27/2022, 9:02 PMBenjamin Willard
07/27/2022, 9:50 PMBenjamin Willard
07/27/2022, 9:54 PMBINARY
, VARBINARY
, TIMESTAMP
, JSON
(This is a custom parser using json-bigint
npm package). Then I also have nodejs-snowflake
npm package I also use which is for all of our major identities. Basically right before a record is inserted if it has an auto-increment with SnowflakeId it will perform the new generated ID. How can I make these possible with Prisma?Benjamin Willard
07/27/2022, 9:55 PMBenjamin Willard
07/27/2022, 9:56 PMDave Edelhart
07/27/2022, 10:18 PMmodel task_type {
id String @id @default(uuid())
name String @unique
tasks task[]
notes String?
order Int @default(0)
parent_id String?
parent task_type? @relation(name: "parent", fields: [parent_id], references: [id])
child_tasks task_type[] @relation(name: "parent")
deleted Boolean @default(false)
interval Int @default(0)
}
model task {
id String @id @default(uuid())
type task_type @relation(fields: [task_type_id], references: [id])
task_type_id String
task_events task_event[]
notes String?
data Json?
createdAt DateTime @default(now())
last_work_done DateTime?
completedAt DateTime?
status String @default("started")
parent_task task? @relation(name: "parent", fields: [parent_task_id], references: [id])
parent_task_id String?
child_tasks task[] @relation(name: "parent")
}
Some of the types have “interval” (numeric) and I want to find all the tasks whose (task_)type.interval field is zero.Jeremy Cohen Hoffing
07/27/2022, 10:26 PMBoo
07/28/2022, 1:29 AMorderBy
the combined result?
Meaning...
.findFirst({
where: {
id: 1
}, {
select: {
something: {...},
somethingElse: {...}
}
}
})
so combining something and somethingElse within here and then orderBy
both of them all in one query, including paginationHussam Khatib
07/28/2022, 6:22 AMif (role === Role.admin)
user = await prisma.user.findUnique({
where: {
id,
},
select: defaultAdminSelect,
});
if (role === Role.student)
user = await prisma.user.findUnique({
where: {
id,
},
select: defaultStudentSelect,
});
Fredrik Lindberg
07/28/2022, 8:32 AMOmar
07/28/2022, 11:19 AMMischa
07/28/2022, 3:19 PM__dirname
), schema.prisma file bundling, and lack of aurora Data API support.
I think kysely is going to eat prisma in the serverless space unless something is done about those issues (prisma data proxy doesn't count)Max Blancarte
07/28/2022, 5:20 PMRutik Wankhade
07/28/2022, 6:26 PMDave Edelhart
07/28/2022, 8:48 PMLogan
07/28/2022, 8:56 PMconst members = await prisma.teamMember.findMany({
where: {
teamId,
},
});
const membersInfo = [];
members.map(async (e) => {
const response = await prisma.user.findFirst({
where: {
id: e.userId,
},
});
if(response) membersInfo.push(response);
});
Matt D
07/28/2022, 9:07 PMVats Patel
07/29/2022, 8:59 AMHello everyone
Hereby I am stuck at one place
there is 1 model like below
model Channel {
user_id Int
user User @relation("user_channels", fields: [user_id], references: [id])
provider_id Int
provider User @relation("provider_channels", fields: [provider_id], references: [id])
created_at DateTime @default(now())
updated_at DateTime @updatedAt
deleted_at DateTime?
conversations Conversation[]
@@id([user_id, provider_id], name: "user_provider_id")
@@map("channels")
}
now there is a model named Conversation
Conversation {
channel_id Int
channel @relation(fields: [channel_id], references: [id])
...
}
But I am not getting what to write or define relation here as there is no id in channel id
have any idea ?
thank you
Michael Jay
07/29/2022, 11:32 AMLloyd Richards
07/29/2022, 12:09 PMError 429: Quota exceeded for quota metric 'Queries' and limit 'Queries per minute per user' of service '<http://sqladmin.googleapis.com|sqladmin.googleapis.com>' for consumer
I assume this has something do with Prisma connections or maybe just the way that prisma connects into CloudSQL. I've got a work around at the moment that retries the functions after 60sec to sort the bottleneck, but maybe if someone has experience with a Cloud Function > Prisma > CloudSQL stack then they might have run into the same issue?user
07/29/2022, 12:10 PMArpan Bagui
07/29/2022, 12:19 PMMichael Jay
07/29/2022, 12:38 PMexport const GroupInvitationStatus: {
Pending: 'Pending',
Accepted: 'Accepted',
Declined: 'Declined'
};
export type GroupInvitationStatus = (typeof GroupInvitationStatus)[keyof typeof GroupInvitationStatus]
Michael Jay
07/29/2022, 12:40 PMArpan Bagui
07/29/2022, 3:12 PMStanislas de Roquemaurel Galitzine
07/29/2022, 3:14 PMimport { PrismaClient } from '@prisma/client';
export let prisma: PrismaClient;
if (typeof window === 'undefined') {
if (process.env['NODE_ENV'] === 'production') {
prisma = new PrismaClient();
} else {
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-ignore
if (!global.prisma) {
// @ts-ignore
global.prisma = new PrismaClient();
}
// @ts-ignore
prisma = global.prisma;
}
}
This works okay bar from the ugly ts-ignores, which I would like to remove.
I can fix this by prepending the code above with:
declare global {
var prisma: PrismaClient
}
But then it clashes with Jest which throws a Duplicate declaration "prisma" error
.
What would be the correct way of fixing this, without exporting prisma as default ?
Why is Jest confused by this? (I am not sure about the error, seems like Jest is unable to infer that this is the same variable).Michael Jay
07/29/2022, 4:32 PMtype UnwrapTuple<Tuple extends readonly unknown[]>
I'm happy to debug it for the answer, but I would prefer to have it in front of my eyes before I try to run it.{Pedrolima}
07/29/2022, 6:44 PM