@nestledjs/api 1.0.2 → 1.0.3
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common'
|
|
2
2
|
import { Prisma, PrismaClient } from '@<%= npmScope %>/api/prisma'
|
|
3
3
|
import { CorePagingInput } from './dto/core-paging.input'
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
|
|
6
6
|
@Injectable()
|
|
7
7
|
export class ApiCoreDataAccessService
|
|
@@ -29,9 +29,16 @@ export class ApiCoreDataAccessService
|
|
|
29
29
|
console.warn('Not Running Prisma Optimize - No API Key Set')
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const { withOptimize } = require('@prisma/extension-optimize')
|
|
32
33
|
const extendedClient = new PrismaClient(config).$extends(withOptimize({ apiKey }))
|
|
33
34
|
Object.assign(this, extendedClient)
|
|
34
|
-
|
|
35
|
+
try {
|
|
36
|
+
const { withOptimize } = require('@prisma/extension-optimize')
|
|
37
|
+
const extendedClient = new PrismaClient(config).$extends(withOptimize({ apiKey }))
|
|
38
|
+
Object.assign(this, extendedClient)
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.warn('Not Running Prisma Optimize - @prisma/extension-optimize not installed or failed to load:', err)
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
public queryCount: number
|
|
@@ -85,8 +92,8 @@ export class ApiCoreDataAccessService
|
|
|
85
92
|
const terms = trimmedSearch.includes(' ')
|
|
86
93
|
? trimmedSearch.split(' ')
|
|
87
94
|
: [trimmedSearch].filter(Boolean)
|
|
88
|
-
const searchFilters = terms.map(
|
|
89
|
-
OR: searchFields.map(
|
|
95
|
+
const searchFilters = terms.map(term => ({
|
|
96
|
+
OR: searchFields.map(field => ({
|
|
90
97
|
[field]: { contains: term, mode: Prisma.QueryMode.insensitive },
|
|
91
98
|
})),
|
|
92
99
|
}))
|
|
@@ -103,3 +110,4 @@ export class ApiCoreDataAccessService
|
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
}
|
|
113
|
+
|