Hubert Kowalski
09/14/2022, 2:38 PMmodel Wallet {
user User
balance Int
incomingTransactions Transaction[] @relation("incomingTransaction")
outgoingTransactions Transaction[] @relation("outgoingTransaction")
}
model Transaction {
id Int
change Int
toWallet Wallet @relation(name: "incomingTransaction")
fromWallet Wallet? @relation(name: "outgoingTransaction")
}
how can I create a query that creates the transaction and:
1. decrements balance of fromWallet by change
if specified
2. increments balance of toWallet by change
3. and actually returns Transaction in the end
Couldn't figure it out on my own π
Should I maybe just opt in to use $transaction?Slackbot
09/14/2022, 3:28 PMMax Daunarovich
09/14/2022, 4:52 PMAman Dalmia
09/14/2022, 5:22 PMrelevance
, and then pass relevance
for orderBy
. We are also using pagination. Which is why it is very important to have the sorting bit done using Prisma's native sorting support.
Something like this would be ideal:
this.prisma.job.map((job) => { ...job, relevance: calculateRelevance(job) }).findMany({ orderBy: relevance })
I tried reading the docs to search for something that might work but couldn't find something to match this use case. Does anyone have any suggestions for how I can go about this? Or do you recommend a different approach?aetheryx
09/14/2022, 8:36 PMColin Robinson
09/15/2022, 5:21 AMSee Jee
09/15/2022, 6:03 AMmodel Media {
mediaUid String @id @db.Uuid
title String
}
model Document {
documentUid String @id @db.Uuid
title String
}
model Post {
postUid String @id @db.Uuid
attachedUid String @db.Uuid
title String
}
The attachedUid in Post table is the uid of Document or Media. When I delete the Media or Document I want to delete it too in Post.Kenny Tran
09/15/2022, 12:24 PMLucas Reinaldo
09/15/2022, 12:37 PMTed Joe
09/15/2022, 1:53 PMType '{ id: string; }[]' has no properties in common with type 'ProfileTypeWhereUniqueInput'.ts(2559)
index.d.ts(17294, 5): The expected type comes from property 'connect' which is declared here on type 'ProfileTypeCreateNestedOneWithoutUserInput'
I have the following tables
model ProfileType {
id String @id @default(cuid())
name String @db.VarChar(255)
user. User[]
}
model User {
id String @id @default(cuid())
profileType ProfileType @relation(fields: [profileTypeId], references: [id])
profileTypeId String
}
Here's where I connect them
const allProfileTypes = await db.profileType.findMany({
select: { id: true },
})
const profileType = allProfileTypes[0]
await db.user.create({data: profileType: { connect: [{ id: profileType.id }] },})
What am I doing wrong and how can I fix them?Jamie Higgins
09/15/2022, 2:16 PMJamie Higgins
09/15/2022, 2:34 PMasync function getLatestBuildByTagAndVersion(tag: string, appVersionId: number) {
const result = prisma.build.findFirst({
where: {
component_version: {
app_version_id: appVersionId,
git_tag: tag,
git_sha: "want this from the build.git_sha",
},
},
orderBy: {
build_number: "desc",
}
});
Essentially I want git_sha to be:
build.git_sha = component_version.git_sha
Xavier Quelard
09/15/2022, 3:06 PMAmol Patel
09/15/2022, 7:35 PMCharlie
09/15/2022, 8:29 PMSamuel Proschansky
09/15/2022, 10:09 PMSamuel Proschansky
09/15/2022, 10:25 PMDavid Hancu
09/16/2022, 5:26 AMpg_trgm
proposal easier to implement.
Features added in v1.3.0:
β’ Code-generated schemas
β’ Config is migrating from .json
to .mjs
β’ Additional ways of configuring Prisma (such as YAML)
β’ Improved internals for handling migrations, to allow you to create .ts
migration files in v1.4.0 and to facilitate pg_trgm
integration with PrismaAlex Ruheni
Vasily Zorin
09/16/2022, 12:03 PMSean Templeton
09/16/2022, 5:45 PMgroupBy
call. Currently I have this:
prismaMock.fitment.groupBy.mockResolvedValue([
{ year: '2020', make: 'Ford', model: 'F-150', sub_model: null },
]);
Sean Templeton
09/16/2022, 5:45 PMTS2322: Type '{ year: string; make: string; model: string; sub_model: string; }' is not assignable to type 'PickArray<FitmentGroupByOutputType, FitmentScalarFieldEnum[]> & { _count: true | { id?: number | undefined; ... 26 more ...; _all?: number | undefined; } | undefined; _avg: { ...; } | undefined; _sum: { ...; } | undefined; _min: { ...; } | undefined; _max: { ...; } | undefined; }'. Type '{ year: string; make: string; model: string; sub_model: string; }' is missing the following properties from type 'PickArray<FitmentGroupByOutputType, FitmentScalarFieldEnum[]>': id, created, modified, available, and 19 more.
Sean Templeton
09/16/2022, 5:46 PMArgument type {sub_model: string, year: string, model: string, make: string}[] is not assignable to parameter type ResolvedValue<unknown>
shahrukh ahmed
09/16/2022, 6:10 PMtransaction_id=22596059218
. Now I want to update this into a Prisma integer field. I convert the query parameter string to an integer with transactionId = parseInt(transaction_id)
and update
await prisma.user.update({
where: { id: userId },
data: {
transactionId,
}
})
The weird bit is, when I check in Prisma studio, the value for transactionId
is 1121222738
. Anyone have an idea?Bryan Z
09/16/2022, 6:36 PMprisma.tagRank.create()
invocation:`when running my app in a docker container but the error doesn't appear when running in local dev and build modes.
Is there a way to get a more detailed log of which part of the .create() invocation is invalid? (ie. is it a syntax problem, arguments the wrong type etc) Thanks.Dwayne Yuen
09/16/2022, 9:10 PMValentin Micu
09/16/2022, 9:59 PMValentin Micu
09/16/2022, 10:01 PMValentin Micu
09/16/2022, 10:02 PMSamuel Corsi-House
09/16/2022, 10:16 PMβ― yarn prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "patch:": patch:@trivago/prettier-plugin-sort-imports@npm%3A3.3.0#~/.yarn/patches/@trivago-prettier-plugin-sort-imports-npm-3.3.0-b578e89971.patch
npm ERR! A complete log of this run can be found in:
npm ERR! /home/xenfo/.npm/_logs/2022-09-16T22_07_41_297Z-debug-0.log
Error: Command failed with exit code 1: npm install @prisma/client@4.3.1
Why is Prisma trying to use NPM when I used Yarn to execute?