INNER CODE UNIT · TypeScript

masterIndex

denodrivers/mongo · src/cluster.ts:105

    const masterIndex = results.findIndex((result) =>
      result.isWritablePrimary || result.ismaster
    );
    if (masterIndex === -1) throw new Error(`Could not find a master node`);
    this.#masterIndex = masterIndex;
  }

  private getMaster() {
    return {
      protocol: this.#protocols[this.#masterIndex],
      conn: this.#connections[this.#masterIndex],
    };
  }

  get protocol(): WireProtocol {
    return this.getMaster().protocol;
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…