How to filter the SpaceX API (mongoDB find() based) by a nested array?! Tech Test
I'm stuck on a tech test where I need to call the spaceX API and filter all launches in the response based on an array of payloads including a specific nationality string. The the response normally has only a list of payload ids, but the full payload data is populated via options object.
I've been going through all the mongoDB docs trying to get my head around the syntax, but keep either getting all data unfiltered, or none, or an error. Been trying for days, and the I know from the recruiter that others have failed because they failed to add in this specific filter in past tech tests. I'm currently getting this error:
Cast to ObjectId failed for value "{ nationalities: 'United States' }" (type Object) at path "payloads" for model "Launch"
Cast to ObjectId failed for value "{ nationalities: 'United States' }" (type Object) at path "payloads" for model "Launch"
:rocket: Open Source REST API for SpaceX launch, rocket, core, capsule, starlink, launchpad, and landing pad data. - SpaceX-API/queries.md at master · r-spacex/SpaceX-API