#1365·SpaceX-API

Nested query not working

Author: GyurmatagCreated Dec 4, 2024Updated Jan 11, 2025

I want to filter for the nationalities in the "launches" query like this:

{
    query: nationality ? { "payloads.nationalities": nationality } : {},
     options: {
         sort: { "date_utc": "desc" },
         page,
         limit,
        populate: ["payloads"],
      },
},

But this gives me no items back... There is a 2 year old issue where others also couldn't solve this. Probably this might be a bug inside the backend, maybe here:

// Query launches
router.post('/query', cache(20), async (ctx) => {
  const { query = {}, options = {} } = await transformQuery(ctx.request.body);
  try {
    const result = await Launch.paginate(query, options);
    ctx.status = 200;
    ctx.body = await transformResponse(result);
  } catch (error) {
    ctx.throw(400, error.message);
  }
});

or somewhere in the _transform-query.js file

Does anybody has any idea on this? How we can solve it?

Thank you very much!