Skip to content

Commit fe22615

Browse files
authored
fix(mongodb): Ensure transactions are used properly in create (#2699)
1 parent f886640 commit fe22615

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/mongodb/src/adapter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,18 @@ export class MongoDbAdapter<
215215

216216
return entry
217217
}
218+
218219
const promise = Array.isArray(data)
219220
? model
220221
.insertMany(data.map(setId), writeOptions)
221222
.then(async (result) =>
222-
Promise.all(Object.values(result.insertedIds).map(async (_id) => model.findOne({ _id })))
223+
Promise.all(
224+
Object.values(result.insertedIds).map(async (_id) => model.findOne({ _id }, params.mongodb))
225+
)
223226
)
224227
: model
225228
.insertOne(setId(data), writeOptions)
226-
.then(async (result) => model.findOne({ _id: result.insertedId }))
229+
.then(async (result) => model.findOne({ _id: result.insertedId }, params.mongodb))
227230

228231
return promise.then(select(params, this.id)).catch(errorHandler)
229232
}

0 commit comments

Comments
 (0)