SPI provision response

I am trying to build an External connector for SQL Database hosted on Azure.

I have built the framework SPI as described here https://www.wix.com/corvid/reference/external-database-collections.html

I am struggling with the format of the provision response… currently returning something like this…

{
  "table": "venues",
  "columns": [
    {
      "name": "venueid",
      "type": "number",
      "isPrimary": "PRI"
    }
  ]
}

whilst it adds a stub when I add External Data Source - no tables or columns are found.

Any ideas or pointers?

Did you also read the support page that goes with it?
https://support.wix.com/en/article/corvid-working-with-external-database-collections
https://github.com/wix/corvid-external-db-mysql-adapter

Step 5 - Adapter translation of data requests from the external database to your Wix site
Your external database will receive the request from your adapter and send a response back. This response will be based on its API, but your Wix site can’t work with that response.

You need the code in your adapter to:

  1. Receive the response from the external database.

  2. Convert that response into a response and payload that your Wix site can receive and send it back to your Wix site.

Yes, but I read that to suggest you need to implement some code behind the various data/ endpoints to interact with the database.

Having done a bit more reading and looking at the MySQL example here … https://github.com/wix/corvid-external-db-mysql-adapter

I think my original question may be a bit of a red herring…

I think Provision should return nothing, it seems to be a means to allow my end to register and allow subsequent connections.

However I am kind of expecting a call to the post: schemas/list or schemas/find endpoints as part or the registration - My logs show the Provision call come in but no other calls?

@benhancy once you add the endpoint, Wix Data will call your provision endpoint and if it returns 200 it will successfully add the driver. Does adding the driver succeed? Do you see the namespace in Database tree?

It will query schemas after that and if it finds at least one collection it will try to display it in our Content Manager and that will trigger another schema request and find endpoint.

@giedrius-grazevicius Thanks - I have made some progress, it is now adding the driver, (and I can now see the call to schemas/list coming in, but it’s not listing them…

EDIT: More Progress… It now seems to add my schema, but errors on Loading Data, whilst I guest it should be calling /data/find , my Logs suggest it’s not ? Not Clear if that means Schema hasn’t loaded properly or there is an upstream error on data/find before my logging?

Current Scheme looks like this…

{
“schemas”: [
{
“id”: “Venue”,
“ttl”: 240,
“defaultSort”: {
“fieldName”: “venueID”,
“direction”: “desc”
},
“allowedOperations”: [
“count”,
“find”,
“get”,
“insert”,
“remove”,
“update”
],
“fields”: {
“venueID”: {
“displayName”: “VenueID”,
“type”: “number”,
“queryOperators”: [
“contains”,
“endsWith”,
“eq”,
“ne”,
“startsWith”
],
“isDeleted”: false
},
“name”: {
“displayName”: “Name”,
“type”: “text”,
“queryOperators”: [
“contains”,
“endsWith”,
“eq”,
“ne”,
“startsWith”
],
“isDeleted”: false
}
},
“maxPageSize”: 50
}
]
}

Is there any error logging that can help me debug?

Bit more progress made today…

Managed to get the Node.JS sample up and running and discovered an undocumented display name field in the schema object was being produced, that stopped the error occurring on connection.

My working Schema files looks like this…
{
“schemas”: [ {
“id”: “Booking”,
“displayName”: “Booking”,
“ttl”: 3600,
“defaultSort”: null,
“allowedOperations”: [“get”, “find”, “count”, “update”, “insert”, “remove”],
“fields”: {
“_id”: {
“displayName”: “_id”,
“type”: “text”,
“queryOperators”: [“eq”, “lt”, “gt”, “hasSome”, “lte”, “gte”, “ne”, “startsWith”, “endsWith”]
},
“BookingID”: {
“displayName”: “BookingID”,
“type”: “number”,
“queryOperators”: [“eq”, “lt”, “gt”, “hasSome”, “lte”, “gte”, “ne”, “startsWith”, “endsWith”]
},
“BookingDate”: {
“displayName”: “BookingDate”,
“type”: “text”,
“queryOperators”: [“eq”, “lt”, “gt”, “hasSome”, “lte”, “gte”, “ne”, “startsWith”, “endsWith”]
},
“Notes”: {
“displayName”: “Notes”,
“type”: “text”,
“queryOperators”: [“eq”, “lt”, “gt”, “hasSome”, “lte”, “gte”, “ne”, “startsWith”, “endsWith”]
},
“VenueID”: {
“displayName”: “VenueID”,
“type”: “number”,
“queryOperators”: [“eq”, “lt”, “gt”, “hasSome”, “lte”, “gte”, “ne”, “startsWith”, “endsWith”]
}
},
“maxPageSize”: 50
}]
}
The Flow of calls seems to be … Schema\List → Schema\Find-> Data\Find

I now have data being pulled in from my SPI - sample data set …

{
“items”: [{
“BookingID”: 670,
“VenueID”: 45,
“BookingDate”: “2019-07-16T00:00:00”,
“Notes”: “Fhfhfh”,
}, {
“BookingID”: 972,
“VenueID”: 9,
“BookingDate”: “2019-07-22T00:00:00”,
“Notes”: “”,
}
],
“totalCount”: 2
}

However latest problem seems to be, when it has imported the schema it has created a field key against which it maps the data which uses a cameCase version of the field name i.e. BookingDate becomes bookingDate.

So when it lists the data it does not map to the correct field (rather creates a new one).

If I modify the Json serialization of the data response to match the camel case it works as expected, however rather than doing this for my entire data model, would be nice if there was a way I could tell it what key to use as part of the schema definition? (I have already tried id & key properties on the field def object).

This looks weird. Field keys should correspond to keys in the fields property in schema.

So

"BookingID": {
    "displayName": "BookingID",
    "type": "number",
    "queryOperators": ["eq", "lt", "gt", "hasSome", "lte", "gte", "ne", "startsWith", "endsWith"]
}

Should match


{
  "BookingID": 11
}

correctly. Can you share your site via private message, so I can inspect what is going on?

@giedrius-grazevicius apologies been on another project - how do I share?

Not sure If it is related but having modified the JSON to match the camelCase requirement, I have tried to create a Dynamic Page, however when I try to setup the page URL the field list is blank?

If I progress into the page design I can associate page items to fields in the database as expected.

Looking at debug on the page - the following error is displayed…

Error: com.wixpress.cloud.data.core.domain.schema.InvalidSchema: Invalid schema elementory-browser-support.min.js:1:9127

@benhancy only string fields that support urlized filter show up as options for Dynamic Page URL.