@jayfong/x-server 2.113.0 → 2.115.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.
package/lib/_cjs/cli/cli.js
CHANGED
|
File without changes
|
|
@@ -11,8 +11,32 @@ const adapter = new PrismaMariaDb({
|
|
|
11
11
|
user: dbUri.username,
|
|
12
12
|
password: dbUri.password,
|
|
13
13
|
database: dbUri.pathname.slice(1),
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
...(x.env.PRISMA_ADAPTER_OPTIONS || {}),
|
|
14
16
|
});
|
|
15
|
-
export const prismaClient = new PrismaClient({ adapter })
|
|
17
|
+
export const prismaClient = new PrismaClient({ adapter })
|
|
18
|
+
// https://github.com/prisma/prisma/issues/7550#issuecomment-2437006346
|
|
19
|
+
.$extends({
|
|
20
|
+
name: 'findManyAndCount',
|
|
21
|
+
model: {
|
|
22
|
+
$allModels: {
|
|
23
|
+
findManyAndCount<Model, Args>(
|
|
24
|
+
this: Model,
|
|
25
|
+
args: Prisma.Exact<Args, Prisma.Args<Model, 'findMany'>>,
|
|
26
|
+
): Promise<{
|
|
27
|
+
data: Prisma.Result<Model, Args, 'findMany'>;
|
|
28
|
+
total: number;
|
|
29
|
+
}> {
|
|
30
|
+
return prismaClient
|
|
31
|
+
.$transaction([
|
|
32
|
+
(this as any).findMany(args),
|
|
33
|
+
(this as any).count({ where: (args as any).where }),
|
|
34
|
+
])
|
|
35
|
+
.then(([data, total]: any) => ({ data, total }));
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
16
40
|
|
|
17
41
|
x.dispose.add(() => prismaClient.$disconnect());
|
|
18
42
|
|
|
@@ -11,8 +11,32 @@ const adapter = new PrismaMariaDb({
|
|
|
11
11
|
user: dbUri.username,
|
|
12
12
|
password: dbUri.password,
|
|
13
13
|
database: dbUri.pathname.slice(1),
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
...(x.env.PRISMA_ADAPTER_OPTIONS || {}),
|
|
14
16
|
});
|
|
15
|
-
export const prismaClient = new PrismaClient({ adapter })
|
|
17
|
+
export const prismaClient = new PrismaClient({ adapter })
|
|
18
|
+
// https://github.com/prisma/prisma/issues/7550#issuecomment-2437006346
|
|
19
|
+
.$extends({
|
|
20
|
+
name: 'findManyAndCount',
|
|
21
|
+
model: {
|
|
22
|
+
$allModels: {
|
|
23
|
+
findManyAndCount<Model, Args>(
|
|
24
|
+
this: Model,
|
|
25
|
+
args: Prisma.Exact<Args, Prisma.Args<Model, 'findMany'>>,
|
|
26
|
+
): Promise<{
|
|
27
|
+
data: Prisma.Result<Model, Args, 'findMany'>;
|
|
28
|
+
total: number;
|
|
29
|
+
}> {
|
|
30
|
+
return prismaClient
|
|
31
|
+
.$transaction([
|
|
32
|
+
(this as any).findMany(args),
|
|
33
|
+
(this as any).count({ where: (args as any).where }),
|
|
34
|
+
])
|
|
35
|
+
.then(([data, total]: any) => ({ data, total }));
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
16
40
|
|
|
17
41
|
x.dispose.add(() => prismaClient.$disconnect());
|
|
18
42
|
|
package/lib/types/dto.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Merge, OmitStrict, PartialBy, RequiredBy, RequiredDeep, Simplify } from 'vtils/types';
|
|
1
|
+
import type { Merge, OmitStrict, PartialBy, RequiredBy, RequiredDeep, Simplify } from 'vtils/types';
|
|
2
2
|
/** 选中的必填,同时能将部分选填,并能覆盖 */
|
|
3
3
|
export type MakeDtoRequired<TRawData extends Record<any, any>, TPickKey extends keyof TRawData = never, TPartialKey extends [TPickKey] extends [never] ? keyof TRawData : TPickKey = never, TOverride extends {
|
|
4
4
|
[K in [TPickKey] extends [never] ? keyof TRawData : TPickKey]?: any;
|
|
@@ -79,3 +79,8 @@ export type MakeDtoIncludeWithRequiredAndPartial<TRawData extends Record<any, an
|
|
|
79
79
|
} = never> = Simplify<Merge<PartialBy<RequiredBy<Pick<TRawData, TIncludeKey>, TRequiredKey>, TPartialKey>, [
|
|
80
80
|
TOverride
|
|
81
81
|
] extends [never] ? {} : TOverride>>;
|
|
82
|
+
/** 添加分页参数 */
|
|
83
|
+
export type MakeDtoWithPagination<TRawData extends Record<any, any>> = TRawData & {
|
|
84
|
+
pageNumber: number;
|
|
85
|
+
pageSize: number;
|
|
86
|
+
};
|