### What? - Fixed an issue where group-by enabled collections with `trash: true` were not showing trashed documents in the collection’s trash view. - Ensured that the `trash` query argument is properly passed to the `findDistinct` call within `handleGroupBy`, allowing trashed documents to be included in grouped list views. ### Why? Previously, when viewing the trash view of a collection with both **group-by** and **trash** enabled, trashed documents would not appear. This was caused by the `trash` argument not being forwarded to `findDistinct` in `handleGroupBy`, which resulted in empty or incorrect group-by results. ### How? - Passed the `trash` flag through all relevant `findDistinct` and `find` calls in `handleGroupBy`.
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
import type { Payload } from 'payload'
|
|
|
|
import { devUser } from '../credentials.js'
|
|
import { executePromises } from '../helpers/executePromises.js'
|
|
import { seedDB } from '../helpers/seed.js'
|
|
import { categoriesSlug } from './collections/Categories/index.js'
|
|
import { postsSlug } from './collections/Posts/index.js'
|
|
|
|
export const seed = async (_payload: Payload) => {
|
|
await executePromises(
|
|
[
|
|
() =>
|
|
_payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
depth: 0,
|
|
overrideAccess: true,
|
|
}),
|
|
async () => {
|
|
const [category1, category2] = await Promise.all([
|
|
_payload.create({
|
|
collection: categoriesSlug,
|
|
data: {
|
|
title: 'Category 1',
|
|
},
|
|
}),
|
|
_payload.create({
|
|
collection: categoriesSlug,
|
|
data: {
|
|
title: 'Category 2',
|
|
},
|
|
}),
|
|
])
|
|
|
|
await Promise.all(
|
|
Array.from({ length: 30 }).map(async (_, index) =>
|
|
_payload.create({
|
|
collection: postsSlug,
|
|
data: {
|
|
title: `Post ${index + 1}`,
|
|
category: index < 15 ? category1.id : category2.id,
|
|
},
|
|
}),
|
|
),
|
|
)
|
|
|
|
await _payload.create({
|
|
collection: 'posts',
|
|
data: {
|
|
title: 'Find me',
|
|
category: category1.id,
|
|
},
|
|
})
|
|
|
|
await _payload.create({
|
|
collection: 'posts',
|
|
data: {
|
|
title: 'Find me',
|
|
category: category2.id,
|
|
},
|
|
})
|
|
},
|
|
],
|
|
false,
|
|
)
|
|
}
|
|
|
|
export async function clearAndSeedEverything(_payload: Payload) {
|
|
return await seedDB({
|
|
_payload,
|
|
collectionSlugs: [postsSlug, categoriesSlug, 'users', 'media'],
|
|
seedFunction: seed,
|
|
snapshotKey: 'groupByTests',
|
|
// uploadsDir: path.resolve(dirname, './collections/Upload/uploads'),
|
|
})
|
|
}
|