prisma-generator-express 1.34.4 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -487,21 +487,29 @@ export async function findManyPaginated(
|
|
|
487
487
|
const shape = ctx.guardShape
|
|
488
488
|
const caller = ctx.guardCaller
|
|
489
489
|
const distinctCountLimit = ctx.paginationConfig?.distinctCountLimit
|
|
490
|
+
const delegate = (extended as any).${modelNameLower}
|
|
490
491
|
|
|
491
492
|
if (shape) {
|
|
492
|
-
assertGuard(
|
|
493
|
+
assertGuard(delegate)
|
|
493
494
|
}
|
|
494
495
|
|
|
495
496
|
let items: any[]
|
|
496
497
|
let total: number
|
|
497
498
|
|
|
498
|
-
if (typeof extended.$transaction
|
|
499
|
+
if (shape || typeof extended.$transaction !== 'function') {
|
|
500
|
+
const [data, count] = await Promise.all([
|
|
501
|
+
shape
|
|
502
|
+
? delegate.guard(shape, caller).findMany(query)
|
|
503
|
+
: delegate.findMany(query),
|
|
504
|
+
countForPagination(delegate, query, shape, caller, distinctCountLimit),
|
|
505
|
+
])
|
|
506
|
+
items = data
|
|
507
|
+
total = count
|
|
508
|
+
} else {
|
|
499
509
|
try {
|
|
500
510
|
const txResult = await extended.$transaction(async (tx: any) => {
|
|
501
|
-
const d =
|
|
502
|
-
|
|
503
|
-
: await tx.${modelNameLower}.findMany(query)
|
|
504
|
-
const t = await countForPagination(tx.${modelNameLower}, query, shape, caller, distinctCountLimit)
|
|
511
|
+
const d = await tx.${modelNameLower}.findMany(query)
|
|
512
|
+
const t = await countForPagination(tx.${modelNameLower}, query, undefined, undefined, distinctCountLimit)
|
|
505
513
|
return { d, t }
|
|
506
514
|
})
|
|
507
515
|
items = txResult.d
|
|
@@ -514,31 +522,12 @@ export async function findManyPaginated(
|
|
|
514
522
|
console.warn(
|
|
515
523
|
'[prisma-generator-express] Interactive transactions not available, pagination queries are non-atomic',
|
|
516
524
|
)
|
|
517
|
-
items =
|
|
518
|
-
|
|
519
|
-
: await (extended as any).${modelNameLower}.findMany(query)
|
|
520
|
-
total = await countForPagination(
|
|
521
|
-
(extended as any).${modelNameLower},
|
|
522
|
-
query,
|
|
523
|
-
shape,
|
|
524
|
-
caller,
|
|
525
|
-
distinctCountLimit,
|
|
526
|
-
)
|
|
525
|
+
items = await delegate.findMany(query)
|
|
526
|
+
total = await countForPagination(delegate, query, undefined, undefined, distinctCountLimit)
|
|
527
527
|
} else {
|
|
528
528
|
throw txError
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
} else {
|
|
532
|
-
items = shape
|
|
533
|
-
? await (extended as any).${modelNameLower}.guard(shape, caller).findMany(query)
|
|
534
|
-
: await (extended as any).${modelNameLower}.findMany(query)
|
|
535
|
-
total = await countForPagination(
|
|
536
|
-
(extended as any).${modelNameLower},
|
|
537
|
-
query,
|
|
538
|
-
shape,
|
|
539
|
-
caller,
|
|
540
|
-
distinctCountLimit,
|
|
541
|
-
)
|
|
542
531
|
}
|
|
543
532
|
|
|
544
533
|
const skip = (query.skip as number) ?? 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateOperationCore.js","sourceRoot":"","sources":["../../src/generators/generateOperationCore.ts"],"names":[],"mappings":";;AAEA,4DAuXC;AAMD,
|
|
1
|
+
{"version":3,"file":"generateOperationCore.js","sourceRoot":"","sources":["../../src/generators/generateOperationCore.ts"],"names":[],"mappings":";;AAEA,4DAuXC;AAMD,8CAwKC;AAriBD,SAAgB,wBAAwB;IACtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
500
500
|
const caller = ctx.guardCaller
|
|
501
501
|
const distinctCountLimit = ctx.paginationConfig?.distinctCountLimit
|
|
502
|
+
const delegate = (extended as any).${modelNameLower}
|
|
502
503
|
|
|
503
504
|
if (shape) {
|
|
504
|
-
assertGuard(
|
|
505
|
+
assertGuard(delegate)
|
|
505
506
|
}
|
|
506
507
|
|
|
507
508
|
let items: any[]
|
|
508
509
|
let total: number
|
|
509
510
|
|
|
510
|
-
if (typeof extended.$transaction
|
|
511
|
+
if (shape || typeof extended.$transaction !== 'function') {
|
|
512
|
+
const [data, count] = await Promise.all([
|
|
513
|
+
shape
|
|
514
|
+
? delegate.guard(shape, caller).findMany(query)
|
|
515
|
+
: delegate.findMany(query),
|
|
516
|
+
countForPagination(delegate, query, shape, caller, distinctCountLimit),
|
|
517
|
+
])
|
|
518
|
+
items = data
|
|
519
|
+
total = count
|
|
520
|
+
} else {
|
|
511
521
|
try {
|
|
512
522
|
const txResult = await extended.$transaction(async (tx: any) => {
|
|
513
|
-
const d =
|
|
514
|
-
|
|
515
|
-
: await tx.${modelNameLower}.findMany(query)
|
|
516
|
-
const t = await countForPagination(tx.${modelNameLower}, query, shape, caller, distinctCountLimit)
|
|
523
|
+
const d = await tx.${modelNameLower}.findMany(query)
|
|
524
|
+
const t = await countForPagination(tx.${modelNameLower}, query, undefined, undefined, distinctCountLimit)
|
|
517
525
|
return { d, t }
|
|
518
526
|
})
|
|
519
527
|
items = txResult.d
|
|
@@ -526,31 +534,12 @@ export async function findManyPaginated(
|
|
|
526
534
|
console.warn(
|
|
527
535
|
'[prisma-generator-express] Interactive transactions not available, pagination queries are non-atomic',
|
|
528
536
|
)
|
|
529
|
-
items =
|
|
530
|
-
|
|
531
|
-
: await (extended as any).${modelNameLower}.findMany(query)
|
|
532
|
-
total = await countForPagination(
|
|
533
|
-
(extended as any).${modelNameLower},
|
|
534
|
-
query,
|
|
535
|
-
shape,
|
|
536
|
-
caller,
|
|
537
|
-
distinctCountLimit,
|
|
538
|
-
)
|
|
537
|
+
items = await delegate.findMany(query)
|
|
538
|
+
total = await countForPagination(delegate, query, undefined, undefined, distinctCountLimit)
|
|
539
539
|
} else {
|
|
540
540
|
throw txError
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
} else {
|
|
544
|
-
items = shape
|
|
545
|
-
? await (extended as any).${modelNameLower}.guard(shape, caller).findMany(query)
|
|
546
|
-
: await (extended as any).${modelNameLower}.findMany(query)
|
|
547
|
-
total = await countForPagination(
|
|
548
|
-
(extended as any).${modelNameLower},
|
|
549
|
-
query,
|
|
550
|
-
shape,
|
|
551
|
-
caller,
|
|
552
|
-
distinctCountLimit,
|
|
553
|
-
)
|
|
554
543
|
}
|
|
555
544
|
|
|
556
545
|
const skip = (query.skip as number) ?? 0
|