Skip to content

Commit

Permalink
Reverse order of insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Oct 26, 2023
1 parent 8434496 commit 4d9ec59
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/modules-mongo/packages/archivist/src/Archivist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ export class MongoDBArchivist extends MongoDBArchivistBase {
const [bw, p] = await validByType(payloads)
const boundWitnesses = await Promise.all(bw.map((x) => toBoundWitnessWithMeta(x)))
const payloadsWithMeta = await Promise.all(p.map((x) => toPayloadWithMeta(x)))
if (boundWitnesses.length) {
const boundWitnessesResult = await this.boundWitnesses.insertMany(boundWitnesses)
if (!boundWitnessesResult.acknowledged || boundWitnessesResult.insertedCount !== boundWitnesses.length)
throw new Error('MongoDBDeterministicArchivist: Error inserting BoundWitnesses')
}
if (payloadsWithMeta.length) {
const payloadsResult = await this.payloads.insertMany(payloadsWithMeta)
if (!payloadsResult.acknowledged || payloadsResult.insertedCount !== payloadsWithMeta.length)
throw new Error('MongoDBDeterministicArchivist: Error inserting Payloads')
}
if (boundWitnesses.length) {
const boundWitnessesResult = await this.boundWitnesses.insertMany(boundWitnesses)
if (!boundWitnessesResult.acknowledged || boundWitnessesResult.insertedCount !== boundWitnesses.length)
throw new Error('MongoDBDeterministicArchivist: Error inserting BoundWitnesses')
}
return payloads ?? []
}

Expand Down

0 comments on commit 4d9ec59

Please sign in to comment.