This endpoint is called to retrieve a list of datasets and their columns that this Plugin makes available for a particular end-user. The /datasets endpoint is responsible for giving information about the structure of the data to Luzmo. Let’s start simple by returning static data. This will give you a clear example of the required return structure.
// > index.js
...
app.get('/datasets', function(req, res) {
// Temporary example of a simple metadata definition
var datasetMetadata = [{
id: "some id",
name: {en: `Burritos`},
description: {en: `Beware, burritos below`},
columns: [
{id: 'name', name: {en: 'Name'}, type: 'hierarchy'},
{id: 'price', name: {en: 'Price'}, type: 'numeric'},
{id: 'expirationday', name: {en: 'Expiration Day'}, type: 'datetime'}
]
}]
return res.status(200).json(datasetMetadata);
})
The metadata that is returned by /datasets consists of an array of objects. Each object defines a separate dataset. Each dataset has an id, a name, a description and an array of columns. Within this array you define the metadata for each column separately by providing the id, the name and the type of the column.
The example above defines a burrito plugin that will only provide one dataset called ‘Burritos’. The code defines one dataset which contains three columns, each of certain available type. Regarding these data types, Luzmo keeps things simple and only supports 3 data types:
The following article will explain how to dynamically construct this and map your database types to cumul.io types.