@hedhog/prisma 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
package/dist/prisma.service.d.ts
CHANGED
@@ -7,8 +7,6 @@ export declare class PrismaService extends PrismaClient implements OnModuleInit
|
|
7
7
|
isMysql(): boolean;
|
8
8
|
createInsensitiveSearch(fields: string[], paginationParams: {
|
9
9
|
search: string;
|
10
|
-
}, prismaService: {
|
11
|
-
getProvider: () => string;
|
12
10
|
}): any[];
|
13
11
|
}
|
14
12
|
//# sourceMappingURL=prisma.service.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prisma.service.d.ts","sourceRoot":"","sources":["../src/prisma.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBACa,aAAc,SAAQ,YAAa,YAAW,YAAY;IAC/D,YAAY;IAIlB,WAAW;IAIX,UAAU;IAIV,OAAO;IAIP,uBAAuB,CACrB,MAAM,EAAE,MAAM,EAAE,EAChB,gBAAgB,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,
|
1
|
+
{"version":3,"file":"prisma.service.d.ts","sourceRoot":"","sources":["../src/prisma.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBACa,aAAc,SAAQ,YAAa,YAAW,YAAY;IAC/D,YAAY;IAIlB,WAAW;IAIX,UAAU;IAIV,OAAO;IAIP,uBAAuB,CACrB,MAAM,EAAE,MAAM,EAAE,EAChB,gBAAgB,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GACnC,GAAG,EAAE;CAmBT"}
|
package/dist/prisma.service.js
CHANGED
@@ -22,17 +22,20 @@ let PrismaService = class PrismaService extends client_1.PrismaClient {
|
|
22
22
|
isMysql() {
|
23
23
|
return this.getProvider() === 'mysql';
|
24
24
|
}
|
25
|
-
createInsensitiveSearch(fields, paginationParams
|
25
|
+
createInsensitiveSearch(fields, paginationParams) {
|
26
26
|
const OR = fields.map((field) => ({
|
27
27
|
[field]: { contains: paginationParams.search },
|
28
28
|
}));
|
29
|
-
if (
|
29
|
+
if (this.isPostgres()) {
|
30
30
|
OR.forEach((condition) => {
|
31
31
|
Object.keys(condition).forEach((key) => {
|
32
32
|
condition[key].mode = 'insensitive';
|
33
33
|
});
|
34
34
|
});
|
35
35
|
}
|
36
|
+
if (!isNaN(+paginationParams.search)) {
|
37
|
+
OR.push({ id: { equals: +paginationParams.search } });
|
38
|
+
}
|
36
39
|
return OR;
|
37
40
|
}
|
38
41
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prisma.service.js","sourceRoot":"","sources":["../src/prisma.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA0D;AAC1D,2CAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,qBAAY;IAC7C,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,WAAW;QACT,OAAQ,IAAY,CAAC,aAAa,CAAC,cAAc,CAAC;IACpD,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;IACxC,CAAC;IAED,uBAAuB,CACrB,MAAgB,EAChB,gBAAoC
|
1
|
+
{"version":3,"file":"prisma.service.js","sourceRoot":"","sources":["../src/prisma.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA0D;AAC1D,2CAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,qBAAY;IAC7C,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,WAAW;QACT,OAAQ,IAAY,CAAC,aAAa,CAAC,cAAc,CAAC;IACpD,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;IACxC,CAAC;IAED,uBAAuB,CACrB,MAAgB,EAChB,gBAAoC;QAEpC,MAAM,EAAE,GAAQ,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACrC,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,gBAAgB,CAAC,MAAM,EAAE;SAC/C,CAAC,CAAC,CAAC;QAEJ,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACtB,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACvB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;oBACpC,SAAS,CAAC,GAAG,CAAS,CAAC,IAAI,GAAG,aAAa,CAAC;gBAC/C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAA;AAvCY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CAuCzB"}
|
package/package.json
CHANGED
package/src/prisma.service.ts
CHANGED
@@ -22,13 +22,12 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
|
|
22
22
|
createInsensitiveSearch(
|
23
23
|
fields: string[],
|
24
24
|
paginationParams: { search: string },
|
25
|
-
prismaService: { getProvider: () => string },
|
26
25
|
): any[] {
|
27
|
-
const OR = fields.map((field) => ({
|
26
|
+
const OR: any = fields.map((field) => ({
|
28
27
|
[field]: { contains: paginationParams.search },
|
29
28
|
}));
|
30
29
|
|
31
|
-
if (
|
30
|
+
if (this.isPostgres()) {
|
32
31
|
OR.forEach((condition) => {
|
33
32
|
Object.keys(condition).forEach((key) => {
|
34
33
|
(condition[key] as any).mode = 'insensitive';
|
@@ -36,6 +35,10 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
|
|
36
35
|
});
|
37
36
|
}
|
38
37
|
|
38
|
+
if (!isNaN(+paginationParams.search)) {
|
39
|
+
OR.push({ id: { equals: +paginationParams.search } });
|
40
|
+
}
|
41
|
+
|
39
42
|
return OR;
|
40
43
|
}
|
41
44
|
}
|