MCPcopy
hub / github.com/mongodb/node-mongodb-native / isSharded

Function isSharded

src/cmap/wire_protocol/shared.ts:31–48  ·  view source on GitHub ↗
(topologyOrServer?: Topology | Server | Connection)

Source from the content-addressed store, hash-verified

29}
30
31export function isSharded(topologyOrServer?: Topology | Server | Connection): boolean {
32 if (topologyOrServer == null) {
33 return false;
34 }
35
36 if (topologyOrServer.description && topologyOrServer.description.type === ServerType.Mongos) {
37 return true;
38 }
39
40 // NOTE: This is incredibly inefficient, and should be removed once command construction
41 // happens based on `Server` not `Topology`.
42 if (topologyOrServer.description && topologyOrServer.description instanceof TopologyDescription) {
43 const servers: ServerDescription[] = Array.from(topologyOrServer.description.servers.values());
44 return servers.some((server: ServerDescription) => server.type === ServerType.Mongos);
45 }
46
47 return false;
48}

Callers 1

prepareCommandMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected