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 items based on the provided filtering, sorting, and paging preferences.
function queryDataItems(
payload: QueryDataItemsEnvelope,
): QueryDataItemsResponse | Promise<QueryDataItemsResponse>;
import { externalDatabase } from "@wix/data/service-plugins";
externalDatabase.provideHandlers({
queryDataItems: 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:
items: [
{
name: "New York",
_id: "c285e77c-a86b-4361-a55f-c6b934d70187",
population: 8300000.0,
country: "US",
isCapital: false,
},
],
pagingMetadata: {
total: 1,
},
};
},
});