Removes PayloadRequestWithData in favour of just PayloadRequest with
optional types for `data` and `locale`
`addDataAndFileToRequest` and `addLocalesToRequestFromData` now takes in
a single argument instead of an object
```ts
// before
await addDataAndFileToRequest({ request: req })
addLocalesToRequestFromData({ request: req })
// current
await addDataAndFileToRequest(req)
addLocalesToRequestFromData(req)
```
---------
Co-authored-by: Paul Popus <paul@nouance.io>
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import type { FindGlobalVersions, PayloadRequest, SanitizedGlobalConfig } from 'payload'
|
|
|
|
import { buildVersionGlobalFields } from 'payload'
|
|
import toSnakeCase from 'to-snake-case'
|
|
|
|
import type { PostgresAdapter } from './types.js'
|
|
|
|
import { findMany } from './find/findMany.js'
|
|
|
|
export const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(
|
|
this: PostgresAdapter,
|
|
{
|
|
global,
|
|
limit,
|
|
locale,
|
|
page,
|
|
pagination,
|
|
req = {} as PayloadRequest,
|
|
skip,
|
|
sort: sortArg,
|
|
where,
|
|
},
|
|
) {
|
|
const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(
|
|
({ slug }) => slug === global,
|
|
)
|
|
const sort = typeof sortArg === 'string' ? sortArg : '-createdAt'
|
|
|
|
const tableName = this.tableNameMap.get(
|
|
`_${toSnakeCase(globalConfig.slug)}${this.versionsSuffix}`,
|
|
)
|
|
|
|
const fields = buildVersionGlobalFields(globalConfig)
|
|
|
|
return findMany({
|
|
adapter: this,
|
|
fields,
|
|
limit,
|
|
locale,
|
|
page,
|
|
pagination,
|
|
req,
|
|
skip,
|
|
sort,
|
|
tableName,
|
|
where,
|
|
})
|
|
}
|