To configure and customize your service plugin, you need to provide important details in the plugin.json
configuration file.
If you created your service plugin extension with the CLI, required fields are automatically populated for you.
The namespace of the external database. This can be used to access collections within the database, for example namespace/collectionId
.
The URI where the service provider is deployed.
{
"namespace": "@your-account-name/your-app-name",
"uriConfig": {
"baseUri": "https://my-external-database-app.com/",
"alternativeUris": {
"absoluteUri": "https://www.my-external-database-app.com/my-create-collection",
"methodName": "CreateCollection"
}
}
}
Retrieves a list of data collections and their details.
When collectionIds
is empty, all existing collections are returned.
If a specified collection does not exist, that collection can be ignored.
function listCollections(
payload: ListCollectionsEnvelope,
): ListCollectionsResponse | Promise<ListCollectionsResponse>;
import { externalDatabase } from "@wix/data/service-plugins";
externalDatabase.provideHandlers({
listCollections: async (payload) => {
const { request, metadata } = payload;
// Use the `request` and `metadata` received from Wix and
// apply custom logic.
return {
// Return your response exactly as documented to integrate with Wix.
// Return value example:
collections: [
{
id: "cities",
displayName: "Cities",
fields: [
{
key: "_id",
displayName: "ID",
description: "The ID of the document",
type: "TEXT",
capabilities: {
sortable: true,
queryOperators: ["EQ", "LT", "GT", "LTE", "GTE"],
},
encrypted: false,
},
{
key: "name",
displayName: "Name",
description: "The name of the city",
type: "TEXT",
capabilities: {
sortable: true,
queryOperators: ["EQ", "STARTS_WITH"],
},
encrypted: false,
},
{
key: "country",
displayName: "Country",
description: "Country code",
type: "TEXT",
capabilities: {
sortable: true,
queryOperators: ["EQ"],
},
encrypted: false,
},
{
key: "pointsOfInterest",
displayName: "Points of interest",
type: "MULTI_REFERENCE",
multiReferenceOptions: {
referencedCollectionId: "pointsOfInterest",
},
encrypted: false,
},
{
key: "_createdDate",
displayName: "Created date",
description: "The date when the document was created",
type: "DATETIME",
capabilities: {
sortable: false,
queryOperators: [],
},
encrypted: false,
},
{
key: "_updatedDate",
displayName: "Updated date",
description: "The date when the document was last updated",
type: "DATETIME",
capabilities: {
sortable: false,
queryOperators: [],
},
encrypted: false,
},
],
capabilities: {
dataOperations: ["QUERY", "COUNT"],
},
permissions: {
insert: "ADMIN",
update: "ADMIN",
remove: "ADMIN",
read: "ANYONE",
},
pagingMode: "OFFSET",
},
{
id: "pointsOfInterest",
displayName: "Points of interest",
fields: [
{
key: "_id",
displayName: "ID",
description: "The ID of the document",
type: "TEXT",
capabilities: {
sortable: true,
queryOperators: ["EQ", "LT", "GT", "LTE", "GTE"],
},
encrypted: false,
},
{
key: "name",
displayName: "Name",
description: "The name of the city",
type: "TEXT",
encrypted: false,
},
],
capabilities: {
dataOperations: ["QUERY", "COUNT"],
},
permissions: {
insert: "ADMIN",
update: "ADMIN",
remove: "ADMIN",
read: "ANYONE",
},
pagingMode: "OFFSET",
},
],
};
},
});