Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

EN | ES

Sometimes, to create a gadget template that meets our needs, we need to be able to access more than one datasource. For this purpose, some methods have been implemented:

      vm.getDataFromDataSource(datasource,callbackFunction,filters,group,project,sort,limit,offset,param,debug)

First three params are available in versions older than empire but the others are new in this version. Every operation is applied in server pushing down the logic to the database.

datasource: identifier of the datasource that we want to access. Bear in mind that they will only return data to which the user has access. If we want to show a public dashboard, then the ontologies from which the datasources are formed must also be marked as public

...

param: it can be posible to use some params in the datasource, for example, overwrite inside some subquery some value for optimization. This param enable sql-inyection so you need to use it in controlled way. Param in the datasource is defined as {$param} for example:


SELECT t1.pt as pt
FROM
(select * from translations) as t1,
(select * from translations) as t2
where t1.{$cdest}=t2.id


It's compose with an array of json with two fields {"field":"paramtoverwrite","value":"value"} for example: [{"field":"cdest","value":"United States"}]

...

A promise is returned by this metod:


vm.get("DsRawRestaurants").then(
    data => console.log(data)
)


or (for backward compatibility)


vm.get("DsRawRestaurants").then(
    function(data){
        console.log(data)
    }
)


vm.getOne('datasource'): syntactic sugar for "vm.get(datasourcename,{"limit":1}) for only one value

...