Search...
listExternalDatabaseConnections( )
Developer Preview
Retrieves a list of all external database collections associated with the site or project.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function listExternalDatabaseConnections(options: ListExternalDatabaseConnectionsOptions): Promise<ListExternalDatabaseConnectionsResponse>
listExternalDatabaseConnections Parameters
NAME
TYPE
DESCRIPTION
options
Optional
ListExternalDatabaseConnectionsOptions
Returns
Return Type:
Promise<
ListExternalDatabaseConnectionsResponse
>NAME
TYPE
DESCRIPTION
externalDatabaseConnections
Array<
ExternalDatabaseConnection
>List of external database connections.
pagingMetadata
PagingMetadata
Paging metadata
Was this helpful?
List existing external database connections (dashboard page code)
Copy Code
1import { externalDatabaseConnections } from "wix-data.v2";2import { elevate } from "wix-auth";34const elevatedListExternalDbConnections = elevate(externalDatabaseConnections.listExternalDatabaseConnections);56export async function myListExternalDatabaseConnectionsFunction() {7 try {8 const listExternalDbConnectionsResponse = await elevatedListExternalDbConnections();910 const firstConnectionName = listExternalDbConnectionsResponse.externalDatabaseConnections[0].name;11 const firstConnectionHaveCollections = listExternalDbConnectionsResponse.externalDatabaseConnections[0].connectionStatus.hasCollections;1213 console.log('Here is a list of all current external database connections: ', listExternalDbConnectionsResponse.externalDatabaseConnections);1415 return listExternalDbConnectionsResponse;16 } catch (error) {17 console.error(error);18 // Handle the error19 }20}2122/* Promise resolves to:23 * [24 * {25 * "capabilities": {26 * "collectionModificationsSupported": false,27 * "fieldTypes": []28 * }29 * "configuration": {30 * "secretKey": "fkapmf9s-kf5z-lg04-mfia-kfo294pamvi5"31 * },32 * "connectionStatus": {33 * "successful": true,34 * "causeOfFailure": "NONE",35 * "hasCollections": "YES"36 * },37 * "endpoint": "https://example.com/my-external-database",38 * "name": "connection1",39 * "protocolVersion": "V2",40 * },41 * {42 * "capabilities": {43 * "collectionModificationsSupported": false,44 * "fieldTypes": []45 * }46 * "configuration": {47 * "secretKey": "ukapguvn-kf5z-kfo4-kg94-nfoem4pamfi6"48 * },49 * "connectionStatus": {50 * "successful": true,51 * "causeOfFailure": "NONE",52 * "hasCollections": "YES"53 * },54 * "endpoint": "https://example.com/my-external-database",55 * "name": "connectionFour",56 * "protocolVersion": "V2",57 * },58 * {59 * "capabilities": {60 * "collectionModificationsSupported": false,61 * "fieldTypes": []62 * }63 * "configuration": {64 * "secretKey": "kf0pguvn-mgoi-kfo4-kg94-nfoefds5mfi6"65 * },66 * "connectionStatus": {67 * "successful": true,68 * "causeOfFailure": "NONE",69 * "hasCollections": "YES"70 * },71 * "endpoint": "https://example.com/my-external-database",72 * "name": "connectionThree",73 * "protocolVersion": "V2",74 * },75 * {76 * "capabilities": {77 * "collectionModificationsSupported": false,78 * "fieldTypes": []79 * }80 * "configuration": {81 * "secretKey": "fergfy84-kf5z-fdsf-kg94-nfoegfdg67i6"82 * },83 * "connectionStatus": {84 * "successful": true,85 * "causeOfFailure": "NONE",86 * "hasCollections": "YES"87 * },88 * "endpoint": "https://example.com/my-external-database",89 * "name": "connectionTwo",90 * "protocolVersion": "V2",91 * },92 * {93 * "applicationId": "8b7e9a62-t5hd-4372-gres-c6fb7762600b"94 * "connectionStatus": {95 * "successful": false,96 * "causeOfFailure": "DESTINATION_ENDPOINT_NOT_DEFINED",97 * "hasCollections": "UNKNOWN"98 * },99 * "name": "extDbSpi",100 * "protocolVersion": "V3",101 * }102 * ]103 */
List existing external database connections (export from backend code)
Copy Code
1import { Permissions, webMethod } from "wix-web-module";2import { externalDatabaseConnections } from "wix-data.v2";3import { elevate } from "wix-auth";45const elevatedListExternalDbConnections = elevate(externalDatabaseConnections.listExternalDatabaseConnections);67export const myListExternalDatabaseConnectionsFunction = webMethod(8 Permissions.Admin,9 async () => {10 try {11 const listExternalDbConnectionsResponse = await elevatedListExternalDbConnections();1213 const firstConnectionName = listExternalDbConnectionsResponse.externalDatabaseConnections[0].name;14 const firstConnectionHaveCollections = listExternalDbConnectionsResponse.externalDatabaseConnections[0].connectionStatus.hasCollections;1516 console.log('Here is a list of all current external database connections: ', listExternalDbConnectionsResponse.externalDatabaseConnections);1718 return listExternalDbConnectionsResponse;19 } catch (error) {20 console.error(error);21 // Handle the error22 }23 }24)2526/* Promise resolves to:27 * [28 * {29 * "capabilities": {30 * "collectionModificationsSupported": false,31 * "fieldTypes": []32 * }33 * "configuration": {34 * "secretKey": "fkapmf9s-kf5z-lg04-mfia-kfo294pamvi5"35 * },36 * "connectionStatus": {37 * "successful": true,38 * "causeOfFailure": "NONE",39 * "hasCollections": "YES"40 * },41 * "endpoint": "https://example.com/my-external-database",42 * "name": "connection1",43 * "protocolVersion": "V2",44 * },45 * {46 * "capabilities": {47 * "collectionModificationsSupported": false,48 * "fieldTypes": []49 * }50 * "configuration": {51 * "secretKey": "ukapguvn-kf5z-kfo4-kg94-nfoem4pamfi6"52 * },53 * "connectionStatus": {54 * "successful": true,55 * "causeOfFailure": "NONE",56 * "hasCollections": "YES"57 * },58 * "endpoint": "https://example.com/my-external-database",59 * "name": "connectionFour",60 * "protocolVersion": "V2",61 * },62 * {63 * "capabilities": {64 * "collectionModificationsSupported": false,65 * "fieldTypes": []66 * }67 * "configuration": {68 * "secretKey": "kf0pguvn-mgoi-kfo4-kg94-nfoefds5mfi6"69 * },70 * "connectionStatus": {71 * "successful": true,72 * "causeOfFailure": "NONE",73 * "hasCollections": "YES"74 * },75 * "endpoint": "https://example.com/my-external-database",76 * "name": "connectionThree",77 * "protocolVersion": "V2",78 * },79 * {80 * "capabilities": {81 * "collectionModificationsSupported": false,82 * "fieldTypes": []83 * }84 * "configuration": {85 * "secretKey": "fergfy84-kf5z-fdsf-kg94-nfoegfdg67i6"86 * },87 * "connectionStatus": {88 * "successful": true,89 * "causeOfFailure": "NONE",90 * "hasCollections": "YES"91 * },92 * "endpoint": "https://example.com/my-external-database",93 * "name": "connectionTwo",94 * "protocolVersion": "V2",95 * },96 * {97 * "applicationId": "8b7e9a62-t5hd-4372-gres-c6fb7762600b"98 * "connectionStatus": {99 * "successful": false,100 * "causeOfFailure": "DESTINATION_ENDPOINT_NOT_DEFINED",101 * "hasCollections": "UNKNOWN"102 * },103 * "name": "extDbSpi",104 * "protocolVersion": "V3",105 * }106 * ]107 */
List existing external database connections with pagination
Copy Code
1import { Permissions, webMethod } from "wix-web-module";2import { externalDatabaseConnections } from "wix-data.v2";3import { elevate } from "wix-auth";45const elevatedListExternalDbConnections = elevate(externalDatabaseConnections.listExternalDatabaseConnections);67/* Sample options object:8 *9 * {10 * paging: {11 * limit: 3,12 * offset: 113 * }14 * }15 */1617export const myListExternalDatabaseConnectionsFunctionOptions = webMethod(18 Permissions.Admin,19 async (options) => {20 try {21 const listExternalDbConnectionsResponse = await elevatedListExternalDbConnections(options);2223 const firstConnectionName = listExternalDbConnectionsResponse.externalDatabaseConnections[0].name;24 const firstConnectionHaveCollections = listExternalDbConnectionsResponse.externalDatabaseConnections[0].connectionStatus.hasCollections;2526 console.log('Here is a list of all current external database connections: ', listExternalDbConnectionsResponse.externalDatabaseConnections);2728 return listExternalDbConnectionsResponse;29 } catch (error) {30 console.error(error);31 // Handle the error32 }33 }34)3536/* Promise resolves to:37 * {38 * "externalDatabaseConnections": [39 * {40 * "capabilities": {41 * "collectionModificationsSupported": false,42 * "fieldTypes": []43 * }44 * "configuration": {45 * "secretKey": "kvod85qz-fk40-mfi5-mfi4-mflqpmgl4f1"46 * },47 * "connectionStatus": {48 * "successful": true,49 * "causeOfFailure": "NONE",50 * "hasCollections": "YES"51 * },52 * "endpoint": "https://example.com/my-external-database",53 * "name": "connectionFour",54 * "protocolVersion": "V2",55 * },56 * {57 * "capabilities": {58 * "collectionModificationsSupported": false,59 * "fieldTypes": []60 * }61 * "configuration": {62 * "secretKey": "lfoe8tfd-fl35-mfo4-mfd1-mvkf99bjfi30"63 * },64 * "connectionStatus": {65 * "successful": true,66 * "causeOfFailure": "NONE",67 * "hasCollections": "YES"68 * },69 * "endpoint": "https://example.com/my-external-database",70 * "name": "connectionThree",71 * "protocolVersion": "V2",72 * },73 * {74 * "capabilities": {75 * "collectionModificationsSupported": false,76 * "fieldTypes": []77 * }78 * "configuration": {79 * "secretKey": "fkapguvn-kf5z-kfo4-kg94-nfoem4pamfi6"80 * },81 * "connectionStatus": {82 * "successful": true,83 * "causeOfFailure": "NONE",84 * "hasCollections": "YES"85 * },86 * "endpoint": "https://example.com/my-external-database",87 * "name": "connectionTwo",88 * "protocolVersion": "V2",89 * }90 * ],91 * "pagingMetadata": {92 * "count": 3,93 * "offset": 1,94 * "total": 5,95 * "tooManyToCount": false96 * }97 * }98 */