In the `findOne` db operation, we return `null` if the document was not found. For single-document delete and update operations, if the document you wanted to update is not found, the following runtime error is thrown instead: `Cannot read properties of null (reading '_id')`. This PR correctly handles these cases and returns `null` from the db method, just like the `findOne` operation.
Payload MongoDB Adapter
Official MongoDB adapter for Payload.
Installation
npm install @payloadcms/db-mongodb
Usage
import { buildConfig } from 'payload'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
export default buildConfig({
db: mongooseAdapter({
url: process.env.DATABASE_URI,
}),
// ...rest of config
})
More detailed usage can be found in the Payload Docs.