Closed
Description
Describe the Bug
Imagine a taxonomy where 5 or more collections are related to each other, like this:
Company -> Team -> Employee -> Project -> Task
Now imagine that you might want to query for all of the tasks that are held by one team. You could (and can) do this with Payload, like this:
payload.find({
collection: "tasks",
where: {
"project.employee.team": {
equals: myTeamId,
}
}
});
This works correctly, but if you go one-level deeper, and try to (for example) get all of the tasks held by the entire company, you encounter a bug. This would return an empty set of docs
:
payload.find({
collection: "tasks",
where: {
"project.employee.team.company": {
equals: myCompanyId,
}
}
});
Link to the code that reproduces this issue
https://github.com/ryami333/payload-nested-where-repro/tree/main/test/_community
Reproduction Steps
- Create at least 5 collections, each associated to the next by a
"relationship"
field (Eg. Companies, Teams, Employees, Projects, Tasks) - Populate each collection with docs, using the relationship fields to "nest" the data like this:
Apple/
├── …
└── Engineering/
├── …
└── Mitch/
├── …
└── Data Lake Migration/
├── …
├── Design Schema Migration
├── Implement Data Transfer
├── Validate Data Integrity
└── Decommission Old System
- Try to query across 4 (or more) relationship boundaries like in my example above (eg. "get all tasks in my company").
- You'll receive an empty array of docs.
Which area(s) are affected? (Select all that apply)
Not sure
Environment Info
See reproduction.
Metadata
Metadata
Assignees
Labels
No labels