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>
40 lines
874 B
TypeScript
40 lines
874 B
TypeScript
import type { Find, PayloadRequest, SanitizedCollectionConfig } from 'payload'
|
|
|
|
import toSnakeCase from 'to-snake-case'
|
|
|
|
import type { PostgresAdapter } from './types.js'
|
|
|
|
import { findMany } from './find/findMany.js'
|
|
|
|
export const find: Find = async function find(
|
|
this: PostgresAdapter,
|
|
{
|
|
collection,
|
|
limit,
|
|
locale,
|
|
page = 1,
|
|
pagination,
|
|
req = {} as PayloadRequest,
|
|
sort: sortArg,
|
|
where,
|
|
},
|
|
) {
|
|
const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config
|
|
const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort
|
|
|
|
const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))
|
|
|
|
return findMany({
|
|
adapter: this,
|
|
fields: collectionConfig.fields,
|
|
limit,
|
|
locale,
|
|
page,
|
|
pagination,
|
|
req,
|
|
sort,
|
|
tableName,
|
|
where,
|
|
})
|
|
}
|