Mongoose find filtering by attached document Mongoose find filtering by attached document mongoose mongoose

Mongoose find filtering by attached document


finally I solved it doing this:

 const packages = await Package.find({'profile' : profile._id}).select('_id').exec();    const ids: any = packages.map( (pkg: any) => {        return pkg._id;    }); return Booking.find( {'package': {$in: ids}} ) .....

Is there another better solution?