fix(db-postgres): joins count with hasMany relationships (#14008)

Fixes https://github.com/payloadcms/payload/issues/13950
This commit is contained in:
Sasha
2025-10-01 18:38:54 +03:00
committed by GitHub
parent 267ea9ea36
commit 1510e125ab
2 changed files with 26 additions and 8 deletions

View File

@@ -215,6 +215,18 @@ describe('Joins Field', () => {
expect(categoryWithPosts.group.relatedPosts?.totalDocs).toBe(15)
})
it('should count hasMany relationship joins', async () => {
const res = await payload.findByID({
id: category.id,
collection: categoriesSlug,
joins: {
hasManyPosts: { limit: 1, count: true },
},
})
expect(res.hasManyPosts?.totalDocs).toBe(15)
})
it('should populate relationships in joins', async () => {
const { docs } = await payload.find({
limit: 1,