Files
payload/packages/db-mongodb/src/deleteMany.ts
Alessio Gravili ae7d6f97d2 chore: formatting and linting (#3261)
* 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
2023-09-01 17:39:44 +02:00

25 lines
597 B
TypeScript

import type { DeleteMany } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from '.'
import { withSession } from './withSession'
export const deleteMany: DeleteMany = async function deleteMany(
this: MongooseAdapter,
{ collection, req = {} as PayloadRequest, where },
) {
const Model = this.collections[collection]
const options = {
...withSession(this, req.transactionID),
lean: true,
}
const query = await Model.buildQuery({
payload: this.payload,
where,
})
await Model.deleteMany(query, options)
}