updateExternalDatabaseConnection( )
Updates an external database connection.
Description
An external database collection name must be provided in name
.
If an existing external database connection is found with the same name, that connection's details are updated.
If no external database connection has that name, the request fails.
Note: After an external database connection is updated, it only contains the values provided in the request. All previous values are lost.
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function updateExternalDatabaseConnection(name: string, externalDatabaseConnection: UpdateExternalDatabaseConnection): Promise<ExternalDatabaseConnection>
updateExternalDatabaseConnection Parameters
NAME
TYPE
DESCRIPTION
Name of the external database connection.
An external database connection may connect to one or more external data collections or tables.
These are represented as connectionName/dataCollectionId
.
Updated external database connection details. The existing connection is replaced with this version.
Returns
Updated external database connection details.
Return Type:
NAME
TYPE
DESCRIPTION
The external database's capabilities.
Settings passed to the external database connection as part of each request. These settings can relate to authentication, tenancy, or provide any other information needed for processing a request. Their content and structure depend on the specific requirements of the external database's API.
Status of the external database connection. Includes whether the connection was established successfully, and if not, the reason for the failure.
Base URL for provisioning and managing data in the external database. For example: https://example.com/my-external-database
.
Name of the external database connection.
An external database connection may connect to one or more external data collections or tables.
These are represented as connectionName/dataCollectionId
.
Was this helpful?
1import { externalDatabaseConnections } from "wix-data.v2";2import { elevate } from "wix-auth";34const elevatedUpdateExternalDatabaseConnection = elevate(externalDatabaseConnections.updateExternalDatabaseConnection);56/*7 * Sample name value: 'connectionOne'8 *9 * Sample externalDatabaseConnection object:10 *11 * {12 * capabilities: {13 * collectionModificationsSupported: false,14 * fieldTypes: []15 * },16 * configuration: {17 * secretKey: '74dbd6d6-ec5b-4668-8229-c77379bc6431',18 * username: 'Jane Doe'19 * },20 * endpoint: 'https://example.com/my-external-database'21 * }22 */2324export async function myUpdateExternalDatabaseConnectionFunction(name, externalDatabaseConnection) {25 try {26 const updateExternalDatabaseConnectionResponse = await elevatedUpdateExternalDatabaseConnection(name, externalDatabaseConnection);2728 console.log(`The ${name} connection was updated with the new values. It is currently mounted at ${updateExternalDatabaseConnectionResponse.endpoint}`);2930 return updateExternalDatabaseConnectionResponse;31 } catch (error) {32 console.error(error);33 // Handle the error34 }35}3637/* Promise resolves to:38 * {39 * "capabilities": {40 * "collectionModificationsSupported": false,41 * "fieldTypes": []42 * }43 * "configuration": {44 * "secretKey": "74dbd6d6-ec5b-4668-8229-c77379bc6431",45 * "username": "Jane Doe"46 * },47 * "connectionStatus": {48 * "successful": true,49 * "causeOfFailure": "NONE",50 * "hasCollections": "YES"51 * },52 * "endpoint": "https://example.com/my-external-database",53 * "name": "connection1",54 * "protocolVersion": "<connection-protocol-version>"55 * }56 */
1import { Permissions, webMethod } from "wix-web-module";2import { externalDatabaseConnections } from "wix-data.v2";3import { elevate } from "wix-auth";45const elevatedUpdateExternalDatabaseConnection = elevate(externalDatabaseConnections.updateExternalDatabaseConnection);67/*8 * Sample name value: 'connectionOne'9 *10 * Sample externalDatabaseConnection object:11 *12 * {13 * capabilities: {14 * collectionModificationsSupported: false,15 * fieldTypes: []16 * },17 * configuration: {18 * secretKey: '74dbd6d6-ec5b-4668-8229-c77379bc6431',19 * username: 'Jane Doe'20 * },21 * endpoint: 'https://example.com/my-external-database'22 * }23 */2425export const myUpdateExternalDatabaseConnectionFunction = webMethod(26 Permissions.Admin,27 async (name, externalDatabaseConnection) => {28 try {29 const updateExternalDatabaseConnectionResponse = await elevatedUpdateExternalDatabaseConnection(name, externalDatabaseConnection);3031 console.log(`The ${name} connection was updated with the new values. It is currently mounted at ${updateExternalDatabaseConnectionResponse.endpoint}`);3233 return updateExternalDatabaseConnectionResponse;34 } catch (error) {35 console.error(error);36 // Handle the error37 }38 }39)4041/* Promise resolves to:42 * {43 * "capabilities": {44 * "collectionModificationsSupported": false,45 * "fieldTypes": []46 * }47 * "configuration": {48 * "secretKey": "74dbd6d6-ec5b-4668-8229-c77379bc6431",49 * "username": "Jane Doe"50 * },51 * "connectionStatus": {52 * "successful": true,53 * "causeOfFailure": "NONE",54 * "hasCollections": "YES"55 * },56 * "endpoint": "https://example.com/my-external-database",57 * "name": "connection1",58 * "protocolVersion": "<connection-protocol-version>"59 * }60 */