Fred The Doggy
01/31/2022, 2:35 AMFred The Doggy
01/31/2022, 2:35 AMFred The Doggy
02/01/2022, 12:25 AMdatasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["dataProxy"]
}
to be exact, and am getting
error: Error validating datasource `db`: the URL must start with the protocol `mysql://`.
--> schema.prisma:6
Avi Block
02/02/2022, 7:28 AMBaptiste Arnaud
02/02/2022, 9:49 AMmodel Typebot {
id String @id @default(cuid())
publishedTypebotId String?
publishedTypebot Typebot? @relation("PublishedUnpublished", fields: [publishedId], references: [id])
typebot Typebot? @relation("PublishedUnpublished", onDelete: Cascade)
}
I get:
Error parsing attribute "@relation": The relation field `typebot` on Model `Typebot` must not specify the `onDelete` or `onUpdate` argument in the @relation attribute. You must only specify it on the opposite field `publishedTypebot` on model `Typebot`.
I'd really like to delete the publishedTypebot
if typebot
is deletedAustin Zentz
02/02/2022, 2:10 PMBarnaby
02/02/2022, 8:07 PMprisma generate
in a monorepo is throwing error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
How to tell Prisma to pass this flag to its yarn invocation?Barnaby
02/02/2022, 8:16 PM@prisma/client
and prisma
in CI before generating code - I'd prefer a workflow where generated code is committed to the repo and not generated on CI - apparently this is advised against thoughBen Ezard
02/02/2022, 11:59 PMenableShutdownHooks(app: INestApplication) {
this.$on('beforeExit', async () => {
await app.close();
});
}
This code is important to us (since if Prisma terminates the process before Nest can gracefully shutdown, we end up with a whole bunch of leftover resources that need to be manually cleaned up), and as such I'm looking to write a test for it...but I'm unsure how to go about that - does anyone have any suggestions please?
Previously I'd have mocked the implementation of $on()
, but 3.9.0
made that readonly so that's not possible anymore (Jest only allows readonly properties to be mocked if they're not a function)Mischa
02/04/2022, 11:34 AMSELECT DISTINCT ON
? - https://www.postgresql.org/docs/14/sql-select.html#SQL-DISTINCTYaakov
02/04/2022, 2:25 PMmodel UserCategory {
id Int @id @default(autoincrement())
@@map("user_categories")
}
// Returns UserCategory
prisma.findModelByTableName('user_categories')
Slackbot
02/04/2022, 2:35 PMMischa
02/04/2022, 3:37 PMMischa
02/04/2022, 3:37 PMINSERT INTO "CandidateSkill"
("candidateId", "skillId", "seniority")
VALUES ($1, $2, $3),($4, $5, $6)
ON CONFLICT ("candidateId", "skillId") DO UPDATE
SET "seniority"=EXCLUDED."seniority"
Raw query failed. Code:. Message: `db error: ERROR: invalid byte sequence for encoding “UTF8”: 0x0022021
Mischa
02/04/2022, 3:37 PMMischa
02/04/2022, 4:19 PMNivv
02/05/2022, 6:53 AMRedS
02/05/2022, 2:27 PMthis.db[t].upsert({
where: {
guildId,
},
update: {
channelId,
content,
},
create: {
guildId,
channelId,
content,
},
});
this.db[t].delete({
where: {
guildId,
},
});
Yaakov
02/07/2022, 1:20 PMupdated_by
ID before each update. The currect user can be obtained from req.user.id
. The correct approach seems to be using Prisma middleware, however prisma.$use
does not seem to provide access to the req
object!
Any ideas??
prisma.$use(async (params, next) => {
if (params.action === 'update') {
const models = prisma._dmmf.datamodel.models;
let model = models.find(m => m.name === params.model);
let updatedAtField = model.fields.find(f => f.name === 'updated_by');
if (updatedAtField) {
params.args.data['updated_by'] = NEED ACCESS TO req.user.id;
}
}
return next(params);
});
Hervé - Product at Prisma
02/09/2022, 11:16 AMTopi Pihko
02/09/2022, 3:47 PMexport function getEmailQuery(email: string): string {
return `SELECT * FROM User WHERE email = ${email}`; }If I call as following:
await this.prisma.$queryRaw` ${getEmailQuery("email@email.com")}`;Prisma gives error :
Raw query failed. Code:. Message:42601
db error: ERROR: syntax error at or near "$1"
Benjamin Smith
02/10/2022, 7:16 PMconst [nResponses, nPromoters, nDetractors] = await prisma.$transaction([
prisma.response.count({
where: {
campaignId
}
}),
prisma.response.count({
where: {
campaignId,
score: {
gte: 9
}
}
}),
prisma.response.count({
where: {
campaignId,
score: {
lte: 6
}
}
})
]);
Opesanya Adebayo
02/15/2022, 7:42 PMYaakov
02/17/2022, 3:20 PMDecimal
, but it loses its precision.
Example: Value 97.85 turns into 97.8499999999999900Josh Kelly
02/18/2022, 10:58 PM[
{
nickname: null,
lastName: 'Smith'
},
{
nickname: 'Billy',
lastName: 'White',
}
]
If i’m calling findMany
and i want to orderBy
but i want to do something like [nickname || lastName]: 'asc'
and then Billy would be the first item in the response as Smith comes after Billy.Jonas Damtoft
02/19/2022, 10:05 AMCharacter
field that references a new characterId
field, why? I want an implicit relations table.
model Character {
id String @id @default(cuid())
name String
friends Character[] @relation("CharacterFriends")
}
I think my current solution will be this:
model Character {
id String @id @default(cuid())
name String
friends Friends[] @relation("friend")
friends_ignored Friends[] @relation("friend_ignored") @ignore
}
model Friends {
character Character @relation("friend", fields: [characterId], references: [id])
characterId String
ignoredCharacter Character @relation("friend_ignored", fields: [ignoredId], references: [id])
ignoredId String
@@id([characterId, ignoredId])
}
Is there a better way? I also need to make sure I both insert and delete two records whenever I update this, as the friendship should always be mutual.Sreenivas Dunna
02/21/2022, 5:05 AMnikos l
02/23/2022, 2:15 PMawait this.prisma.test.updateMany({
where: {
status: 'active',
endsAt: {
lt: new Date(),
},
},
data: {
status: 'expired',
and here the relation...
},
});
nikos l
02/23/2022, 2:15 PMAdhithyan YT
02/25/2022, 5:30 AMCannot read properties of undefined (reading 'create')
this error when call my API anyone can help me with this