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

Function sameServerSelector

src/sdam/server_selection.ts:71–84  ·  view source on GitHub ↗
(description?: ServerDescription)

Source from the content-addressed store, hash-verified

69 * if it is in a state that it can have commands sent to it.
70 */
71export function sameServerSelector(description?: ServerDescription): ServerSelector {
72 return function sameServerSelector(
73 _topologyDescription: TopologyDescription,
74 servers: ServerDescription[],
75 _deprioritized: DeprioritizedServers
76 ): ServerDescription[] {
77 if (!description) return [];
78 // Filter the servers to match the provided description only if
79 // the type is not unknown.
80 return servers.filter(sd => {
81 return sd.address === description.address && sd.type !== ServerType.Unknown;
82 });
83 };
84}
85
86/**
87 * Returns a server selector that uses a read preference to select a

Callers 2

Calls 1

filterMethod · 0.45

Tested by

no test coverage detected