@@ -488,6 +488,7 @@ export function getFindBatchLoadFn<Entity extends object>(
488488 for ( const [ key , value ] of Object . entries ( filter ) ) {
489489 const entityValue = entity [ key as keyof K ] ;
490490 if ( Array . isArray ( value ) ) {
491+ // Our current filter is an array
491492 if ( Array . isArray ( entityValue ) ) {
492493 // Collection
493494 if ( ! value . every ( ( el ) => entityValue . includes ( el ) ) ) {
@@ -500,8 +501,10 @@ export function getFindBatchLoadFn<Entity extends object>(
500501 }
501502 }
502503 } 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 ) ) {
505508 return false ;
506509 }
507510 }
@@ -522,9 +525,6 @@ export function optsMapToQueries<Entity extends object>(
522525 populate : options . populate === true ? [ "*" ] : Array . from ( options . populate ) ,
523526 } ) ,
524527 } satisfies Pick < FindOptions < any , any > , "populate" > ;
525- console . log ( "entityName" , entityName ) ;
526- console . log ( "filter" , filter ) ;
527- console . log ( "findOptions" , findOptions ) ;
528528 const entities = await em . find ( entityName , filter , findOptions ) ;
529529 return [ key , entities ] ;
530530 } ) ;
0 commit comments