Ridhwaan Shakeel
10/19/2022, 3:40 AM```
ready = true;
ready && sync();
const sync = async () => {
/* some logic * /
jsonCollection.length &&
(await upsertManyA(
jsonCollection.filter((obj) => obj.startsWith(A))
));
jsonCollection.length &&
(await upsertManyB(
jsonCollection.filter((obj) => obj.startsWith(B))
));
jsonCollection.length &&
(await upsertManyC(
jsonCollection.filter((obj) => obj.startsWith(C))
));
/* finish */
};
```
const upsertManyA, upsertManyB, upsertManyC
are async
methods that each make an async
request to an api service then perform an async
prisma upsert
upsertManyA
(first method) runs normally, but upsertManyB
(second method) throws a timeout error everytime when it starts. All async/await methods above are expected to run in serial
node_modules/@prisma/client/runtime/index.js:30855
[0] throw new PrismaClientUnknownRequestError(message, this.client._clientVersion);
[0] ^
[0]
[0] PrismaClientUnknownRequestError:
[0] Invalid `prisma.notAvailable.upsert()` invocation:
[0]
[0]
[0] Error occurred during query execution:
[0] ConnectorError(ConnectorError { user_facing_error: None, kind: ConnectionError(Timed out during query execution.) })
[0] at RequestHandler.handleRequestError (/node_modules/@prisma/client/runtime/index.js:30855:13)
[0] at RequestHandler.request (/node_modules/@prisma/client/runtime/index.js:30834:12)
[0] at async PrismaClient._request (/node_modules/@prisma/client/runtime/index.js:31812:16)
[0] at async upsertNotAvailable (file:/index.js:313:3) {
[0] clientVersion: '4.4.0'
[0] }
[0]
[0] Node.js v18.11.0
feedback appreciated
thanksMax
10/19/2022, 4:39 AMnew
, packing
, shipped
. Each different state has additional fields tracking when the state was entered and other information. I'd like to create the schema so that I can query across all the different states. This is what I have so far:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
type LineItem {
productId String
name String
quantity Int
}
enum Status {
NEW
PACKING
SHIPPED
}
model NewOrder {
id String @id @default(auto()) @map("_id") @db.ObjectId
status Status @default(NEW)
lineItems LineItem[]
createdAt DateTime @default(now())
}
model PackingOrder {
id String @id @default(auto()) @map("_id") @db.ObjectId
status Status @default(PACKING)
lineItems LineItem[]
createdAt DateTime
packingStartedAt DateTime @default(now())
}
model ShippedOrder {
id String @id @default(auto()) @map("_id") @db.ObjectId
status Status @default(SHIPPED)
lineItems LineItem[]
createdAt DateTime
packingStartedAt DateTime
shippedAt DateTime @default(now())
}
Is there it possible to achieve this or am I barking up the wrong tree?
Thanks!Javier Tarazaga Gomez
10/19/2022, 5:19 AMJavier Tarazaga Gomez
10/19/2022, 5:22 AMKlaus
10/19/2022, 9:50 AMKlaus
10/19/2022, 9:53 AMKenny Tran
10/19/2022, 10:29 AMven v
10/19/2022, 1:59 PMPatrick
10/19/2022, 3:04 PMSebastian Gug
10/19/2022, 3:16 PMthis.client.user.update({
where: { id },
data: { emailVerificationSendCount: +1 },
});
Sebastian Gug
10/19/2022, 3:16 PMSebastian Gug
10/19/2022, 3:16 PMSebastian Gug
10/19/2022, 4:06 PMprisma.$transaction(async (tx) => {
but this throws a type error now Argument of type '(tx: any) => void' is not assignable to parameter of type 'PrismaPromise<any>[]'
what even is a PrismaPromise? and if it's an array, how am I supposed to benefit from the result of one of those operations for incrementing purposes?Sebastian Gug
10/19/2022, 4:07 PMAlex Vilchis
10/19/2022, 4:55 PMcreateMany
? Something like this:
const result = await prisma.payment.createMany({
data: [...]
});
const createdPayments = await prisma.payment.findMany({
where: {
id: {
in: result.ids, // THIS IS NOT POSSIBLE
},
},
});
Any possible workarounds?Gerardo Gomez
10/19/2022, 6:37 PMtoSQL()
function? I’ve seen other ORMs that have this functionality. I don’t need to log this query (I saw that functionality) I need the raw statement at the moment the code is runVivek Yadav
10/19/2022, 8:56 PMSebastian Gug
10/20/2022, 12:14 AMKenny Tran
10/20/2022, 5:33 AMaggrigate
to sum up a field within a relation query. Have a look at the my query below -
const profiles = await prisma.profile.findMany({
include: {
offer: true,
meeting: true,
sale: true
},
orderBy: {
points: "desc"
},
take: 10
})
I want to get the sum of offer, meeting and sale, IndividuallyDuckyDev
10/20/2022, 7:08 AMjames tan
10/20/2022, 7:40 AMAndy Pickler
10/20/2022, 10:02 AMconstructor(message: string, clientVersion: string, errorCode?: string) {
super(message)
this.clientVersion = clientVersion
this.errorCode = errorCode
Error.captureStackTrace(PrismaClientInitializationError)
}
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#custom_error_types
• https://nodejs.org/dist/latest-v16.x/docs/api/errors.html#errorcapturestacktracetargetobject-constructoropt
what I believe is correct:
constructor(message: string, clientVersion: string, errorCode?: string) {
super(message)
this.clientVersion = clientVersion
this.errorCode = errorCode
Error.captureStackTrace(this, PrismaClientInitializationError)
}
I am up for contributing a PR, but first I am curious if there was an intentional design around capturing the stack trace in this manner.Marek Brzeziński
10/20/2022, 10:47 AMprisma db pull
to automatically update schema with the imported data tables? 🤔Sebastian Gug
10/20/2022, 11:22 AMSebastian Gug
10/20/2022, 11:25 AMconst {execSync} = require('child_process');
let output = execSync('npx prisma migrate');
this seems uhhh, a bit hacky for some reasonDan Calise
10/20/2022, 1:11 PMDateTime
type, I see this when making my query:
Inconsistent column data: Conversion failed: input contains invalid characters
I also try defining it as a string to see if I could just get the raw string output of 7/28/22 4:56:51 PM
, that didn’t work.
I tried adding it as an unsupported type and using queryRaw
, but I get:
Invalid `prisma.$queryRaw()` invocation:
Raw query failed. Code: `N/A`. Message: `N/A`
Any ideas?
edit: I ran the same sql query directly on the db to make sure the sql was valid and it worked just fine.mazhar iqbal
10/20/2022, 1:15 PMAlban Kaperi
10/20/2022, 2:04 PMAlban Kaperi
10/20/2022, 2:04 PMAlban Kaperi
10/20/2022, 2:05 PMwhere: {
day: {
gte: new Date('2022-10-20'),
lte: new Date('2022-10-25'),
},
},