Since Azure Mobile Apps does not provide a way to create relationships between tables I decided to create a custom API in my Node.js backend to return data from related tables. The idea was to implement the joins in the backend using SQL, like explained at the Mobile Services Doc.
The problem is that I'm using the new Mobile Apps and not the old Mobile Services, so the above code does not work anymore. As I understand the architecture changed from Mobile Service to Mobile Apps and the Node.js SDK is an express middleware package. So now we leverage azure-mobile-apps/src/data module to handle sql operations.
So I now I have to do something like this to read from a table in a Custom API inside the Node backend:
var queries = require('azure-mobile-apps/src/query');
module.exports = {
"get": function (req, res, next) {
var myTable = req.azureMobile.tables('TableName');
var query = queries.create('TableName');
query.where({'id':req.query.userId});
myTable.read(query).then(function(data){
res.send({ some: data });
});
}
};
But since the SQL is not exposed anymore I cannot use the JOIN command to return data from related tables. I would have to to use loops and many request to the database, which defeats the purpose.
-Is there a way to implement the joins in the backend using SQL on the new Mobile Apps Node.js SDK? Or any other better way?
Thank you very much!