As an external database provider, you can integrate with Wix to allow a Wix sites to access and manage data stored anywhere, as if it were hosted natively on Wix.
The integration is done via an app in the Wix App Market and by implementing the External Database service plugin. After the app is installed on a site, Wix triggers a call to your service whenever the site needs to access and interact with the external database.
Using the service plugin, you can design your app to:
Wix offers a variety of data management solutions to accommodate common user needs at different scales. This includes support for internal databases that are hosted directly on Wix, as well as external databases hosted outside the Wix ecosystem.
You can store and manage data directly on Wix using the Wix Data API. Wix also supports managing data hosted on external databases. The External Database Connections API allows Wix Data to communicate with an external database as if it were hosted directly on Wix. Wix offers several out-of-the-box external database integrations for common platforms such as Google Cloud Platform (GCP), Amazon Web Services (AWS), or Microsoft Azure. These integrations translate Wix Data requests into the external database's protocol, and translate the response back into a format that Wix APIs can read.
To allow Wix Data to communicate with any other data source, implement the External Database service plugin.
Follow these steps to begin implementing your service plugin.
You can implement this service plugin with the following frameworks:
To configure and customize your plugin, you need to provide important information in the service plugin configuration file. You can configure your plugin in the Wix Dev Center. For details, see External Database Extension Configuration.
Use externalDatabase.provideHandlers()
to define the following handler functions that implement your custom business logic. Make sure you define all required functions.
Below is an example for implementing the External Database service plugin in your code.
This is the basic code structure for implementing the External Database service plugin with the Wix CLI:
This is the basic code structure for implementing a self-hosted External Database service plugin:
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.
Runs an aggregation query on the specified data collection and returns the resulting list of items.
Counts the number of items in the specified data collection that match the filtering preferences.
Creates a new data collection.
Deletes a data collection.
Lists the global capabilities the external database supports.
Inserts one or more item references into a referring field of the specified item.
Adds one or more items to a collection.
A data item object contains the _id
and _owner
fields. The response array must include the same items that were inserted, and each returned item must be added the _createdDate
and _updatedDate
fields.
However, data items can also be inserted without an _id
field. In that case, it is the service provider's responsibility to generate a unique ID for each item.
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.
Retrieves a list of items based on the provided filtering, sorting, and paging preferences.
Retrieves a list of distinct values for a given field for all items that match the query, without duplicates.
As with queryDataItems()
, this function retrieves items based on the filtering, sorting, and paging preferences provided. However, this function does not return the full items that match the query. Rather, for items that match the query, it returns all unique values in the field specified in fieldName
. If more than one item has the same value in that field, that value appears only once.
Retrieves the items referenced in the specified field of a referring item. Reference fields refer to items that exist in different collections. Implement this function so callers can retrieve the full details of the referenced items.
This service plugin supports item multi-references, which means that data collections can have many-to-many relationships with other collections. For example, consider a scenario where a Movies collection includes a multi-reference Actors field, which might refer to several Actor items in an Actors collection. Users can therefore query the Movies collection to retrieve the Actor items referenced in each Movie item.
Notes:
queryDataItems()
function for the Awards collection.isReferenced()
function of the Data API.
Removes one or more item references from a referring field of the specified item.
Removes one or more items from a collection. The response object must contain the removed item.
Removes all items from a collection.
Updates the structure of an existing data collection.
Some parameters, such as capabilities
and pagingMode
, are determined by the service provider. If the collection passed in the request contains these parameters, their values must be ignored. However, these fields must be included in the response collection with relevant values.
Updates one or more items in a collection. Items must be completely replaced.
The response array must include the same items that were updated, and each returned item must be added the _createdDate
and _updatedDate
fields.