Skip to content

Commit a6dc933

Browse files
committed
Add pg_documentdb
1 parent 774fc9a commit a6dc933

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/mongodb-build-info/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export function getGenuineMongoDB(uri: string): {
140140
export async function identifyServerName(
141141
uri: string,
142142
runCommand: (command: Document) => Promise<Document>,
143+
adminCommand: (command: Document) => Promise<Document>,
143144
): Promise<string> {
144145
const hostname = getHostnameFromUrl(uri);
145146
if (hostname.match(COSMOS_DB_REGEX)) {
@@ -160,6 +161,14 @@ export async function identifyServerName(
160161
return 'ferretdb';
161162
}
162163

164+
try {
165+
await adminCommand({ getParameter: 'foo' });
166+
} catch (error) {
167+
if (error instanceof Error && /documentdb_api/.test(error.message)) {
168+
return 'pg_documentdb';
169+
}
170+
}
171+
163172
return 'mongodb';
164173
}
165174

0 commit comments

Comments
 (0)