fix(db-mongodb): joins with singular collection name (#8933)

### What?
Properly specifies `$lookup.from` when the collection name is singular.

### Why?
MongoDB can pluralize the collection name and so can be different for
singular ones.

### How?
Uses the collection name from the driver directly
`adapter.collections[slug].collection.name` instead of just `slug`.
This commit is contained in:
Sasha
2024-10-30 18:06:03 +02:00
committed by GitHub
parent 123125185c
commit f4041ce6e2
6 changed files with 62 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import type { CollectionConfig } from 'payload'
import { categoriesSlug, postsSlug } from '../shared.js'
import { singularSlug } from './Singular.js'
export const Categories: CollectionConfig = {
slug: categoriesSlug,
@@ -83,5 +84,11 @@ export const Categories: CollectionConfig = {
},
],
},
{
name: 'singulars',
type: 'join',
collection: singularSlug,
on: 'category',
},
],
}