I experience some unexpected behaviour of the local API. I set a where query to filter on a value of a relationship of the document.
something like:
const where: Where = {
"relationship.title": {
equals: "test"
}
}I expect that the where query can resolve the relationship (especially if I specify a high enough depth value) and returns documents which have a relationship to a document with title "test". The current behaviour is that I can only specify this by id ( relationship: id ). At the latest if I want to filter on a relation of the relationship this is not worling any more.
Is this a bug or intended?
Hi, im having a similar issue.
I try to filter projects like this:
const projects = await payload.find({
collection: "projects",
depth: 1,
limit: 12,
where: {
"industries.title": {
equals: "Architecture",
},
},
overrideAccess: false,
locale: lang,
fallbackLocale: "de",
});But it doesnt seem to work. Any recommendations for filtering by relationship?
it's also important to include the database adapter that you're using for these types of questions, at first sight it
shouldwork
Im using "
@967091941873426493/db-mongodb": "3.0.0-beta.71". Should i try to revert to an older version?
Im so confused. I tried it with categories.title (completly similar to the industries collection) and thats working.. At least i can progress now checking my code
I'm new to this, so I tried to replicate your problem to educate myself, and in my situation the code that you've provided worked*. I did have to remove the "locale" & "fallbackLocale" properties, because I ain't using them (including them would return an empty array). The "overrideAccess" has also been removed, since in the way I was executing this method, I was not authenticated.
I suppose that your definition of "not working" refers to retrieving an empty array?
I finally found the issue!
some documents inside the categories collection had localized entries like:
title: {
en: "Corporate"
de: "Corporate"
}
some just had title: "Architektur"
and some just had one locale entry...
I guess its because i changed the scheme while developing.
I would love some more error messages or indicators that there are missing entries in other languages, its hard to debug that kind of stuff..
Glad to hear that you were able to resolve it! I had the same conclusion when I was working on the [reset password flow](
https://github.com/payloadcms/payload/discussions/7487) this afternoon.
What kind of error messages were you expacting? It sounds like the scheme got messed up during development and you'd like to have some sort of "health-check" process, that would go through all entries in a collection, validate them and create some sort of report to communicate the differences/inconsistencies between the database objects?
Hey
@1128321779702706186the best path forward for this, as it sounds like something we don't yet offer in Payload would be to open a discussion on GitHub. We review those quite frequently and then assign priority in our roadmap.
It's not a huge deal—but please refrain from cross-posting in other channels when your have an open community help thread. I see this has been open for awhile, which is why I'd suggesting logging this on GitHub in detail as it's easy for this stuff to get lost in Discord.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.