@@ -488,6 +488,7 @@ export function getFindBatchLoadFn<Entity extends object>(
488
488
for ( const [ key , value ] of Object . entries ( filter ) ) {
489
489
const entityValue = entity [ key as keyof K ] ;
490
490
if ( Array . isArray ( value ) ) {
491
+ // Our current filter is an array
491
492
if ( Array . isArray ( entityValue ) ) {
492
493
// Collection
493
494
if ( ! value . every ( ( el ) => entityValue . includes ( el ) ) ) {
@@ -500,8 +501,10 @@ export function getFindBatchLoadFn<Entity extends object>(
500
501
}
501
502
}
502
503
} else {
503
- // Object: recursion
504
- if ( ! filterResult ( entityValue as object , value ) ) {
504
+ // Our current filter is an object
505
+ if ( entityValue instanceof Collection ) {
506
+ entityValue . find ( ( entity ) => filterResult ( entity , value ) ) ;
507
+ } else if ( ! filterResult ( entityValue as object , value ) ) {
505
508
return false ;
506
509
}
507
510
}
@@ -522,9 +525,6 @@ export function optsMapToQueries<Entity extends object>(
522
525
populate : options . populate === true ? [ "*" ] : Array . from ( options . populate ) ,
523
526
} ) ,
524
527
} satisfies Pick < FindOptions < any , any > , "populate" > ;
525
- console . log ( "entityName" , entityName ) ;
526
- console . log ( "filter" , filter ) ;
527
- console . log ( "findOptions" , findOptions ) ;
528
528
const entities = await em . find ( entityName , filter , findOptions ) ;
529
529
return [ key , entities ] ;
530
530
} ) ;
0 commit comments