Merge pull request #4804 from payloadcms/fix/#4802-transaction-options-false
fix(db-mongodb): transactionOptions=false typeErrors
This commit is contained in:
@@ -50,7 +50,7 @@ export const connect: Connect = async function connect(this: MongooseAdapter, pa
|
||||
|
||||
const client = this.connection.getClient()
|
||||
|
||||
if (!client.options.replicaSet || this.transactionOptions === false) {
|
||||
if (!client.options.replicaSet) {
|
||||
this.transactionOptions = false
|
||||
this.beginTransaction = undefined
|
||||
}
|
||||
|
||||
@@ -93,18 +93,13 @@ export function mongooseAdapter({
|
||||
connectOptions,
|
||||
disableIndexHints = false,
|
||||
migrationDir: migrationDirArg,
|
||||
transactionOptions,
|
||||
transactionOptions = {},
|
||||
url,
|
||||
}: Args): MongooseAdapterResult {
|
||||
function adapter({ payload }: { payload: Payload }) {
|
||||
const migrationDir = findMigrationDir(migrationDirArg)
|
||||
let beginTransactionFunction = beginTransaction
|
||||
mongoose.set('strictQuery', false)
|
||||
|
||||
if (transactionOptions === false) {
|
||||
beginTransactionFunction = () => null
|
||||
}
|
||||
|
||||
return createDatabaseAdapter<MongooseAdapter>({
|
||||
name: 'mongoose',
|
||||
|
||||
@@ -122,7 +117,7 @@ export function mongooseAdapter({
|
||||
versions: {},
|
||||
|
||||
// DatabaseAdapter
|
||||
beginTransaction: beginTransactionFunction,
|
||||
beginTransaction: transactionOptions ? beginTransaction : undefined,
|
||||
commitTransaction,
|
||||
connect,
|
||||
create,
|
||||
|
||||
Reference in New Issue
Block a user