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>
25 lines
621 B
TypeScript
25 lines
621 B
TypeScript
import type { DeleteVersions, PayloadRequest } from 'payload'
|
|
|
|
import type { MongooseAdapter } from './index.js'
|
|
|
|
import { withSession } from './withSession.js'
|
|
|
|
export const deleteVersions: DeleteVersions = async function deleteVersions(
|
|
this: MongooseAdapter,
|
|
{ collection, locale, req = {} as PayloadRequest, where },
|
|
) {
|
|
const VersionsModel = this.versions[collection]
|
|
const options = {
|
|
...withSession(this, req.transactionID),
|
|
lean: true,
|
|
}
|
|
|
|
const query = await VersionsModel.buildQuery({
|
|
locale,
|
|
payload: this.payload,
|
|
where,
|
|
})
|
|
|
|
await VersionsModel.deleteMany(query, options)
|
|
}
|