Skip to content

Commit

Permalink
fix(mongodb): Speed up multi create (#3171)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaddyWarbucks committed Apr 28, 2023
1 parent cacedf5 commit e34f728
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions packages/mongodb/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ export class MongoDbAdapter<
? model
.insertMany(data.map(setId), writeOptions)
.then(async (result) =>
Promise.all(
Object.values(result.insertedIds).map(async (_id) => model.findOne({ _id }, params.mongodb))
)
model.find({ _id: { $in: Object.values(result.insertedIds) } }, params.mongodb).toArray()
)
: model
.insertOne(setId(data), writeOptions)
Expand Down

0 comments on commit e34f728

Please sign in to comment.