* chore: lint packages/payload * chore: lint packages/db-postgres * chore: lint packages/db-mongodb * chore: update eslintrc exclusion rules * chore: update eslintrc exclusion rules * chore: lint misc files * chore: run prettier through packages * chore: run eslint on payload again * chore: prettier misc files * chore: prettier docs
26 lines
654 B
TypeScript
26 lines
654 B
TypeScript
import type { DeleteVersions } from 'payload/database'
|
|
import type { PayloadRequest } from 'payload/types'
|
|
|
|
import type { MongooseAdapter } from '.'
|
|
|
|
import { withSession } from './withSession'
|
|
|
|
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)
|
|
}
|