To bind my data on the mobile side it works like this :
getHeros() {
this.wakanda.getCatalog().then(ds => {
ds['Superhero'].query({orderBy:"ID desc",pageSize:3}).then(collection => {
this.favoriteSuperheroes = collection.entities;
});
});
}
But like this I work directly on the table. I have a method who provide me everything I want on the server side.
I want to know, if I call my method in the backend and store it in a variable like this:
var favoriteMethod = ds.Superhero.myDataClassMethod();
How I can use this variable on the mobile side ?
Your first example is probably the best. Another (longer) trick would be to:
Create a request handler
// Let's say you define a http://127.0.0.1:8081/getSuperHeroesData request handler httpServer.addRequestHandler('^/getSuperHeroesData$', 'super-heroes-module', 'getData');
Define a super-heroes-module
module in your backend/modules
directory
// modules/super-heroes-module/index.js exports.getData = function pong( request, response ){ return ds.Superhero.myDataClassMethod(); }
So when you call http://127.0.0.1:8081/getSuperHeroesData from your mobile front end, it will trigger the getData
method from super-heroes-module
and return the result in your HTTP request response.