mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Add support for auxiliary MongoDB sessions in startSession function
GitOrigin-RevId: 3ea0acd9c78e837f8aaf7c1e5ac06f7befb80805
This commit is contained in:
committed by
Copybot
parent
5df372186e
commit
7f74e5b1d2
@@ -160,9 +160,19 @@ export async function waitForDb() {
|
||||
/**
|
||||
* Starts a client session for use with multi-document transactions
|
||||
* (session.withTransaction(...)). Requires Mongo to be running as a replica
|
||||
* set, which is enforced at startup for every deployment
|
||||
* set, which is enforced at startup for every deployment.
|
||||
*
|
||||
* The session must be started on the same MongoClient as the collections it
|
||||
* operates on, otherwise Mongo throws "ClientSession must be from the same
|
||||
* MongoClient".
|
||||
*
|
||||
* @param {{ aux?: boolean }} [options]
|
||||
*/
|
||||
export async function startSession() {
|
||||
export async function startSession({ aux = false } = {}) {
|
||||
if (aux && auxMongoClient) {
|
||||
await auxConnectionPromise
|
||||
return auxMongoClient.startSession()
|
||||
}
|
||||
const client = await connectionPromise
|
||||
return client.startSession()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user