@hedhog/prisma 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,EACpC,aAAa,EAAE;QAAE,WAAW,EAAE,MAAM,MAAM,CAAA;KAAE,GAC3C,GAAG,EAAE;CAeT"}
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"}
@@ -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, prismaService) {
25
+ createInsensitiveSearch(fields, paginationParams) {
26
26
  const OR = fields.map((field) => ({
27
27
  [field]: { contains: paginationParams.search },
28
28
  }));
29
- if (prismaService.getProvider() === 'postgres') {
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,EACpC,aAA4C;QAE5C,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAChC,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,gBAAgB,CAAC,MAAM,EAAE;SAC/C,CAAC,CAAC,CAAC;QAEJ,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE,CAAC;YAC/C,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACvB,MAAM,C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C,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
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@hedhog/prisma",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "build": "tsc && npm version patch",
7
+ "build": "tsc --project tsconfig.production.json && npm version patch",
8
8
  "prod": "npm run build && npm publish --access public"
9
9
  },
10
10
  "keywords": [],
@@ -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 (prismaService.getProvider() === 'postgres') {
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
  }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "experimentalDecorators": true,
4
+ "target": "es2017",
5
+ "module": "commonjs",
6
+ "lib": ["es2017", "es7", "es6"],
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "sourceMap": true,
10
+ "outDir": "./dist",
11
+ "rootDir": "./src",
12
+ "strict": true,
13
+ "noImplicitAny": false,
14
+ "strictNullChecks": false,
15
+ "allowSyntheticDefaultImports": true,
16
+ "esModuleInterop": true,
17
+ "emitDecoratorMetadata": true
18
+ },
19
+ "exclude": ["node_modules", "dist"]
20
+ }