getExternalDatabaseConnection( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves an external database connection by name.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage External Database Connections
Learn more about app permissions.
Method Declaration
Copy
function getExternalDatabaseConnection(
  name: string,
): Promise<ExternalDatabaseConnection>;
Method Parameters
namestringRequired

Name of the external database connection to retrieve.

Returns
Return Type:Promise<ExternalDatabaseConnection>
JavaScript
import { externalDatabaseConnections } from "wix-data.v2"; import { elevate } from "wix-auth"; const elevatedGetExternalDbConnection = elevate( externalDatabaseConnections.getExternalDatabaseConnection, ); /* * Sample name value: 'ConnectionOne' */ export async function myGetExternalDbConnection(name) { try { const getExternalDbConnectionResponse = await elevatedGetExternalDbConnection(name); const connectionSuccessful = getExternalDbConnectionResponse.connectionStatus.successful; const dbEndpoint = getExternalDbConnectionResponse.endpoint; console.log( `Retrieved the ${name} external database connection, which is ${connectionSuccessful ? "successful" : "unsuccessful"}`, ); console.log(`It is mounted at ${dbEndpoint}`); return getExternalDbConnectionResponse; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * * { * "capabilities": { * "collectionModificationsSupported": true, * "fieldTypes": [] * } * "configuration": { * "secretKey": "74dbd6d6-ec5b-4668-8229-c77379bc6431" * }, * "connectionStatus": { * "causeOfFailure": "NONE", * "hasCollections": "YES" * "successful": true, * }, * "endpoint": "https://example.com/my-external-database", * "name": "connectionOne", * "protocolVersion": "V2" * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?