Hey guys,
I encountered an issue where querying nested relational properties returns an empty array. This previously worked in earlier versions:
Here's the full info of this issue: https://github.com/payloadcms/payload/discussions/9852
I might be overlooking things, but the previous version worked:
"next": "15.0.0-canary.104",
"payload": "3.0.0-beta.91"
After updating the query doesnt return any obhects. anymore:
"next": "15.0.3",
"payload": "3.4.0"
locationSlug: string,
options?: { locale?: string; draft?: boolean },
) => {
const payload = await getPayload({ config });
console.log(`Fetching apartments for location: ${locationSlug}`);
const { docs: apartments } = await payload.find({
collection: "apartments",
where: {
"location.slug": {
equals: locationSlug,
},
},
depth: 2,
locale: validateLocale(options?.locale),
limit: 1000,
sort: "priority",
});
console.log("Apartments:", apartments);
return apartments;
};
Expected Behavior:
The function should return all apartments where location.slug matches the locationSlug parameter.
Current Behavior:
The docs array is empty ([]), even though apartments with the specified location.slug exist in the database.
Admin Panel Issue:
When trying to filter apartments by the location relation in the admin panel, no results are returned.
Would really appreaciate any help! 🙏