@@ -255,23 +255,33 @@ export class ClientImpl<Schema extends SchemaDef> {
255
255
}
256
256
257
257
$use ( plugin : RuntimePlugin < Schema > ) {
258
- const newOptions = {
258
+ // tsc perf
259
+ const newPlugins : RuntimePlugin < Schema > [ ] = [ ...( this . $options . plugins ?? [ ] ) , plugin ] ;
260
+ const newOptions : ClientOptions < Schema > = {
259
261
...this . options ,
260
- plugins : [ ... ( this . options . plugins ?? [ ] ) , plugin ] ,
262
+ plugins : newPlugins ,
261
263
} ;
262
264
return new ClientImpl < Schema > ( this . schema , newOptions , this ) ;
263
265
}
264
266
265
267
$unuse ( pluginId : string ) {
266
- const newOptions = {
268
+ // tsc perf
269
+ const newPlugins : RuntimePlugin < Schema > [ ] = [ ] ;
270
+ for ( const plugin of this . options . plugins ?? [ ] ) {
271
+ if ( plugin . id !== pluginId ) {
272
+ newPlugins . push ( plugin ) ;
273
+ }
274
+ }
275
+ const newOptions : ClientOptions < Schema > = {
267
276
...this . options ,
268
- plugins : this . options . plugins ?. filter ( ( p ) => p . id !== pluginId ) ,
277
+ plugins : newPlugins ,
269
278
} ;
270
279
return new ClientImpl < Schema > ( this . schema , newOptions , this ) ;
271
280
}
272
281
273
282
$unuseAll ( ) {
274
- const newOptions = {
283
+ // tsc perf
284
+ const newOptions : ClientOptions < Schema > = {
275
285
...this . options ,
276
286
plugins : [ ] as RuntimePlugin < Schema > [ ] ,
277
287
} ;
@@ -388,7 +398,7 @@ function createModelCrudHandler<Schema extends SchemaDef, Model extends GetModel
388
398
for ( const plugin of plugins ) {
389
399
if ( plugin . onQuery && typeof plugin . onQuery === 'object' ) {
390
400
// for each model key or "$allModels"
391
- for ( const [ _model , modelHooks ] of Object . entries ( plugin . onQuery ) ) {
401
+ for ( const [ _model , modelHooks ] of Object . entries < any > ( plugin . onQuery ) ) {
392
402
if ( _model === lowerCaseFirst ( model ) || _model === '$allModels' ) {
393
403
if ( modelHooks && typeof modelHooks === 'object' ) {
394
404
// for each operation key or "$allOperations"
0 commit comments