How to get all objects in relation and their fields?

Hello, I’m tired of trying,
Problem: I have Team object with relation to TeamLocation object (one-to-many)
now i want to get all available teamLocations in team as below with teamLocations subfields.

        const Team = Parse.Object.extend('team');
        const Location = Parse.Object.extend('teamLocation');
        const locationQuery = await new Parse.Query(Location).findAll();
        const teamQuery = await new Parse.Query(Team).equalTo('objectId',data.params.teamId);
        await teamQuery.equalTo('locations', locationQuery).findAll();
        console.log(teamQuery.includeAll());
        console.log(teamQuery._where);

result of console.log()
image

The result is [Objects] how to get to the data of such an object, because I would like to filter the list of teamLocations that belong to a given team.

I’m not sure I’ve got this exactly right but you can use matchesQuery for querying relations

const Team = Parse.Object.extend('team');
const Location = Parse.Object.extend('teamLocation');
const teamQuery = new Parse.Query(Team).equalTo('objectId',data.params.teamId);
const query = new Parse.Query(Team)
query.matchesQuery("locations", teamQuery)
const result = await query.findAll();
console.log(result)
        const Team = Parse.Object.extend('team');
        const Location = Parse.Object.extend('teamLocation');
        const innerQuery = new Parse.Query(Location);
        const query = new Parse.Query(Team);
        query.matchesQuery('locations', innerQuery);

        const result = await query.find();
        console.log(result);

yes i was trying it but this solution returning me existing team object not their teamLocation:
image

where am i making a mistake?

const query = new Parse.Query(Team);
query.equalTo("objectId", id)
// you might be able to use query.include("locations")
const team = await query.first()
const locationsQuery = team.relation("locations").query()
const locations = await locationsQuery.find()
1 Like